In application source files include: #include "eyebot.h"
Compile application to include RoBIOS library: $gccarm myfile.c -o myfile.o
int LCDPrintf(const char *format, ...); // Print string and arguments on LCD int LCDSetPrintf (int row, int column, const char *format,...) // Printf from given position int LCDClear(void); // Clear the LCD display and display buffers int LCDSetPos(int row, int column); // Set cursor position in pixels for subsequent printf int LCDGetPos(int *row, int *column) // Read current cursor position int LCDSetColor(COLOR fg, COLOR bg); // Set color for subsequent printf int LCDSetFont(int font, int variation); // Set font for subsequent print operation int LCDSetFontSize(int fontsize); // Set font-size (7..18) for subsequent print operation int LCDSetMode(int mode); // Set LCD Mode (0=default)
int LCDMenu(char *st1, char *st2, char *st3, char *st4); // Set menu entries for soft buttons int LCDMenuI(int pos, char *string, COLOR fg, COLOR bg); // Set menu for i-th entry with color [1..4]
int LCDGetSize(int *x, int *y); // Get LCD resolution in pixels int LCDPixel(int x, int y, COLOR col); // Set one pixel on LCD int LCDPixelInvert(int x, int y); // Invert pixel (gray or color) COLOR LCDGetPixel (int x, int y); // Read pixel value from LCD int LCDLine(int x1, int y1, int x2, int y2, COLOR col); // Draw line int LCDLineInvert(int x1, int y1, int x2, int y2); // Invert line int LCDArea(int x1, int y1, int x2, int y2, COLOR col, int fill); // Draw filled/hollow rectangle int LCDAreaInvert(int x1, int y1, int x2, int y2); // Invert filled rectangle int LCDCircle(int x1, int y1, int size, COLOR col, int fill); // Draw filled/hollow circle int LCDCircleInvert(int x1, int y1, int size); // Invert circle int LCDImageSize(int t); // Define image type for LCD (default QVGA; 0,0; full) int LCDImageStart(int x, int y, int xs, int ys); // Define image start position and size (default 0,0; max_x, max_y) int LCDImage(BYTE *img); // Print color image at screen start pos. and size int LCDImageGray(BYTE *g); // Print gray image [0..255] black..white int LCDImageBinary(BYTE *b); // Print binary image [0..1] white..black
Font Names and Variations: HELVETICA (default), TIMES, COURIER NORMAL (default), BOLD Color Constants (COLOR is data type "int" in RGB order): RED (0xFF0000), GREEN (0x00FF00), BLUE (0x0000FF), WHITE (0xFFFFFF), GRAY (0x808080), BLACK (0) ORANGE, SILVER, LIGHTGRAY, DARKGRAY, NAVY, CYAN, TEAL, MAGENTA, PURPLE, MAROON, YELLOW, OLIVE LCD Modes: LCD_BGCOL_TRANSPARENT, LCD_BGCOL_NOTRANSPARENT, LCD_BGCOL_INVERSE, LCD_BGCOL_NOINVERSE, LCD_FGCOL_INVERSE, LCD_FGCOL_NOINVERSE, LCD_AUTOREFRESH, LCD_NOAUTOREFRESH, LCD_SCROLLING, LCD_NOSCROLLING, LCD_LINEFEED, LCD_NOLINEFEED, LCD_SHOWMENU, LCD_HIDEMENU, LCD_LISTMENU, LCD_CLASSICMENU, LCD_FB_ROTATE, LCD_FB_NOROTATION
int KEYGet(void); // Blocking read (and wait) for key press (returns KEY1..KEY4) int KEYRead(void); // Non-blocking read of key press (returns NOKEY=0 if no key) int KEYWait(int key); // Wait until specified key has been pressed (us ANYKEY for any key) int KEYGetXY (int *x, int *y); // Blocking read for touch at any position, returns coordinates int KEYReadXY(int *x, int *y); // Non-blocking read for touch at any position, returns coordinates
Key Constants: KEY1..KEY4, ANYKEY, NOKEY
int CAMInit(int resolution); // Change camera resolution (will also set IP resolution) int CAMRelease(); // Stops camera stream int CAMGet(BYTE *buf); // Read one color camera image int CAMGetGray(BYTE *buf); // Read gray scale camera image
Resolution Settings: QQVGA(160x120), QVGA(320x240), VGA(640x480), CAM1MP(1296x730), CAMHD(1920x1080), CAM5MP(2592x1944), CUSTOM (LCD only) Variables CAMWIDTH, CAMHEIGHT, CAMPIXELS (=width*height) and CAMSIZE (=3*CAMPIXELS) will be automatically set, (BYTE is data type "char"). Constant sizes in bytes for color images and number of pixels: QQVGA_SIZE, QVGA_SIZE, VGA_SIZE, CAM1MP_SIZE, CAMHD_SIZE, CAM5MP_SIZE QQVGA_PIXELS, QVGA_PIXELS, VGA_PIXELS, CAM1MP_PIXELS, CAMHD_PIXELS, CAM5MP_PIXELS Data Types: typedef QQVGAcol BYTE [120][160][3]; typedef QQVGAgray BYTE [120][160]; typedef QVGAcol BYTE [240][320][3]; typedef QVGAgray BYTE [240][320]; typedef VGAcol BYTE [480][640][3]; typedef VGAgray BYTE [480][640]; typedef CAM1MPcol BYTE [730][1296][3]; typedef CAM1MPgray BYTE [730][1296]; typedef CAMHDcol BYTE[1080][1920][3]; typedef CAMHDgray BYTE[1080][1920]; typedef CAM5MPcol BYTE[1944][2592][3]; typedef CAM5MPgray BYTE[1944][2592];
int IPSetSize(int resolution); // Set IP resolution using CAM constants (also automatically set by CAMInit) int IPReadFile(char *filename, BYTE* img); // Read PNM file, fill/crop if req.; return 0 for color, 1 for gray image int IPWriteFile(char *filename, BYTE* img); // Write color PNM file int IPWriteFileGray(char *filename, BYTE* gray); // Write gray scale PGM file
void IPLaplace(BYTE* grayIn, BYTE* grayOut); // Laplace edge detection on gray image void IPSobel(BYTE* grayIn, BYTE* grayOut); // Sobel edge detection on gray image void IPCol2Gray(BYTE* imgIn, BYTE* grayOut); // Transfer color to gray void IPRGB2Col (BYTE* r, BYTE* g, BYTE* b, BYTE* imgOut); // Transform 3*gray to color void IPCol2HSI (BYTE* img, BYTE* h, BYTE* s, BYTE* i); // Transform RGB image to HSI int IPOverlay(BYTE* c1, BYTE* c2, BYTE* cOut); // Overlay c2 onto c1, all color images int IPOverlayGray(BYTE* g1, BYTE* g2, COLOR col, BYTE* cOut); // Overlay gray image g2 onto g1, using col
COLOR IPPRGB2Col(BYTE r, BYTE g, BYTE b); // PIXEL: RGB to color void IPPCol2RGB(COLOR col, BYTE* r, BYTE* g, BYTE* b); // PIXEL: color to RGB void IPPCol2HSI(COLOR c, BYTE* h, BYTE* s, BYTE* i); // PIXEL: RGB to HSI for pixel BYTE IPPRGB2Hue(BYTE r, BYTE g, BYTE b); // PIXEL: Convert RGB to hue (0 for gray values) void IPPRGB2HSI(BYTE r, BYTE g, BYTE b, BYTE* h, BYTE* s, BYTE* i); // PIXEL: Convert RGB to hue, sat, int; hue=0 for gray values
char * OSExecute(char* command); // Execute Linux program in background int OSVersion(char* buf); // RoBIOS Version int OSVersionIO(char* buf); // RoBIOS-IO Board Version int OSMachineSpeed(void); // Speed in MHz int OSMachineType(void); // Machine type int OSMachineName(char* buf); // Machine name int OSMachineID(void); // Machine ID derived from MAC address
int MTInit(); // Start multi-tasking int MTSleep(int n) // Sleep for n/100 seconds TASK MTSpawn (void (*fct)(void), int id) // Create and initialize thread with given ID int MTGetUID(TASK t); // Read ID of current thread int MTKill(TASK t); // Delete thread (0 for self) int MTExit(void); // Terminate current thread
SEMA SEMAInit(SEMAPHORE *sem,int val); // Create and initialize semaphore with VAL (e.g. 1) int SEMALock(SEMS sem); // Lock semaphore int SEMAUnlock(SEMA); // Unlock semaphorepthreads are used for implementing multi-tasking.
int OSWait(int n); // Wait for n/1000 sec TIMER OSAttachTimer(int scale, (*fct)(void)); // Add fct to 1000Hz/scale timer int OSDetachTimer(TIMER t) // Remove fct from 1000Hz/scale timer
int OSSetTime(int hrs,int mins,int secs); // Set system time int OSGetTime(int *hrs,int *mins,int *secs,int *ticks); // Get system time (ticks in 1/1000 sec) int OSGetCount(void); // Count in 1/1000 sec since system start
int SERInit(int interface, int baud,int handshake); // Init communication (see parameters below), interface number as in HDT file int SERSendChar(int interface, char ch); // Send single character int SERSend(int interface, char *buf); // Send string (Null terminated) char SERReceiveChar(int interface); // Receive single character int SERReceive(int interface, char *buf); // Receive String (Null terminated), function returns number of chars received bool SERCheck(int interface); // Non-blocking check if character is waiting int SERFlush(int interface); // Flush interface buffers int SERClose(int interface); // Close Interface
Communication Parameters: Baudrate: 50 .. 230400 Handshake: NONE, RTSCTS Interface: 0 (serial port), 1..20 (USB devices, names are assigned via HDT entries)
int AUBeep(void); // Play beep sound int AUTone(int freq, int time); // Play tone with FREQ for time/100 sec int AUCheckTone(void); // Non-blocking test if tone has finished int AUPlay(BYTE* sample); // Play audio sample int AUCheckPlay(void); // Non-blocking test if playing has finished int AUMicrophone(void); // Return microphone A-to-D sample value int AURecord(BYTE* buf, int time, long freq); // Record sound for time/100sec using sample FREQ int AUCheckRecord(void); // Non-blocking check whether recording has finished
int PSDGet(int psd); // Read distance value from PSD sensor [1..6] int PSDGetRaw(int psd); // Read raw value from PSD sensor [1..6]
int SERVOSet(int servo, int angle); // Set servo [1..14] position to [1..255] or power down (0) int SERVOSetRaw (int servo, int angle); // Set servo [1..14] position bypassing HDT int SERVORange(int servo, int low, int high); // Set servo [1..14] limits in 1/100 sec
int MOTORDrive(int motor, int speed); // Set motor [1..4] speed in percent [-100 ..+100] int MOTORDriveRaw(int motor, int speed); // Set motor [1..4] speed bypassing HDT int MOTORPID(int motor, int p, int i, int d); // Set motor [1..4] PID controller values [1..255] int MOTORPIDOff(int motor); // Stop PID control loop int MOTORSpeed(int motor, int ticks); // Set controlled motor speed in ticks/100 sec
int ENCODERRead(int quad); // Read quadrature encoder [1..4] int ENCODERReset(int quad); // Set encoder value to 0 [1..4]
int VWSetSpeed(int linSpeed, int angSpeed); // Set fixed linSpeed (mm/s) and angSpeed [(rad/100)/s] int VWGetSpeed(int *linSspeed. int *angSpeed); // Read current speeds int VWSetPosition(int x, int y, int phi); // Set robot position to x, y [mm], phi [rad/100] int VWGetPosition(int *x, int *y, int *phi); // Get robot position as x, y [mm], phi [rad/100] int VWControl(int Vv, int Tv, int Vw, int Tw); // Set PI params. for v and w (typical 70 30 70 10) int VWControlOff(void); // Stop PI control for v and w
int VWStraight(int dist, int lin_speed); // Drive straight, dist [mm], lin. speed [mm/s] int VWTurn(int angle, int ang_speed); // Turn on spot, angle [rad/100], ang. speed [(rad/100)/s] int VWCurve(int dist, int angle, int lin_speed);// Drive Curve, dist [mm], angle (orientation change) [rad/100], lin. speed [mm/s] int VWDrive(int dx, int dy, int lin_speed); // Drive x[mm] straight and y[mm] left, x>|y| int VWDriveRemain(void); // Return remaining drive time in 1/100 sec int VWDriveDone(void); // Non-blocking check whether drive is finished (1) or not (0) int VWDriveWait(void); // Suspend current thread until drive operation has finished int VWStalled(void); // Returns number of stalled motor [1..2], 3 if both stalled, 0 if none
All VW functions return 0 if OK and 1 if error (e.g. destination unreachable)
int DIGITALSetup(int io, char direction); // Set IO line [1..16] to i-n/o-ut/I-n pull-up/J-n pull-down int DIGITALRead(int io); // Read and return individual input line [1..16] int DIGITALReadAll(void); // Read and return all 16 io lines int DIGITALWrite(int io, int state); // Write individual output [1..16] to 0 or 1
int ANALOGRead(int channel); // Read analog channel [1..8] int ANALOGVoltage(void); // Read analog supply voltage in [Volt/100]
Default for digital IO lines: [1..8] are input with pull-up, [9..16] are output IO settings are: i: input, o: output, I: input with pull-up res., J: input with pull-down res.
int IRTVGet(void); // Blocking read of IRTV command int IRTVRead(void); // Non-blocking read, return 0 if nothing int IRTVFlush(void); // Empty IRTV buffers int IRTVGetStatus(void); // Checks to see if IRTV is activated (1) or off (0)
Defined Constants for IRTV buttons are: IRTV_0 .. IRTV_9, IRTV_RED, IRTV_GREEN, IRTV_YELLOW, IRTV_BLUE, IRTV_LEFT, IRTV_RIGHT, IRTV_UP, IRTV_DOWN, IRTV_OK, IRTV_POWER
int RADIOInit(void); // Start radio communication int RADIOGetID(void); // Get own radio ID int RADIOSend(int id, BYTE* buf, int size); // Send spec. number of bytes to ID destination int RADIOReceive(int *id, BYTE* buf, int *size);// Read num. of bytes from ID source int RADIOCheck(int *id); // Non-blocking check whether message is waiting int RADIOStatus(int IDlist[]); // Returns number of robots (incl. self) and list of IDs in network int RADIORelease(void); // Terminate radio communication
ID numbers match last byte of robots' IP addresses.