MyroC  2.4
C-based Infrastructure for the control of Scribbler 2 robots
 All Classes Files Functions Variables
MyroC.h
Go to the documentation of this file.
1 
25  /*
26  Index of all functions
27 
28  1. GENERAL 2. SENSOR
29  rConnect a. Scribbler Sensors
30  rDisconnect rGetLightsAll
31  rSetConnection rGetLightTxt
32  rBeep rGetIRAll
33  rBeep2 rGetIRTxt
34  rSetName rGetLine
35  rGetName
36  rSetForwardness b. Fluke Sensors
37  rGetForwardness rSetIRPower
38  rSetLEDFront rGetObstacleAll
39  rSetLEDBack rGetObstacleTxt
40  rGetBattery rGetBrightAll
41  rGetStall rGetBrightTxt
42  rSetBluetoothEcho
43 
44 3. MOVEMENT 4. PICTURES
45  rTurnLeft rTakePicture
46  rTurnRight rSavePicture
47  rTurnSpeed rLoadPicture
48  rForward rDisplayPicture
49  rFastForward
50  rBackward
51  rMotors
52  rStop
53  rHardStop
54 */
55 
56 #ifndef _MyroC
57 #define _MyroC
58 
61 typedef struct
62 {
63  unsigned char R;
64  unsigned char G;
65  unsigned char B;
66 } Pixel;
67 
75 typedef struct
76 {
77  int height;
78  int width;
79  Pixel pix_array[192][256];
80 } Picture;
81 /* ***************************************************************/
82 /* 1. GENERAL - GENERAL - GENERAL - GENERAL - GENERAL - GENERAL */
83 /*****************************************************************/
84 
103 int rConnect (const char * address);
104 
108 void rDisconnect();
109 
116 void rSetConnection (int new_socket_num);
117 
124 void rBeep(double duration, int frequency);
125 
133 void rBeep2(double duration, int freq1, int freq2);
134 
141 void rSetName (const char * name);
142 
148 const char * rGetName();
149 
156 void rSetForwardness(char * direction);
157 
161 void rSetForwardnessTxt (char * direction);
162 
167 char * rGetForwardness ();
168 
175 void rSetLEDFront(int led);
176 
185 void rSetLEDBack(double led);
186 
191 double rGetBattery();
192 
203 int rGetStall (int sampleSize);
204 
216 void rSetBluetoothEcho (char onOff);
217 
218 
219 /**************************************************************************/
220 /* 2. SENSORS - SENSORS - SENSORS - SENSORS - SENSORS - SENSORS - SENSORS */
221 /**************************************************************************/
222 
223 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
224 /* Group a: Scribbler Sensors */
225 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
226 
243 void rGetLightsAll (int lightSensors[3], int sampleSize);
244 
245 
262 int rGetLightTxt (const char * sensorName, int sampleSize);
263 
280 void rGetIRAll (int irSensors[2], int sampleSize);
281 
282 
298 int rGetIRTxt (const char * sensorName, int sampleSize);
299 
316 void rGetLine (int lineSensors[2], int sampleSize);
317 
318 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
319 /* Group b: Fluke Sensors */
320 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
321 
327 void rSetIRPower (int power);
328 
346 void rGetObstacleAll (int obstSensors[3], int sampleSize);
347 
368 int rGetObstacleTxt (const char * sensorName, int sampleSize);
369 
385 void rGetBrightAll (int brightSensors[3], int sampleSize);
386 
404 int rGetBrightTxt (char * sensorName, int sampleSize);
405 
412 void rGetInfo (char * infoBuffer);
413 
414 
415 /***********************************************************************/
416 /* 3. MOVEMENT - MOVEMENT - MOVEMENT - MOVEMENT - MOVEMENT - MOVEMENT */
417 /***********************************************************************/
418 
419 /* In this section, "non-blocking" refers to commands that do not prevent
420  the robot from executing other non-movement commands at the same time.
421  For example, a call to rForward in the non-blocking mode with a
422  consecutive call to rBeep will result in the Scribbler moving forward
423  while beeping.
424 */
425 
426 
438 void rTurnLeft (double speed, double time);
439 
451 void rTurnRight (double speed, double time);
452 
468 void rTurnSpeed (char * direction, double speed, double time);
469 
483 void rForward (double speed, double time);
484 
494 void rFastForward (double time);
495 
509 void rBackward (double speed, double time);
510 
523 void rMotors (double leftSpeed, double rightSpeed);
524 
528 void rStop();
529 
533 void rHardStop();
534 
535 /***********************************************************************/
536 /* 4.) PICTURES PICTURES PICTURES PICTURES PICTURES PICTURES PICTURES */
537 /***********************************************************************/
538 /* In this section we deal with taking and manipulating pictures produced
539  from the Scribbler 2 camera. These pictures will always be 192x256
540  (192 rows by 256 columns) and internally are defined as type Picture,
541  which hold a 2D array of type of Pixel. These can be saved and loaded
542  as .jpeg files.
543 
544  Following standard mathematical convention for a 2D matrix,
545  all references to a pixel are given within an array as [row][col]
546  */
547 
553 
562 void rSavePicture(Picture pic, char * filename);
563 
571 Picture rLoadPicture(char * filename);
572 
573 
587 void rDisplayPicture(Picture pic, double duration, const char * windowTitle);
588 
589 
590 #endif
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 ca...
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 rTurnLeft(double speed, double time)
turn Scribbler left for a specified time and speed
unsigned char G
The value of the green component.
Definition: MyroC.h:64
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 robo...
void rSetBluetoothEcho(char onOff)
Turn on and off echoing of Bluetooth transmissions All robot commands involve the transmission of a c...
void rSetName(const char *name)
Change name stored in the robot to the 16-byte name given.
Struct for a picture object.
Definition: MyroC.h:75
void rSetForwardnessTxt(char *direction)
alternative to rSetForwardness for compatibility with earlier MyroC
unsigned char B
The value of the blue component.
Definition: MyroC.h:65
void rSavePicture(Picture pic, char *filename)
Save a Picture to a .jpeg.
void rMotors(double leftSpeed, double rightSpeed)
move robot with given speeds for the left and right motors continues until given another motion comma...
Picture rTakePicture()
Use the camera to take a photo.
void rGetInfo(char *infoBuffer)
returns information about the robot's dongle, firmware, and communication mode as a 60 character arra...
void rBeep(double duration, int frequency)
Beeps with the given duration and frequency.
Struct for a pixel.
Definition: MyroC.h:61
int rGetBrightTxt(char *sensorName, int sampleSize)
Reads one of the Fluke's virtual light sensors. Since values of each obstacle sensor can vary substan...
void rDisconnect()
disconnect program from Scribbler
int rGetLightTxt(const char *sensorName, int sampleSize)
Get the average values of a specified light sensor. Values of each light sensor can somewhat (typical...
void rHardStop()
cuts power to the motor of the robot
double rGetBattery()
Get the percentage of volts left in the batteries of the scribbler.
int height
Definition: MyroC.h:77
int width
Definition: MyroC.h:78
void rGetBrightAll(int brightSensors[3], int sampleSize)
Read the Fluke's virtual light sensors. Since readings of each brightness sensor can vary substantial...
int rGetObstacleTxt(const char *sensorName, int sampleSize)
Get the average values of a specified obstacle (IR) sensor. Since values of each obstacle sensor can ...
void rForward(double speed, double time)
moves Scribbler forward for a specified time and speed
void rStop()
directs robot to stop movement
void rSetForwardness(char *direction)
specifies which end of the Scribbler is considered the front
void rSetLEDFront(int led)
Set the front [fluke] LED on or off.
void rBeep2(double duration, int freq1, int freq2)
Generates two notes for the prescribed duration.
void rSetConnection(int new_socket_num)
set current connection to the socket number
void rGetObstacleAll(int obstSensors[3], int sampleSize)
Get the average values of the three obstacle sensors in an array. Since readings of each obstacle sen...
void rTurnSpeed(char *direction, double speed, double time)
turn Scribbler in direction for a specified time and speed
void rBackward(double speed, double time)
moves Scribbler backward for a specified time and speed
char * rGetForwardness()
Gets the forwardness of the Scribbler.
void rSetLEDBack(double led)
Set the the intensity of the back fluke LED,.
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 e...
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.
int rConnect(const char *address)
connects program to Scribbler
int rGetIRTxt(const char *sensorName, int sampleSize)
Use specified IR sensor to determine if obstacle is present. Since values of each light sensor can va...
void rFastForward(double time)
moves Scribbler forward at the largest possible speed for a specified time
unsigned char R
The value of the red component.
Definition: MyroC.h:63
const char * rGetName()
Get the name of the robot.
void rSetIRPower(int power)
Set the amount of power for the dongle's IR sensors.
void rTurnRight(double speed, double time)
turn Scribbler right for a specified time and speed