Eyebot 7: eyebot/include/eyebot.h Source File

Eyebot 7 7.16 A Hardware API to control various hardware

- Main Page
- Functions
- Types
- Files

- File List
- Globals

eyebot.h
Go to the documentation of this file.
1
61 #ifndef EYEBOT_H_
62 #define EYEBOT_H_
63
64 #include "types.h"
65
69
75 int LCDPrintf(const char *format, ...);
76
84 int LCDSetPrintf(int row, int column, const char *format, ...);
85
90 int LCDClear(void);
91
98 int LCDSetPos(int row, int column);
99
106 int LCDGetPos(int *row, int *column);
107
114 int LCDSetColor(COLOR fg, COLOR bg);
115
122 int LCDSetFont(int font, int variation);
123
129 int LCDSetFontSize(int fontsize);
130
136 int LCDSetMode(int mode);
137
146 int LCDMenu(char *st1, char *st2, char *st3, char *st4);
147
156 int LCDMenuI(int pos, char *string, COLOR fg, COLOR bg);
157
164 int LCDGetSize(int *x, int *y);
165
173 int LCDPixel(int x, int y, COLOR col);
174
181 int LCDPixelInvert(int x, int y);
182
189 COLOR LCDGetPixel (int x, int y);
190
200 int LCDLine(int x1, int y1, int x2, int y2, COLOR col);
201
210 int LCDLineInvert(int x1, int y1, int x2, int y2);
211
221 int LCDArea(int x1, int y1, int x2, int y2, COLOR col, int fill);
222
232 int LCDAreaInvert(int x1, int y1, int x2, int y2);
233
243 int LCDCircle(int x1, int y1, int size, COLOR col, int fill);
244
252 int LCDCircleInvert(int x1, int y1, int size);
253
259 int LCDImageSize(int t);
260
270 int LCDImageStart(int x, int y, int xs, int ys);
271
277 int LCDImage(BYTE *img);
278
284 int LCDImageGray(BYTE *g);
285
291 int LCDImageBinary(BYTE *b);
292
297 int LCDRefresh(void);
299
300 /******************************************************************************************************************************/
301
305
310 int KEYGet(void);
311
316 int KEYRead(void);
317
323 int KEYWait(int key);
324
329 int KEYGetXY (int *x, int *y); /
330
335 int KEYReadXY(int *x, int *y);
336
338
339 /******************************************************************************************************************************/
340
344
350 int CAMInit(int resolution);
351
357 int CAMRelease(void);
358
364 int CAMGet(BYTE *buf);
365
371 int CAMGetGray(BYTE *buf);
372
374
375 /******************************************************************************************************************************/
376
380
386 int IPSetSize(int resolution);
387
394 int IPReadFile(char *filename, BYTE* img);
395
402 int IPWriteFile(char *filename, BYTE* img);
403
410 int IPWriteFileGray(char *filename, BYTE* gray);
411
417 void IPLaplace(BYTE* grayIn, BYTE* grayOut);
418
424 void IPSobel(BYTE* imageIn, BYTE* imageOut);
425
431 void IPCol2Gray(BYTE* imgIn, BYTE* grayOut);
432
438 void IPGray2Col(BYTE* imgIn, BYTE* colOut);
439
445 void IPRGB2Col (BYTE* r, BYTE* g, BYTE* b, BYTE* imgOut);
446
454 void IPCol2HSI (BYTE* img, BYTE* h, BYTE* s, BYTE* i);
455
462 void IPOverlay(BYTE* c1, BYTE* c2, BYTE* cOut);
463
471 void IPOverlayGray(BYTE* g1, BYTE* g2, COLOR col, BYTE* cOut);
472
480 COLOR IPPRGB2Col(BYTE r, BYTE g, BYTE b);
481
489 void IPPCol2RGB(COLOR col, BYTE* r, BYTE* g, BYTE* b);
490
498 void IPPCol2HSI(COLOR c, BYTE* h, BYTE* s, BYTE* i);
499
507 BYTE IPPRGB2Hue(BYTE r, BYTE g, BYTE b);
508
518 void IPPRGB2HSI(BYTE r, BYTE g, BYTE b, BYTE* h, BYTE* s, BYTE* i);
519
521
522 /******************************************************************************************************************************/
523
527
533 char * OSExecute(char* command);
534
539 int OSVersion(char* buf);
540
546 int OSVersionIO(char* buf);
547
552 int OSMachineSpeed(void);
553
559 int OSMachineType(void);
560
565 int OSMachineName(char* buf);
566
571 int OSMachineID(void);
572
574
575 /******************************************************************************************************************************/
576
580
585 int MTInit(void);
586
592 int MTSleep(int n);
593
600 TASK MTSpawn(void* (*fct) (void*), int id);
601
607 int MTGetUID(TASK t);
608
614 int MTKill(TASK t);
615
620 int MTExit(void);
621
628 int SEMAInit(SEMA *sem, int val);
629
635 int SEMALock(SEMA* sem);
636
642 int SEMAUnlock(SEMA* sem);
643
644
650 int OSWait(int n);
651
659 TIMER OSAttachTimer(int scale, void (*fct)(void));
660
666 int OSDetachTimer(TIMER t);
667
675 int OSSetTime(int hrs,int mins,int secs);
676
685 int OSGetTime(int *hrs,int *mins,int *secs,int *ticks);
686
691 int OSGetCount(void);
692
694
695 /******************************************************************************************************************************/
696
700
708 int SERInit(int interface, int baud,int handshake);
709
716 int SERSendChar(int interface, char ch);
717
725 int SERSend(int interface, char *buf);
726
732 char SERReceiveChar(int interface);
733
741 int SERReceive(int interface, char *buf);
742
748 bool SERCheck(int interface);
749
755 int SERFlush(int interface);
756
762 int SERClose(int interface);
763
765
766 /******************************************************************************************************************************/
767
771
776 int AUBeep(void);
777
784 int AUTone(int freq, int time);
785
790 int AUCheckTone(void);
791
797 int AUPlay(BYTE* sample);
798
803 int AUCheckPlay(void);
804
809 int AUMicrophone(void);
810
818 int AURecord(BYTE* buf, int time, long freq);
819
824 int AUCheckRecord(void);
825
827
828 /******************************************************************************************************************************/
829
833
839 int PSDGet(int psd);
840
846 int PSDGetRaw(int psd);
847
849
850 /******************************************************************************************************************************/
851
855
862 int SERVOSet(int servo, int angle);
863
870 int SERVOSetRaw (int servo, int angle);
871
879 int SERVORange(int servo, int low, int high);
880
882
883 /******************************************************************************************************************************/
884
888
895 int MOTORDrive(int motor, int speed);
896
903 int MOTORDriveRaw(int motor, int speed);
904
913 int MOTORPID(int motor, int p, int i, int d);
914
920 int MOTORPIDOff(int motor);
921
928 int MOTORSpeed(int motor, int ticks);
929
931
932 /******************************************************************************************************************************/
933
937
943 int ENCODERRead(int quad);
944
950 int ENCODERReset(int quad);
951
953
954 /******************************************************************************************************************************/
955
959
966 int VWSetSpeed(int linSpeed, int angSpeed);
967
974 int VWGetSpeed(int *linSspeed, int *angSpeed);
975
983 int VWSetPosition(int x, int y, int phi);
984
992 int VWGetPosition(int *x, int *y, int *phi);
993
1002 int VWControl(int Vv, int Tv, int Vw, int Tw);
1003
1008 int VWControlOff(void);
1009
1016 int VWStraight(int dist, int lin_speed);
1017
1024 int VWTurn(int angle, int ang_speed);
1025
1033 int VWCurve(int dist, int angle, int lin_speed);
1034
1042 int VWDrive(int dx, int dy, int lin_speed);
1043
1048 int VWDriveRemain(void);
1049
1054 int VWDriveDone(void);
1055
1060 int VWDriveWait(void);
1061
1066 int VWStalled(void);
1067
1069
1070 /******************************************************************************************************************************/
1071
1075
1082 int DIGITALSetup(int io, char direction);
1083
1089 int DIGITALRead(int io);
1090
1095 int DIGITALReadAll(void);
1096
1103 int DIGITALWrite(int io, int state);
1104
1110 int ANALOGRead(int channel);
1111
1116 int ANALOGVoltage(void);
1117
1119
1120 /******************************************************************************************************************************/
1121
1125
1130 int IRTVGet(void);
1131
1136 int IRTVRead(void);
1137
1142 int IRTVFlush(void);
1143
1148 int IRTVGetStatus(void);
1149
1151
1152 /******************************************************************************************************************************/
1153
1157
1162 int RADIOInit(void);
1163
1168 int RADIOGetID(void);
1169
1177 int RADIOSend(int id_no, BYTE* buf, int size);
1178
1186 int RADIOReceive(int *id_no, BYTE* buf, int *size);
1187
1193 int RADIOCheck(int *id_no);
1194
1200 int RADIOStatus(int IDlist[]);
1201
1206 int RADIORelease(void);
1207
1209
1210
1211 #endif /* EYEBOT_H_ */
RADIOReceive
int RADIOReceive(int *id_no, BYTE *buf, int *size)
Read num. of bytes from ID source.
IPCol2Gray
void IPCol2Gray(BYTE *imgIn, BYTE *grayOut)
Transfer color to gray image.
MTKill
int MTKill(TASK t)
kills the task t
MTSleep
int MTSleep(int n)
sleeps for 10ms ie n/100s
VWControl
int VWControl(int Vv, int Tv, int Vw, int Tw)
Set PI params. for v and w (typical 70 30 70 10)
IPRGB2Col
void IPRGB2Col(BYTE *r, BYTE *g, BYTE *b, BYTE *imgOut)
Transfer grey to color (3-byte) image.
VWDriveWait
int VWDriveWait(void)
Blocks until the drive is complete.
VWSetSpeed
int VWSetSpeed(int linSpeed, int angSpeed)
Sets the VW speed, angle.
LCDGetPixel
COLOR LCDGetPixel(int x, int y)
Get the RGB color value of the pixel at (x,y) coordinate.
VWGetSpeed
int VWGetSpeed(int *linSspeed, int *angSpeed)
Obtains the current speeds.
KEYGetXY
int KEYGetXY(int *x, int *y)
Blocking read for touch at any position, and returns the coordinates of the pressed position...
SERSendChar
int SERSendChar(int interface, char ch)
Sends a single character to the given port handle.
LCDImageSize
int LCDImageSize(int t)
Specifies the size of subsequent LCDImage functions.
types.h
Defines types used for the EyeBot 7.
SEMAInit
int SEMAInit(SEMA *sem, int val)
initialises the semaphores
IPPCol2HSI
void IPPCol2HSI(COLOR c, BYTE *h, BYTE *s, BYTE *i)
Transforms RGB to HSI (for one pixel)
SERFlush
int SERFlush(int interface)
flushes the port
KEYGet
int KEYGet(void)
Blocking read (and wait) for key press (returns KEY1..KEY4)
IPReadFile
int IPReadFile(char *filename, BYTE *img)
Read PNM file, fill/crop if req.; return 0 for color, 1 for gray image.
VWCurve
int VWCurve(int dist, int angle, int lin_speed)
Turns the vehicle in a curve.
LCDSetPrintf
int LCDSetPrintf(int row, int column, const char *format,...)
LCDPrintf with text position specified.
CAMGet
int CAMGet(BYTE *buf)
Retrieve a camera frame into the provided buffer.
OSMachineSpeed
int OSMachineSpeed(void)
Inform the user how fast the processor runs.
OSVersion
int OSVersion(char *buf)
Returns string containing running RoBIOS version.
OSMachineID
int OSMachineID(void)
Inform the user with which ID the Eyebot is titled.
VWTurn
int VWTurn(int angle, int ang_speed)
Turns the vehicle on the spot.
OSMachineName
int OSMachineName(char *buf)
Inform the user with which name the Eyebot is titled.
LCDLineInvert
int LCDLineInvert(int x1, int y1, int x2, int y2)
Draw a line from (x1,y1) to (x2,y2). The line pixels will invert the color of existing pixels...
AUTone
int AUTone(int freq, int time)
Play tone with FREQ for time/100 sec.
COLOR
int COLOR
Definition: types.h:109
LCDImageBinary
int LCDImageBinary(BYTE *b)
Draws a binary [0..1] image to the LCD.
AUCheckRecord
int AUCheckRecord(void)
Non-blocking check whether recording has finished.
ANALOGRead
int ANALOGRead(int channel)
Reads the analog channel on the IO board.
IPWriteFileGray
int IPWriteFileGray(char *filename, BYTE *gray)
Write greyscale PNM file.
LCDImageGray
int LCDImageGray(BYTE *g)
Draws a greyscale [0..255] image to the LCD.
IPGray2Col
void IPGray2Col(BYTE *imgIn, BYTE *colOut)
Transfer grey to color (3-byte) image.
VWSetPosition
int VWSetPosition(int x, int y, int phi)
Sets the position wrt current position.
IRTVGetStatus
int IRTVGetStatus(void)
Checks to see if IR input is enabled;.
VWDriveDone
int VWDriveDone(void)
Checks to see if the current drive is complete.
AUPlay
int AUPlay(BYTE *sample)
Play audio sample.
LCDSetPos
int LCDSetPos(int row, int column)
Set the text cursor position to (row, column).
OSDetachTimer
int OSDetachTimer(TIMER t)
removes the Timer from the list
IRTVRead
int IRTVRead(void)
Non-blocking read, return 0 if nothing and returns the keycode.
VWControlOff
int VWControlOff(void)
Stop PI control for v and w.
MOTORPID
int MOTORPID(int motor, int p, int i, int d)
Set the given motors with PID control.
IPSetSize
int IPSetSize(int resolution)
Sets the size for the image processing (also automatically set by CAMInit).
IPOverlay
void IPOverlay(BYTE *c1, BYTE *c2, BYTE *cOut)
Overlay c2 onto c1, all color images.
LCDClear
int LCDClear(void)
Clear the LCD display and all display buffers ie. turn it black.
ENCODERRead
int ENCODERRead(int quad)
Reads the value from the encoder.
RADIOCheck
int RADIOCheck(int *id_no)
Non-blocking check whether message is waiting.
LCDSetFont
int LCDSetFont(int font, int variation)
Sets the font using font type and variation.
OSWait
int OSWait(int n)
Waits for 1 ms.
MOTORSpeed
int MOTORSpeed(int motor, int ticks)
Sets the controlled motor speed in ticks/sec.
CAMRelease
int CAMRelease(void)
Stops and releases all camera structures.
OSSetTime
int OSSetTime(int hrs, int mins, int secs)
sets the system time
LCDImage
int LCDImage(BYTE *img)
Draws a colour (RGB) image to the LCD.
PSDGet
int PSDGet(int psd)
Delivers actual timestamp or distance measured by the selected PSD.
LCDCircleInvert
int LCDCircleInvert(int x1, int y1, int size)
Inverts the pixels inside of the given circle.
SEMAUnlock
int SEMAUnlock(SEMA *sem)
unlocks the given semaphore
IPLaplace
void IPLaplace(BYTE *grayIn, BYTE *grayOut)
apply Laplace tranform to the image
IPCol2HSI
void IPCol2HSI(BYTE *img, BYTE *h, BYTE *s, BYTE *i)
Transfer color image to hue sat int.
RADIOSend
int RADIOSend(int id_no, BYTE *buf, int size)
Send spec. number of bytes to ID destination.
KEYRead
int KEYRead(void)
Non-blocking read of key press (returns NOKEY=0 if no key)
LCDAreaInvert
int LCDAreaInvert(int x1, int y1, int x2, int y2)
Draw a rectangle with (x1,y1) as top-left coordinate and (x2,y2) as the bottom-right coordinate...
IPPRGB2Hue
BYTE IPPRGB2Hue(BYTE r, BYTE g, BYTE b)
Convert RGB to hue (0 for gray values)
IPOverlayGray
void IPOverlayGray(BYTE *g1, BYTE *g2, COLOR col, BYTE *cOut)
Overlay gray image g2 onto g1, using col.
LCDMenuI
int LCDMenuI(int pos, char *string, COLOR fg, COLOR bg)
Set specific menu entry in KEY_CLASSIC mode (index given by pos).
VWDriveRemain
int VWDriveRemain(void)
Checks the remaining drive time.
SERVORange
int SERVORange(int servo, int low, int high)
Sets the range for the servos.
AUCheckPlay
int AUCheckPlay(void)
Non-blocking test if playing has finished.
DIGITALSetup
int DIGITALSetup(int io, char direction)
Sets up the digital input/output pins.
IRTVGet
int IRTVGet(void)
Blocking read of IRTV command and returns the keycode.
AURecord
int AURecord(BYTE *buf, int time, long freq)
Record sound for time/100sec using sample FREQ.
LCDSetMode
int LCDSetMode(int mode)
Update the internal mode flag bits.
LCDImageStart
int LCDImageStart(int x, int y, int xs, int ys)
Sets the location and size parameters for subsequent image draws.
AUCheckTone
int AUCheckTone(void)
Non-blocking test if tone has finished.
MTGetUID
int MTGetUID(TASK t)
gets the ID of the taks
LCDPixel
int LCDPixel(int x, int y, COLOR col)
Sets the color of the pixel at (x,y) coordinate to color.
LCDSetFontSize
int LCDSetFontSize(int fontsize)
Sets the font size.
MOTORDrive
int MOTORDrive(int motor, int speed)
Set the given motors to the same given speed dependant on hdt table.
MTExit
int MTExit(void)
kills current task
LCDLine
int LCDLine(int x1, int y1, int x2, int y2, COLOR col)
Draw a color line from (x1,y1) to (x2,y2).
SERClose
int SERClose(int interface)
closes the port
AUBeep
int AUBeep(void)
Play beep sound.
LCDArea
int LCDArea(int x1, int y1, int x2, int y2, COLOR col, int fill)
Draw a color-filled rectangle with (x1,y1) as top-left coordinate and (x2,y2) as the bottom-right coo...
LCDPrintf
int LCDPrintf(const char *format,...)
Print formatted string to LCD and refresh LCD. Cursor position is updated.
RADIOStatus
int RADIOStatus(int IDlist[])
Returns number of robots (incl. self) and list of IDs in network.
SERSend
int SERSend(int interface, char *buf)
Sends a string to the given port handle.
RADIOInit
int RADIOInit(void)
Starts radio communication between the Eyebots.
TIMER
int TIMER
Definition: types.h:112
VWStalled
int VWStalled(void)
Checks to see if the vehicle is stalled.
DIGITALWrite
int DIGITALWrite(int io, int state)
Writes to the digital input/output pins.
SERReceive
int SERReceive(int interface, char *buf)
Receives a string from port handle.
OSMachineType
int OSMachineType(void)
Inform the user in which environment the program runs.
AUMicrophone
int AUMicrophone(void)
Return microphone A-to-D sample value.
SERInit
int SERInit(int interface, int baud, int handshake)
Initialises the port.
CAMInit
int CAMInit(int resolution)
Initialises the camera.
IPPRGB2Col
COLOR IPPRGB2Col(BYTE r, BYTE g, BYTE b)
Transforms RGB to a COLOR (for one Pixel)
SERReceiveChar
char SERReceiveChar(int interface)
Receives a single character from the given port handle.
OSExecute
char * OSExecute(char *command)
Executes a system command and obtains the string returned after the command.
SERVOSet
int SERVOSet(int servo, int angle)
Set the given servos to the same given angle depending on table value.
VWDrive
int VWDrive(int dx, int dy, int lin_speed)
Turns the vehicle in a curve: x[mm] straight and y[mm] left, x>|y|.
OSGetTime
int OSGetTime(int *hrs, int *mins, int *secs, int *ticks)
Get system time (ticks in 1/100 sec)
IPPCol2RGB
void IPPCol2RGB(COLOR col, BYTE *r, BYTE *g, BYTE *b)
Transforms COLOR to RGB (for one Pixel)
PSDGetRaw
int PSDGetRaw(int psd)
Delivers raw-data measured by the selected PSD.
MOTORDriveRaw
int MOTORDriveRaw(int motor, int speed)
Set the given motor to a given speed.
OSAttachTimer
TIMER OSAttachTimer(int scale, void(*fct)(void))
adds a function to a 1kHz/scale timer, ie. executes every 1ms*scale usage: OSAttachTimer(<scale>, &<function>);
LCDSetColor
int LCDSetColor(COLOR fg, COLOR bg)
Set the default color for text (including background).
KEYReadXY
int KEYReadXY(int *x, int *y)
Non-blocking read for touch at any position, returns coordinates of pressed position.
IPPRGB2HSI
void IPPRGB2HSI(BYTE r, BYTE g, BYTE b, BYTE *h, BYTE *s, BYTE *i)
Convert RGB to hue, sat, int; hue=0 for gray values.
ANALOGVoltage
int ANALOGVoltage(void)
Finds the Analog Voltage as read from the IO board.
DIGITALRead
int DIGITALRead(int io)
Reads the digital input/output pins.
CAMGetGray
int CAMGetGray(BYTE *buf)
Grabs a gray image off the camera.
MOTORPIDOff
int MOTORPIDOff(int motor)
Shuts off PID control.
IPSobel
void IPSobel(BYTE *imageIn, BYTE *imageOut)
apply Sobel tranform to the image
LCDGetSize
int LCDGetSize(int *x, int *y)
Get LCD resolution in pixels.
DIGITALReadAll
int DIGITALReadAll(void)
Reads all digital pins.
LCDMenu
int LCDMenu(char *st1, char *st2, char *st3, char *st4)
Set menu entries in KEY_CLASSIC mode (4-buttons).
LCDGetPos
int LCDGetPos(int *row, int *column)
Get the text cursor position.
ENCODERReset
int ENCODERReset(int quad)
Resets the encoder to 0.
LCDPixelInvert
int LCDPixelInvert(int x, int y)
Bit-invert the color of the pixel at (x,y) coordinate.
BYTE
char BYTE
Definition: types.h:110
VWStraight
int VWStraight(int dist, int lin_speed)
Drives straight.
LCDCircle
int LCDCircle(int x1, int y1, int size, COLOR col, int fill)
Draws a circle.
IRTVFlush
int IRTVFlush(void)
Terminates the remote control decoder and releases the irtv thread.
OSVersionIO
int OSVersionIO(char *buf)
Gives the version of the IO board.
RADIOGetID
int RADIOGetID(void)
Get own radio ID.
SEMALock
int SEMALock(SEMA *sem)
locks the given semaphoe
MTInit
int MTInit(void)
initialises the threads
KEYWait
int KEYWait(int key)
Wait for specific keys to be pressed. (use ANYKEY for any key)
RADIORelease
int RADIORelease(void)
Terminate radio communication.
LCDRefresh
int LCDRefresh(void)
Refresh the screen. Refreshes the menu.
VWGetPosition
int VWGetPosition(int *x, int *y, int *phi)
Gets the position wrt original position.
IPWriteFile
int IPWriteFile(char *filename, BYTE *img)
Write color PNM file.
OSGetCount
int OSGetCount(void)
gives you the count in 1/100 sec since the system start
SERVOSetRaw
int SERVOSetRaw(int servo, int angle)
Set the given servos to the same given angle in raw mode.
MTSpawn
TASK MTSpawn(void *(*fct)(void *), int id)
Create and initialize thread with given ID.
SERCheck
bool SERCheck(int interface)
checks and flushes the port by sending enter until seeing prompt