MyroC
2.1
a C-based package to control Scribbler 2 robots
|
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 | |
void | rDisconnect () |
disconnect program from Scribbler | |
void | rSetConnection (int socket_num) |
set current connection to the socket number | |
void | rBeep (double duration, int frequency) |
Beeps with the given duration and frequency. | |
void | rBeep2 (double duration, int freq1, int freq2) |
Generates two notes for the prescribed duration. | |
void | rSetName (const char *name) |
Change name stored in the robot to the 16-byte name given. | |
const char * | rGetName () |
Get the name of the robot. | |
void | rSetForwardness (char *direction) |
specifies which end of the Scribbler is considered the front | |
void | rSetForwardnessTxt (char *direction) |
alternative to rSetForwardness for compatibility with earlier MyroC | |
char * | rGetForwardness () |
Gets the forwardness of the Scribbler. | |
void | rSetLEDFront (int led) |
Set the front [fluke] LED on or off. | |
void | rSetLEDBack (double led) |
Set the the intensity of the back fluke LED,. | |
double | rGetBattery () |
Get the percentage of volts left in the batteries of the scribbler. | |
int | rGetStall (int sampleSize) |
Determine if robot has stalled Since readings of each brightness sensor can vary substantially, each sensor can be queried sampleSize times and an average obtained. | |
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. | |
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. | |
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. | |
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. | |
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. | |
void | rSetIRPower (int power) |
Set the amount of power for the dongle's IR sensors. | |
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. | |
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. | |
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. | |
int | rGetBrightTxt (char *sensorName, int sampleSize) |
Reads one of the Fluke's virtual light sensors. 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. | |
void | rGetInfo (char *infoBuffer) |
returns information about the robot's dongle, firmware, and communication mode as a 60 character array in infoBuffer. | |
void | rTurnLeft (double speed, double time) |
turn Scribbler left for a specified time and speed | |
void | rTurnRight (double speed, double time) |
turn Scribbler right for a specified time and speed | |
void | rTurnSpeed (char *direction, double speed, double time) |
turn Scribbler in direction for a specified time and speed | |
void | rForward (double speed, double time) |
moves Scribbler forward for a specified time and speed | |
void | rFastForward (double time) |
moves Scribbler forward at the largest possible speed for a specified time | |
void | rBackward (double speed, double time) |
moves Scribbler backward for a specified time and speed | |
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) | |
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. | |
void | rSavePicture (Picture pic, char *filename) |
Save a Picture to a .jpeg. | |
Picture | rLoadPicture (char *filename) |
Load a picture from a .jpeg file. | |
void | rDisplayPicture (Picture pic, double duration, const char *windowTitle) |
Display a picture in a new window. |
Header for a C-based, my-robot package for the Scribbler 2.
Based on a C++ package by April O'Neill, David Cowden, Dilan Ustek, Erik Opavsky, and Henry M. Walker
void rBackward | ( | double | speed, |
double | time | ||
) |
moves Scribbler backward for a specified time and speed
speed | the 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 |
time | specifies the duration of the turn if negative: robot continues to go backward until given another motion command or disconnected (non-blocking) if nonnegative: robot moves backward for the given duration, in seconds |
moves Scribbler backward for a specified time and speed
speed | the 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 |
time | specifies the duration of the turn if negative: robot continues to go backward until given another motion command or disconnected (non-blocking) if nonnegative: robot moves backward for the given duration, in seconds |
void rBeep | ( | double | duration, |
int | frequency | ||
) |
Beeps with the given duration and frequency.
duration | length of note in seconds |
frequency | frequency of pitch in cycles per second (hertz) |
Beeps with the given duration and frequency
duration | length of note in seconds |
frequency | frequency of pitch in cycles per second (hertz) |
void rBeep2 | ( | double | duration, |
int | freq1, | ||
int | freq2 | ||
) |
Generates two notes for the prescribed duration.
duration | length of note in seconds |
freq1 | frequency of first pitch in cycles per second (hertz) |
freq2 | frequency of second pitch in cycles per second (hertz) |
Generates two notes for the prescribed duration
duration | length of note in seconds |
freq1 | frequency of first pitch in cycles per second (hertz) |
freq2 | frequency of second pitch in cycles per second (hertz) |
int rConnect | ( | const char * | address | ) |
connects program to Scribbler
address | string, giving name of workstation port or a Scribbler Bluetooth designation |
several string formats are possible a communications port, such as "/dev/rfcomm0" a MAC address, such as "00:1E:19:01:0E:13" 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"
connects program to Scribbler
address | string, giving name of workstation port or a Scribbler Bluetooth designation |
several string formats are possible a communications port, such as "/dev/rfcomm0" a MAC address, such as "00:1E:19:01:0E:13" 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"
void rDisplayPicture | ( | Picture | pic, |
double | duration, | ||
const char * | windowTitle | ||
) |
Display a picture in a new window.
pic | RGB picture struct from Scribbler 2 camera |
duration | if 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 if duration == 0, picture displayed until closed manually |
windowTitle | The title of the window that appears. white spaces will be replaced with underscores. |
Display a picture in a new window
pic | RGB picture struct from Scribbler 2 camera |
duration | if 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 if duration == 0, picture displayed until closed manually |
windowTitle | The title of the window that appears. white spaces will be replaced with underscores. |
void rFastForward | ( | double | time | ) |
moves Scribbler forward at the largest possible speed for a specified time
time | specifies the duration of movement if negative: robot continues to move forward until given another motion command or disconnected (non-blocking) if nonnegative: robot moves forward for the given duration, in seconds |
moves Scribbler forward at the largest possible speed for a specified time
time | specifies the duration of movement if negative: robot continues to move forward until given another motion command or disconnected (non-blocking) if nonnegative: robot moves forward for the given duration, in seconds may take longer than usual to execute |
void rForward | ( | double | speed, |
double | time | ||
) |
moves Scribbler forward for a specified time and speed
speed | the 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 |
time | specifies the duration of movement if negative: robot continues to move forward until given another motion command or disconnected (non-blocking) if nonnegative: robot moves forward for the given duration, in seconds |
moves Scribbler forward for a specified time and speed
speed | the 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 |
time | specifies the duration of movement if negative: robot continues to move forward until given another motion command or disconnected (non-blocking) if nonnegative: robot moves forward for the given duration, in seconds |
double rGetBattery | ( | ) |
Get the percentage of volts left in the batteries of the scribbler.
Get the percentage of volts left in the batteries of the scribbler
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.
brightSensors | array to store intensity values |
sampleSize | how many readings are taken for each sensor |
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.
brightSensors | array to store intensity values |
sampleSize | how many readings are taken for each sensor |
int rGetBrightTxt | ( | char * | sensorName, |
int | sampleSize | ||
) |
Reads one of the Fluke's virtual light sensors. 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.
sensorName | name of the obstacle sensor |
sampleSize | how many readings are taken for the sensor |
Reads one of the Fluke's virtual light sensors. 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.
sensorName | name of the obstacle sensor |
sampleSize | how many readings are taken for the sensor |
char* rGetForwardness | ( | ) |
Gets the forwardness of the Scribbler.
Gets the forwardness of the Scribbler
void rGetInfo | ( | char * | infoBuffer | ) |
returns information about the robot's dongle, firmware, and communication mode as a 60 character array in infoBuffer.
infoBuffer | a pre-defined, 60-character array |
returns information about the robot's dongle, firmware, and communication mode as a 60 character array in infoBuffer.
infoBuffer | a pre-defined, 60-character array |
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.
irSensors | array to store intensity values |
sampleSize | how many readings are taken for each sensor |
Get an array of true/false values regarding the presence of an 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.
irSensors | array to store intensity values |
sampleSize | how many readings are taken for each sensor |
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.
sensorName | name of the light sensor |
sampleSize | how many readings are taken for the sensor |
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.
sensorName | name of the light sensor |
sampleSize | how many readings are taken for the sensor |
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.
lightSensors | array to store intensity values |
sampleSize | how many readings are taken for each sensor |
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.
obstSensors | array to store intensity values |
sampleSize | how many readings are taken for each sensor |
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.
sensorName | name of the light sensor |
sampleSize | how many readings are taken for the sensor |
Get the average values of a specified light sensor. Values of each light sensor can vary somewhat (typically under 5%-10%). To even out variability, the sensor can be queried sampleSize times and an average obtained.
sensorName | name of the light sensor |
sampleSize | how many readings are taken for the sensor |
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.
lineSensors | array to store line values detected |
sampleSize | how many readings are taken for each sensor |
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. results of these sensors may be flakey!
lineSensors | array to store line values detected |
sampleSize | how many readings are taken for each sensor |
const char* rGetName | ( | ) |
Get the name of the robot.
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.
obstSensors | array to store intensity values |
sampleSize | how many readings are taken for each sensor |
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.
obstSensors | array to store intensity values |
sampleSize | how many readings are taken for each sensor |
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.
sensorName | name of the obstacle sensor |
sampleSize | how many readings are taken for the sensor |
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.
sensorName | name of the obstacle sensor |
sampleSize | how many readings are taken for the sensor |
int rGetStall | ( | int | sampleSize | ) |
Determine if robot has stalled Since readings of each brightness sensor can vary substantially, each sensor can be queried sampleSize times and an average obtained.
sampleSize | how many readings are taken for each sensor |
Determine if robot has stalled Since readings of each brightness sensor can vary substantially, each sensor can be queried sampleSize times and an average obtained.
sampleSize | how many readings are taken for each sensor |
Picture rLoadPicture | ( | char * | filename | ) |
Load a picture from a .jpeg file.
filename | the name of the file |
Load a picture from a .jpeg file.
filename | the name of the file |
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)
leftSpeed | the 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 |
rightSpeed | the 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 |
move robot with given speeds for the left and right motors continues until given another motion command or disconnected (non-blocking)
left | the 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 |
right | the 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 |
void rSavePicture | ( | Picture | pic, |
char * | filename | ||
) |
Save a Picture to a .jpeg.
pic | RGB picture struct from Scribbler 2 camera |
filename | the name of the file |
Save a Picture to a .jpeg
pic | RGB picture struct from Scribbler 2 camera |
filename | the name of the file |
void rSetConnection | ( | int | new_socket_num | ) |
set current connection to the socket number
socket_num | the number of an open socket for communication |
set current connection to the socket number
socket_num | the number of an open socket for communication |
void rSetForwardness | ( | char * | direction | ) |
specifies which end of the Scribbler is considered the front
direction | identifies front direction |
specifies which end of the Scribbler is considered the front
direction | identifies front direction |
void rSetIRPower | ( | int | power | ) |
Set the amount of power for the dongle's IR sensors.
power | the desired power level for the IR sensors |
Set the amount of power for the dongle's IR sensors
power | the desired power level for the IR sensors |
void rSetLEDBack | ( | double | led | ) |
Set the the intensity of the back fluke LED,.
led | intensity 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). |
Set the the intensity of the back fluke LED,
led | intensity 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). |
void rSetLEDFront | ( | int | led | ) |
Set the front [fluke] LED on or off.
led | value 1 turns on LED value 0 turns off LED |
Set the front [fluke] LED on or off
led | value 1 turns on LED value 0 turns off LED |
void rSetName | ( | const char * | name | ) |
Change name stored in the robot to the 16-byte name given.
name | specifies 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 |
Change name stored in the robot to the 16-byte name given
name | specifies 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 |
Picture rTakePicture | ( | ) |
void rTurnLeft | ( | double | speed, |
double | time | ||
) |
turn Scribbler left for a specified time and speed
speed | the 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 |
time | specifies the duration of the turn if negative: robot continues to turn until given another motion command or disconnected (non-blocking) if nonnegative: robot turns for the given duration, in seconds |
turn Scribbler left for a specified time and speed
speed | the 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 |
time | specifies the duration of the turn if negative: robot continues to turn until given another motion command or disconnected (non-blocking) if nonnegative: robot turns for the given duration, in seconds |
void rTurnRight | ( | double | speed, |
double | time | ||
) |
turn Scribbler right for a specified time and speed
speed | the 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 |
time | specifies the duration of the turn if negative: robot continues to turn until given another motion command or disconnected (non-blocking) if nonnegative: robot turns for the given duration, in seconds |
turn Scribbler right for a specified time and speed
speed | the 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 |
time | specifies the duration of the turn if negative: robot continues to turn until given another motion command or disconnected (non-blocking) if nonnegative: robot turns for the given duration, in seconds |
void rTurnSpeed | ( | char * | direction, |
double | speed, | ||
double | time | ||
) |
turn Scribbler in direction for a specified time and speed
direction | direction of turn, based on looking from the center of the robot and facing forward |
speed | the 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 |
time | specifies the duration of the turn if negative: robot continues to turn until given another motion command or disconnected if nonnegative: robot turns for the given duration, in seconds |
turn Scribbler in direction for a specified time and speed
direction | direction of turn, based on looking from the center of the robot and facing forward |
speed | the 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 |
time | specifies the duration of the turn if negative: robot continues to turn until given another motion command or disconnected if nonnegative: robot turns for the given duration, in seconds |