MyroC  MyroC.3.1b
C-based infrastructure for controlng Scribbler 2 robots
 All Data Structures Files Functions Variables
MyroC.h
Go to the documentation of this file.
1 
59 /*
60  ********************** implementation overview *************************
61  * MyroC implementation files organized by user function as follows:
62 
63  1. GENERAL 2. SENSORS
64  rConnect a.Scribbler Sensors
65  rDisconnect rGetLightsAll
66  rSetConnection rGetLightTxt
67  rFinishProcessing rGetIRAll
68  rSetVolume rGetIRTxt
69  rBeep rGetLine
70  rBeep2
71  rSetName b.Fluke Sensors
72  rGetName rGetObstacleAll
73  rSetForwardness rGetObstacleTxt
74  rGetForwardness rGetBrightAll
75  rSetLEDFront rGetBrightTxt
76  rSetLEDBack rSetIRPower
77  rGetBattery
78  rGetStall
79 
80 3. MOVEMENT 4. PICTURES
81  rTurnLeft rGetCameraSize
82  rTurnRight rTakePicture
83  rTurnSpeed rDisplayPicture
84  rForward rWaitTimedImageDisplay
85  rFastForward rSavePicture
86  rBackward rLoadPicture
87  rMotors
88  rStop
89  rHardStop
90 */
91 
92 #ifndef _MyroC
93 #define _MyroC
94 
97 typedef struct
98 {
99  unsigned char R;
100  unsigned char G;
101  unsigned char B;
102 } Pixel;
103 
129 typedef struct
130 {
131  int height;
132  int width;
133  Pixel pix_array[266][427];
134 } Picture;
135 
136 /* ***************************************************************/
137 /* 1. GENERAL - GENERAL - GENERAL - GENERAL - GENERAL - GENERAL */
138 /* ***************************************************************/
139 
173 int rConnect (const char * address);
174 
188 void rDisconnect();
189 
196 void rSetConnection (int new_socket_num);
197 
212 void rFinishProcessing ();
213 
220 void rSetVolume (char highMute);
221 
228 void rBeep(double duration, int frequency);
229 
237 void rBeep2(double duration, int freq1, int freq2);
238 
245 void rSetName (const char * name);
246 
252 const char * rGetName();
253 
260 void rSetForwardness(char * direction);
261 
265 void rSetForwardnessTxt (char * direction);
266 
271 char * rGetForwardness ();
272 
279 void rSetLEDFront(int led);
280 
289 void rSetLEDBack(double led);
290 
297 double rGetBattery();
298 
318 int rGetStall (int sampleSize);
319 
331 void rSetBluetoothEcho (char onOff);
332 
333 
334 /* ************************************************************************/
335 /* 2. SENSORS - SENSORS - SENSORS - SENSORS - SENSORS - SENSORS - SENSORS */
336 /* ************************************************************************/
337 
338 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
339 /* Group a: Scribbler Sensors */
340 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
341 
358 void rGetLightsAll (int lightSensors[3], int sampleSize);
359 
376 int rGetLightTxt (const char * sensorName, int sampleSize);
377 
394 void rGetIRAll (int irSensors[2], int sampleSize);
395 
396 
412 int rGetIRTxt (const char * sensorName, int sampleSize);
413 
430 void rGetLine (int lineSensors[2], int sampleSize);
431 
432 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
433 /* Group b: Fluke Sensors */
434 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
435 
444 void rSetIRPower (int power);
445 
464 void rGetObstacleAll (int obstSensors[3], int sampleSize);
465 
487 int rGetObstacleTxt (const char * sensorName, int sampleSize);
488 
504 void rGetBrightAll (int brightSensors[3], int sampleSize);
505 
525 int rGetBrightTxt (char * sensorName, int sampleSize);
526 
533 void rGetInfo (char * infoBuffer);
534 
535 
536 /* *********************************************************************/
537 /* 3. MOVEMENT - MOVEMENT - MOVEMENT - MOVEMENT - MOVEMENT - MOVEMENT */
538 /* *********************************************************************/
539 
540 /* Procedures in this section, except rMotors, include a "time" parameter.
541  *
542  * Throughout, "time" is interpreted as follows:
543  * if time > 0, the call to the procedure is "blocking:
544  * That is, a call to the procedure starts a motion, and
545  * all other processing stops for the specified time (in seconds).
546  * After the specified time interval, the motion stops,
547  * and processing in the main program continues. \n
548  * If time == 0, the procedure is "non-blocking":
549  * That is, the procedure starts a motion,
550  * and that motion continues until another motion command is issued.
551  * Once the motion starts, other processing in the main
552  * program continues. \n
553  * If time < 0, the procedure is "non-blocking":
554  * That is, a call to the procedure starts a motion,
555  * and a timer is started for the abs("time"). \n
556  * Once the time interval is completed, \n
557  * if no other motion command has been issued,
558  * a command to stop robot motion is given \n
559  * if another motion command has been issued (before the
560  * specified time), the new command is executed immediately,
561  * and the timer is ignored. \n
562  * For example, suppose rForward is called with a time of -5 seconds:
563  * subsequent processing in the main program continues \n
564  * if numerous beeps are issued or the camera is used or
565  * a series of non-motion commands are issued, then
566  * the rForward action stops in 5 seconds. \n
567  * if an rRightTurn command is issued after 2 seconds,
568  * then the rForward command is overridden by rRightTurn
569  * and the timer for rForward (after another 3 seconds)
570  * is ignored.
571  *
572  * Program termination with timed, non-blocking commands:
573  * When a non-blocking time is specified (i.e., time < 0), processing within
574  * the controlling program continues. However, the robot's Bluetooth connection
575  * (established with rConnect) is not severed until the non-blocking timer has
576  * expired and the motion stopped. In particular, rDisconnect blocks until
577  * the specified non-blocking time is completed and the program tells the
578  * robot to stop.
579  */
580 
596 void rTurnLeft (double speed, double time);
597 
614 void rTurnRight (double speed, double time);
615 
634 void rTurnSpeed (char * direction, double speed, double time);
635 
651 void rForward (double speed, double time);
652 
665 void rFastForward (double time);
666 
682 void rBackward (double speed, double time);
683 
696 void rMotors (double leftSpeed, double rightSpeed);
697 
701 void rStop();
702 
706 void rHardStop();
707 
708 /* *********************************************************************/
709 /* 4. PICTURES PICTURES PICTURES PICTURES PICTURES PICTURES PICTURES */
710 /* *********************************************************************/
757 
766 void rSavePicture(Picture * pic, char * filename);
767 
775 Picture rLoadPicture(char * filename);
776 
777 
799 void rDisplayPicture(Picture * pic, double duration, const char * windowTitle);
800 
811 void rWaitTimedImageDisplay ();
812 
813 #endif
unsigned char G
The value of the green component.
Definition: MyroC.h:100
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 height
The actual height of the image, but no more than 266.
Definition: MyroC.h:131
void rSavePicture(Picture *pic, char *filename)
Save a Picture to a .jpeg.
int rGetStall(int sampleSize)
void rTurnLeft(double speed, double time)
turn Scribbler left for a specified time and speed
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:129
void rSetForwardnessTxt(char *direction)
alternative to rSetForwardness for compatibility with earlier MyroC
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 rWaitTimedImageDisplay()
Wait until all timed, non-blocking image window timers are complete.
void rGetInfo(char *infoBuffer)
returns information about the robot's dongle, firmware, and communication mode as a 60 character arra...
void rSetVolume(char highMute)
Set sound to high volume (H) or mute (M) highMute set volume of Scribbler.
void rBeep(double duration, int frequency)
Beeps with the given duration and frequency.
Struct for a pixel.
Definition: MyroC.h:97
int rGetBrightTxt(char *sensorName, int sampleSize)
Reads one of the Fluke's virtual light sensors. Each sensor reports a total intensity in the left...
void rDisconnect()
stop Scribbler motion and close Bluetooth
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 current voltage from the Scribbler batteries; Maximum charge from 6 batteries could be up to ...
void rDisplayPicture(Picture *pic, double duration, const char *windowTitle)
Display a picture in a new window.
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 rFinishProcessing()
all timed motions/image displays completed, all robots stopped, and all robot Bluetooth connections c...
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...
unsigned char R
The value of the red component.
Definition: MyroC.h:99
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.
unsigned char B
The value of the blue component.
Definition: MyroC.h:101
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...
int width
The actual width of the image, but no more than 427.
Definition: MyroC.h:132
Picture rLoadPicture(char *filename)
Load a picture from a .jpeg file.
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
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