MyroC  MyroC.3.2a
C-based infrastructure for controling Scribbler 2 robots
Data Structures | Functions
MyroC.h File Reference

Header for a C-based, my-robot package for the Scribbler 2. More...

Go to the source code of this file.

Data Structures

struct  Pixel
 Struct for a pixel. More...
 
struct  Picture
 Struct for a picture object. More...
 

Functions

int rConnect (const char *address)
 connects program to Scribbler More...
 
void rDisconnect ()
 stop Scribbler motion and close Bluetooth More...
 
void rSetConnection (int new_socket_num)
 set current connection to the socket number More...
 
void rFinishProcessing ()
 all timed motions/image displays completed, all robots stopped, and all robot Bluetooth connections closed More...
 
void rSetVolume (char highMute)
 Set sound to high volume (H) or mute (M) highMute set volume of Scribbler. More...
 
void rBeep (double duration, int frequency)
 Beeps with the given duration and frequency. More...
 
void rBeep2 (double duration, int freq1, int freq2)
 Generates two notes for the prescribed duration. More...
 
void rSetName (const char *name)
 Change name stored in the robot to the 16-byte name given. More...
 
const char * rGetName ()
 Get the name of the robot. More...
 
void rSetForwardness (char *direction)
 specifies which end of the Scribbler is considered the front More...
 
void rSetForwardnessTxt (char *direction)
 alternative to rSetForwardness for compatibility with earlier MyroC
 
char * rGetForwardness ()
 Gets the forwardness of the Scribbler. More...
 
void rSetLEDFront (int led)
 Set the front [fluke] LED on or off. More...
 
void rSetLEDBack (double led)
 Set the the intensity of the back fluke LED. More...
 
double rGetBattery ()
 Get the current voltage from the Scribbler batteries; Maximum charge from 6 batteries could be up to 6 volts; Manufacturer suggests batteries should be changed below 4.1 volts. More...
 
int rGetStall (int sampleSize)
 
void rSetBluetoothEcho (char onOff)
 Turn on and off echoing of Bluetooth transmissions All robot commands involve the transmission of a command over Bluetooth Scribbler commands are always 9 bytes
Fluke commands have varying lengths
The fluke echos most, but not all, of the commands
For many commands, the fluke also echos 11 bytes of sensor data. More...
 
void rGetLightsAll (int lightSensors[3], int sampleSize)
 Get the average values of each of the three light sensors in an array. Values of each light sensor can somewhat (typically under 5%-10%). To even out variability, the sensor can be queried sampleSize times and an average obtained. More...
 
int rGetLightTxt (const char *sensorName, int sampleSize)
 Get the average values of a specified light sensor. Values of each light sensor can somewhat (typically under 5%-10%). To even out variability, the sensor can be queried sampleSize times and an average obtained. More...
 
void rGetIRAll (int irSensors[2], int sampleSize)
 Get an array of true/false values regarding the presence of obstacle based on the average values of each of the three IR sensors. Since readings of each light sensor can vary substantially, each sensor can be queried sampleSize times and an average obtained. More...
 
int rGetIRTxt (const char *sensorName, int sampleSize)
 Use specified IR sensor to determine if obstacle is present. Since values of each light sensor can vary substantially, the sensor can be queried sampleSize times and an average obtained. More...
 
void rGetLine (int lineSensors[2], int sampleSize)
 Use Scribbler 2 line sensors of Scribbler to check for a black line on a white surface under the robot. Since values of each light sensor can vary substantially, the sensor can be queried sampleSize times and an average obtained. More...
 
void rSetIRPower (int power)
 Set the amount of power for the dongle's IR sensors. More...
 
void rGetObstacleAll (int obstSensors[3], int sampleSize)
 Get the average values of the three obstacle sensors in an array. Since readings of each obstacle sensor can vary substantially (successive readings may differ by several hundred or more), each sensor can be queried sampleSize times and an average obtained. More...
 
int rGetObstacleTxt (const char *sensorName, int sampleSize)
 Get the average values of a specified obstacle (IR) sensor. Since values of each obstacle sensor can vary substantially (successive readings may differ by several hundred or more), the sensor can be queried sampleSize times and an average obtained. More...
 
void rGetBrightAll (int brightSensors[3], int sampleSize)
 Read the Fluke's virtual light sensors. Since readings of each brightness sensor can vary substantially (successive readings may differ by 5000-10000), each sensor can be queried sampleSize times and an average obtained. More...
 
int rGetBrightTxt (char *sensorName, int sampleSize)
 Reads one of the Fluke's virtual light sensors. Each sensor reports a total intensity in the left, middle, or right of the Fluke's camera Since values of each obstacle sensor can vary substantially (successive readings may differ by 5000-10000), the sensor can be queried sampleSize times and an average obtained. More...
 
void rGetInfo (char *infoBuffer)
 returns information about the robot's dongle, firmware, and communication mode as a 60 character array in infoBuffer. More...
 
void rTurnLeft (double speed, double time)
 turn Scribbler left for a specified time and speed More...
 
void rTurnRight (double speed, double time)
 turn Scribbler right for a specified time and speed More...
 
void rTurnSpeed (char *direction, double speed, double time)
 turn Scribbler in direction for a specified time and speed More...
 
void rForward (double speed, double time)
 moves Scribbler forward for a specified time and speed More...
 
void rFastForward (double time)
 moves Scribbler forward at the largest possible speed for a specified time More...
 
void rBackward (double speed, double time)
 moves Scribbler backward for a specified time and speed More...
 
void rMotors (double leftSpeed, double rightSpeed)
 move robot with given speeds for the left and right motors continues until given another motion command or disconnected (non-blocking) More...
 
void rStop ()
 directs robot to stop movement
 
void rHardStop ()
 cuts power to the motor of the robot
 
Picture rTakePicture ()
 Use the camera to take a photo. More...
 
void rSavePicture (Picture *pic, char *filename)
 Save a Picture to a .jpeg. More...
 
Picture rLoadPicture (char *filename)
 Load a picture from a .jpeg file. More...
 
void rDisplayPicture (Picture *pic, double duration, const char *windowTitle)
 Display a picture in a new window. More...
 
void rDisplayImageProcessingErrors ()
 Turn on and off the printing of error messasge for image processing. More...
 
void rWaitTimedImageDisplay ()
 Wait until all timed, non-blocking image window timers are complete. More...
 

Detailed Description

Header for a C-based, my-robot package for the Scribbler 2.

Revision History

Version 1.0 based on a C++ package by April O'Neill, David Cowden, Dilan Ustek, Erik Opavsky, and Henry M. Walker

Developers of the C package for Linux: Creators Version 2.0 (C functions for utilities,general,sensors,movement): Spencer Liberto Dilan Ustek Jordan Yuan Henry M. Walker Contributors Version 2.2-2.3: (C functions for image processing) Anita DeWitt Jason Liu Nick Knoebber Vasilisa Bashlovkina Revision for Version 2.4: (image row/column made to match matrix notation) Henry M. Walker

Revisions for Version 3.0 Henry M. Walker

C ported to Macintosh Linux/Mac differences required for connections — otherwise same code OpenGL used to display images, replacing ImageMagick same [new] code used for both Linux and Macintosh 1 process for robot control 1 process needed for each titled window (not each image, as in 2.2-2.4) Blocking options (negative duration parameter) utilize separate thread timer MyroC implementation files organized by user function as follows:

Revisions for Version 3.1 Henry M. Walker

Picture struct and image functions revised to allow 192 by 256 images from origial Fluke camera 266 x 427 low-resolution images from Fluke 2 (high-resolution (800 x 1280) too large for more than 2-4 variables on run-time stack) storage, retrieval, and display of any images up to 266 x 427

Revisions for Version 3.2 Henry M. Walker

Practical range of rBeep duration identified as <= 3.0014 seconds Image display and processing resolves several matters and adds functionality function rDisplayPicture completely rewritten over time OpenGL rountines had encountered troubles on Linux, specifically glutHideWindow() hid images, but could not be restored, with difficulties depending on the graphics card on Mac, High Sierra generated compile warnings and restricted threads that could display images function rDisplayImageProcessingErrors added function rWaitTimedImageDisplay updated substantially

This program and all MyroC software is licensed under the Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License. Details may be found at http://creativecommons.org/licenses/by-nc-sa/3.0/us/

Function Documentation

◆ rBackward()

void rBackward ( double  speed,
double  time 
)

moves Scribbler backward for a specified time and speed

Parameters
speedthe rate at which the robot should move backward
linear range: -1.0 specifies move forward at full speed
0.0 specifies no forward/backward movement
1.0 specifies move backward at full speed
timespecifies the duration of the turn
if negative: the robot starts backward (non-blocking) other processing proceeds, and the robot continues backward until given another motion command or disconnected (non-blocking)
if zero: robot starts moving backward (non-blocking) other processing proceeds
if positive: robot moves backward for the given duration, in seconds

◆ rBeep()

void rBeep ( double  duration,
int  frequency 
)

Beeps with the given duration and frequency.

Parameters
durationlength of note in seconds
frequencyfrequency of pitch in cycles per second (hertz)
Precondition
0.0 < duration > 0.0 <= 3.0 seconds (Scribbler 2 hangs if duration > 3.0014 seconds; although reason unknown, experimentation suggests part of Sribbler 2 firmware)

◆ rBeep2()

void rBeep2 ( double  duration,
int  freq1,
int  freq2 
)

Generates two notes for the prescribed duration.

Parameters
durationlength of note in seconds
freq1frequency of first pitch in cycles per second (hertz)
freq2frequency of second pitch in cycles per second (hertz)
Precondition
0.0 < duration <= 3.0 seconds (Scribbler 2 hangs if duration > 3.0014 seconds; although reason unknown, experimentation suggests part of Sribbler 2 firmware)

◆ rConnect()

int rConnect ( const char *  address)

connects program to Scribbler

Parameters
addressstring, giving name of workstation port or a Scribbler Bluetooth designation

several string formats are possible
Linux and Mac:
a communications port, such as "/dev/rfcomm0"
a Scribbler 2 fluke serial number, such as "245787"
a full IPRE serial number, such as "IPRE245787"
a Fluke 2 serial number (hexadecimal), such as "021F"
a full Fluke 2 serial number, such as "Fluke2-021F"
Linux only:
a MAC address, such as "00:1E:19:01:0E:13"
Mac only:
any substring of a complete device file name,
as long as the resulting device is unique
some possibilities include
a complete device file name, such as

  • "/dev/tty.IPRE6-365877-DevB"
  • "/dev/tty.Fluke2-0958-Fluke2"
    a fluke or fluke2 serial number
    full path of symbolic link to a device filename string or substring in /dev

uniqueness is ensured by requiring 4 hex digits
or 6 decimal digits

Returns
the socket number of communications port
Postcondition
subsequent communications will take place through this socket, unless changed by rSetConnection

◆ rDisconnect()

void rDisconnect ( )

stop Scribbler motion and close Bluetooth

Postcondition
motion for the current robot is stopped, blocking until any non-blocking motion time has expired
i.e., if a motion timer is set,
this procedure blocks
when the timer completes,
then the motion stops
else, procedure stops motion immediately
Bluetooth for the current robot is closed

◆ rDisplayImageProcessingErrors()

void rDisplayImageProcessingErrors ( )

Turn on and off the printing of error messasge for image processing.

Note
Some operating systems (e.g., Mac OX S High Sierra) display an error message whenevern a new process for image display starts
Postcondition
This function toggles this printing on and off Initially, printing is off

◆ rDisplayPicture()

void rDisplayPicture ( Picture pic,
double  duration,
const char *  windowTitle 
)

Display a picture in a new window.

Parameters
picpointer to an RGB picture struct from Scribbler 2 camera
durationif duration > 0, operation is blocking
if duration <= 0, operation is non-blocking
for duration != 0, picture displayed for abs(duration)
seconds or until picture closed manually or until the program terminates
if duration == 0, picture displayed until closed manually
windowTitleThe title of the window that appears. white spaces will be replaced with underscores.
Precondition
windowTitle is less than 100 characters.
Postcondition
image is displayed for the duration specified,
EXCEPT all display windows are closed when the main program terminates.
Warning
If images are displayed with a non-blocking option, and if the user wants images to appear for a full duration, use rWaitTimedImageDisplay or rFinishProcessing to block processing until all image timers are finished. Otherwise, program termination may close windows prematurely.

◆ rFastForward()

void rFastForward ( double  time)

moves Scribbler forward at the largest possible speed for a specified time

Parameters
timespecifies the duration of the turn
if negative: the robot starts forward (non-blocking) other processing proceeds, and the robot continues forward until given another motion command or disconnected (non-blocking)
if zero: robot starts moving forward (non-blocking); other processing proceeds
if positive: robot moves forward for the given duration, in seconds
Warning
may take longer than usual to execute

◆ rFinishProcessing()

void rFinishProcessing ( )

all timed motions/image displays completed, all robots stopped, and all robot Bluetooth connections closed

same result as rDisconnect for all robots plus rComleteImageDisplay

Postcondition
blocks until all timed robot motions are complete, and all timed image displays no longer visible
upon completion, all timed images are invisible, all robot motion is halted, and all robot Bluetooth connections closed

◆ rForward()

void rForward ( double  speed,
double  time 
)

moves Scribbler forward for a specified time and speed

Parameters
speedthe rate at which the robot should move forward
linear range: -1.0 specifies move backward at full speed
0.0 specifies no forward/backward movement
1.0 specifies move forward at full speed
timespecifies the duration of the turn
if negative: the robot starts forward (non-blocking) other processing proceeds, and the robot continues forward until given another motion command or disconnected (non-blocking)
if zero: robot starts moving forward (non-blocking); other processing proceeds
if positive: robot moves forward for the given duration, in seconds

◆ rGetBattery()

double rGetBattery ( )

Get the current voltage from the Scribbler batteries; Maximum charge from 6 batteries could be up to 6 volts; Manufacturer suggests batteries should be changed below 4.1 volts.

Returns
percentage of battery voltage

◆ rGetBrightAll()

void rGetBrightAll ( int  brightSensors[3],
int  sampleSize 
)

Read the Fluke's virtual light sensors. Since readings of each brightness sensor can vary substantially (successive readings may differ by 5000-10000), each sensor can be queried sampleSize times and an average obtained.

Parameters
brightSensorsarray to store intensity values
sampleSizehow many readings are taken for each sensor
Precondition
space already allocated for brightSensors array sampleSize > 0
Postcondition
brightSensors[0] gives average value for left sensor
brightSensors[1] gives average value for middle sensor
brightSensors[2] gives average value for right sensor
Brightness values near 0 represent bright light
Brightness values may extend to about 65535 for a dark region.

◆ rGetBrightTxt()

int rGetBrightTxt ( char *  sensorName,
int  sampleSize 
)

Reads one of the Fluke's virtual light sensors. Each sensor reports a total intensity in the left, middle, or right of the Fluke's camera Since values of each obstacle sensor can vary substantially (successive readings may differ by 5000-10000), the sensor can be queried sampleSize times and an average obtained.

Parameters
sensorNamename of the bright sensor
Precondition
sensorName is "left", "center", "middle", or "right" (not case sensitive)
designations "center" and "middle" are alternatives for the same bright sensor
Parameters
sampleSizehow many readings are taken for the sensor
Precondition
sampleSize > 0
Returns
reading from the specified bright sensor, averaged over sampleSize number of data samples
Brightness values near 0 represent bright light
Brightness values may extend to about 65535 for a very dark region.

◆ rGetForwardness()

char* rGetForwardness ( )

Gets the forwardness of the Scribbler.

Returns
either "fluke-forward" or "scribbler-forward"

◆ rGetInfo()

void rGetInfo ( char *  infoBuffer)

returns information about the robot's dongle, firmware, and communication mode as a 60 character array in infoBuffer.

Parameters
infoBuffera pre-defined, 60-character array
Postcondition
infoBuffer contains relevant robot information

◆ rGetIRAll()

void rGetIRAll ( int  irSensors[2],
int  sampleSize 
)

Get an array of true/false values regarding the presence of obstacle based on the average values of each of the three IR sensors. Since readings of each light sensor can vary substantially, each sensor can be queried sampleSize times and an average obtained.

Parameters
irSensorsarray to store intensity values
sampleSizehow many readings are taken for each sensor
Precondition
space already allocated for irSensors array sampleSize > 0
Postcondition
irSensors[0] checks obstacle for left sensor
irSensors[1] checks obstacle for right sensor
for each irSensors array value
return 0 indicates no obstacle detected
return 1 indicates obstacle detected

◆ rGetIRTxt()

int rGetIRTxt ( const char *  sensorName,
int  sampleSize 
)

Use specified IR sensor to determine if obstacle is present. Since values of each light sensor can vary substantially, the sensor can be queried sampleSize times and an average obtained.

Parameters
sensorNamename of the light sensor
Precondition
sensorName is "left" or "right" (not case sensitive)
Parameters
sampleSizehow many readings are taken for the sensor
Precondition
sampleSize > 0
Returns
true/false (0/1) determination of obstacle, based on IR sensorName sensor, averaged over sampleSize number of data samples
Postcondition
return 0 indicates no obstacle detected
return 1 indicates obstacle detected

◆ rGetLightsAll()

void rGetLightsAll ( int  lightSensors[3],
int  sampleSize 
)

Get the average values of each of the three light sensors in an array. Values of each light sensor can somewhat (typically under 5%-10%). To even out variability, the sensor can be queried sampleSize times and an average obtained.

Parameters
lightSensorsarray to store intensity values
sampleSizehow many readings are taken for each sensor
Precondition
space already allocated for lightSensors array sampleSize > 0
Postcondition
lightSensors[0] gives average value for left sensor
lightSensors[1] gives average value for middle sensor
lightSensors[2] gives average value for right sensor
Intensity values near 0 represent bright light
Intensities may extend to about 65000 for a dark region.

◆ rGetLightTxt()

int rGetLightTxt ( const char *  sensorName,
int  sampleSize 
)

Get the average values of a specified light sensor. Values of each light sensor can somewhat (typically under 5%-10%). To even out variability, the sensor can be queried sampleSize times and an average obtained.

Parameters
sensorNamename of the light sensor
Precondition
sensorName is "left", "center", "middle", or "right" (not case sensitive)
designations "center" and "middle" are alternatives for the same light sensor
Parameters
sampleSizehow many readings are taken for the sensor
Precondition
sampleSize > 0
Returns
reading from the specified light sensor, averaged over sampleSize number of data samples
if sensorName invalid, returns -1.0

◆ rGetLine()

void rGetLine ( int  lineSensors[2],
int  sampleSize 
)

Use Scribbler 2 line sensors of Scribbler to check for a black line on a white surface under the robot. Since values of each light sensor can vary substantially, the sensor can be queried sampleSize times and an average obtained.

Warning
results of these sensors may be flakey!
Parameters
lineSensorsarray to store line values detected
sampleSizehow many readings are taken for each sensor
Precondition
space already allocated for lineSensors array sampleSize > 0
Postcondition
lineSensors[0] checks left sensor for line
lineSensors[1] checks right sensor for line
for each irSensors array value
return 0 indicates line is identified
return 1 indicates line is not identified

◆ rGetName()

const char* rGetName ( )

Get the name of the robot.

Returns
information about the name of the robot
Postcondition
the returned name is a newly-allocated 17-byte string

◆ rGetObstacleAll()

void rGetObstacleAll ( int  obstSensors[3],
int  sampleSize 
)

Get the average values of the three obstacle sensors in an array. Since readings of each obstacle sensor can vary substantially (successive readings may differ by several hundred or more), each sensor can be queried sampleSize times and an average obtained.

Parameters
obstSensorsarray to store intensity values
sampleSizehow many readings are taken for each sensor
Precondition
space already allocated for obstSensors array; sampleSize > 0
Postcondition
obstSensors[0] gives average value for left sensor
obstSensors[1] gives average value for middle sensor
obstSensors[2] gives average value for right sensor
Returned values are between 0 and 6400
Obstacle values near 0 represent no obstacle seen
Obstacle values may approach 6400 as obstacle gets close.
Warning
As battery degrades, sensor readings degrade, yielding systematically lower numbers.

◆ rGetObstacleTxt()

int rGetObstacleTxt ( const char *  sensorName,
int  sampleSize 
)

Get the average values of a specified obstacle (IR) sensor. Since values of each obstacle sensor can vary substantially (successive readings may differ by several hundred or more), the sensor can be queried sampleSize times and an average obtained.

Parameters
sensorNamename of the obstacle sensor
Precondition
sensorName is "left", "center", "middle", or "right" (not case sensitive)
designations "center" and "middle" are alternatives for the same light sensor
Parameters
sampleSizehow many readings are taken for the sensor
Precondition
space already allocated for vals array; sampleSize > 0
Returns
reading from the specified obstacle sensor, averaged over sampleSize number of data samples
Returned values are between 0 and 6400
Obstacle values near 0 represent no obstacle seen
Obstacle values may approach 6400 as obstacle gets close.
Warning
As battery degrades, sensor values degrade, yielding systematically lower numbers.

◆ rGetStall()

int rGetStall ( int  sampleSize)

Determine if robot has stalled

MyroC Reference Manual (http://wiki.roboteducation.org/Myro_Reference_Manual) states "Every time you issue a move command, the stall sensor resets, and it needs to wait a short time to see whether the motors are stalled. This means that the sensor won't give accurate results if you test it too soon after the robot starts to move."

In practice, it may take 0.5-1.0 seconds for rGetStall to sense the robot is stalled

Parameters
sampleSizehow many readings are taken for each sensor
Precondition
sampleSize > 0
Returns
whether or not robot current has stalled
Postcondition
Returns 1 if the robot has stalled
Returns 0 otherwise.

◆ rLoadPicture()

Picture rLoadPicture ( char *  filename)

Load a picture from a .jpeg file.

Parameters
filenamethe name of the file
Precondition
file must exist
file must be a 256x192 .jpeg or .jpg
Returns
Picture

◆ rMotors()

void rMotors ( double  leftSpeed,
double  rightSpeed 
)

move robot with given speeds for the left and right motors continues until given another motion command or disconnected (non-blocking)

Parameters
leftSpeedthe rate at which the left wheel should turn
linear range: -1.0 specifies move backward at full speed
0.0 specifies no forward/backward movement
1.0 specifies move forwardward at full speed
rightSpeedthe rate at which the right wheel should turn
linear range: -1.0 specifies move backward at full speed
0.0 specifies no forward/backward movement
1.0 specifies move forward at full speed

◆ rSavePicture()

void rSavePicture ( Picture pic,
char *  filename 
)

Save a Picture to a .jpeg.

Parameters
picpointer to an RGB picture struct from Scribbler 2 camera
filenamethe name of the file
Precondition
filename ends with .jpeg or .jpg.
Postcondition
If the file does not exist, a new file will be created.
If the file exists, the file will be overwritten.

◆ rSetBluetoothEcho()

void rSetBluetoothEcho ( char  onOff)

Turn on and off echoing of Bluetooth transmissions All robot commands involve the transmission of a command over Bluetooth Scribbler commands are always 9 bytes
Fluke commands have varying lengths
The fluke echos most, but not all, of the commands
For many commands, the fluke also echos 11 bytes of sensor data.

Parameters
onOffchar 'y' enables echoing
char 'n' disables echoing
other character values ignored

◆ rSetConnection()

void rSetConnection ( int  new_socket_num)

set current connection to the socket number

Parameters
new_socket_numthe number of an open socket for communication
Precondition
new_socket_num has been returned by rConnect the designated socket has not been closed

◆ rSetForwardness()

void rSetForwardness ( char *  direction)

specifies which end of the Scribbler is considered the front

Parameters
directionidentifies front direction
Precondition
direction is either "fluke-forward" or "scribbler-forward" (not case sensitive)

◆ rSetIRPower()

void rSetIRPower ( int  power)

Set the amount of power for the dongle's IR sensors.

Parameters
powerthe desired power level for the IR sensors
Precondition
power is between 0 and 255 (inclusive)
Manufacturer notes: default value is 135
if IR obstacle sensor is always high, try lowering IR power
if IR obstacle sensor is always low, try raising IR power

◆ rSetLEDBack()

void rSetLEDBack ( double  led)

Set the the intensity of the back fluke LED.

Parameters
ledintensity of the LED
values between 0 and 1 provide a range of brightness from off to full intensity
values bigger than 1 are treated as 1 (full brightness)
values less than 0 are treated as 0 (LED off)

◆ rSetLEDFront()

void rSetLEDFront ( int  led)

Set the front [fluke] LED on or off.

Parameters
ledvalue 1 turns on LED value 0 turns off LED
Precondition
led must be 0 or 1

◆ rSetName()

void rSetName ( const char *  name)

Change name stored in the robot to the 16-byte name given.

Parameters
namespecifies new name of robot
if < 16 bytes given, name is filled with null characters
if >= 16 bytes given, name is truncated to 15 bytes plus null

◆ rSetVolume()

void rSetVolume ( char  highMute)

Set sound to high volume (H) or mute (M) highMute set volume of Scribbler.

Precondition
highMute is 'H' to set for high volume or 'M' for mute

◆ rTakePicture()

Picture rTakePicture ( )

Use the camera to take a photo.

This section contains functions for taking and manipulating images All images are constrained with height <= 266 and width <= 427

images from robot cameras have varying sizes, depending on the Fluke images for the original Fluke are 192 (height) by 256 (width) low-resolution images for the Fluke 2 are 266 by 427 high-resolution images for the fluke 2 are 800 by 1280

Bluetooth communication constrains the time required for the Fluke to take a picture Typical times: original fluke: 2- 4 seconds Fluke 2 (low res): 4- 6 seconds Fluke 2 (high res): 25-30 seconds

BASED ON TIMINGS AND MEMORY CONSIDERATIONS, Myro C ALLOWS ONLY LOW RESOLUTION IMAGES

the Picture struct allows direct access to Pixel data Pictures can be saved and loaded as .jpeg files

Note
Following standard mathematical convention for a 2D matrix, all references to a pixel are given within an array as [row][col]
user-defined images may have any size, as long as height <= 266 and width <= 427
Following standard mathematical convention for a 2D matrix, all references to a pixel are given within an array as [row][col]
Warning
The Picture struct is defined to be sufficiently large to store several low-resolution camera images (340756 bytes each) Experimentally, an array of up to 94 (not 95) Pictures is allowed However, the display of images requires that image data be copied, so display of many images may not work If a program hangs when working with Picture variables, the issue may involve lack of space on the runtime stack. To utilize a modest number of Pictures, use "ulimit -s" command, as needed, in a terminal window For example, ulimit -s 32768 Sizes above 32768 may not be allowed in Linux or Mac OS X
Returns
Picture

◆ rTurnLeft()

void rTurnLeft ( double  speed,
double  time 
)

turn Scribbler left for a specified time and speed

Parameters
speedthe rate at which the robot should move left linear range: -1.0 specifies right turn at full speed
0.0 specifies no turn
1.0 specifies left turn at full speed
timespecifies the duration of the turn
if negative: the robot starts to turn (non-blocking) other processing proceeds, and the robot continues to turn until given another motion command or disconnected (non-blocking)
if zero: robot starts turning (non-blocking); other processing proceeds
if positive: robot turns for the given duration, in seconds

◆ rTurnRight()

void rTurnRight ( double  speed,
double  time 
)

turn Scribbler right for a specified time and speed

Parameters
speedthe rate at which the robot should move right
linear range: -1.0 specifies left turn at full speed
0.0 specifies no turn
1.0 specifies right turn at full speed
timespecifies the duration of the turn
if negative: the robot starts to turn (non-blocking) other processing proceeds, and the robot continues to turn until given another motion command or disconnected (non-blocking)
if zero: robot starts turning (non-blocking); other processing proceeds
if positive: robot turns for the given duration, in seconds
if nonnegative: robot turns for the given duration, in seconds

◆ rTurnSpeed()

void rTurnSpeed ( char *  direction,
double  speed,
double  time 
)

turn Scribbler in direction for a specified time and speed

Parameters
directiondirection of turn, based on looking from the center of the robot and facing forward
speedthe rate at which the robot should move forward
linear range: -1.0 specifies turn at full speed
0.0 specifies no turn
1.0 specifies turn at full speed
timespecifies the duration of the turn
if negative: the robot starts to turn (non-blocking) other processing proceeds, and the robot continues to turn until given another motion command or disconnected (non-blocking)
if zero: robot starts turning (non-blocking); other processing proceeds
if positive: robot turns for the given duration, in seconds
Precondition
direction is "left" or "right", case insensitive

◆ rWaitTimedImageDisplay()

void rWaitTimedImageDisplay ( )

Wait until all timed, non-blocking image window timers are complete.

Postcondition
wait until all timed [non-blocking] images have closed
robot motion is unaffected by this function
Warning
images opened with duration 0.0 do not close until images are updated or until the program terminates
all other [timed, non-blocking] image windows are closed by this function