#ifndef GARCIA_UTIL_H #define GARCIA_UTIL_H /* This header file defines public interface to control the robot. */ /* The robot is controlled through acpGarcia class provided by */ /* acroname inside the Brainstem API. Here we use pure C function to */ /* take the place of the complicated acpGarcia class to do the same */ /* function. */ /* To use the Garcia robot, user should call init() first in the start */ /* of his code. When user's program is about to quit, user should call destroy() */ /* function. */ /* Any question related to Garcia.cpp and garcia.h should be reported to pway@cs.dartmouth.edu(Wei Pan) */ #ifdef __cplusplus extern "C" { #endif // This is a blocking function, which means that the function // will not return before the robot finish the walk. // The float is the distance the user want to robots to move. // The unit of the distance is ADJUSTABLE, currently it is centimeter. //! param f the distance to go, negative number for backward. //! return a status value, 0 means success, otherwise failure(may be robots are blocked by wall so they can't move) int GarciaWalk(float); // This is also a blocking function. The robot will turn acording to // the angle value the user pass in as a parameter. The current unit is // rad. So PI means turn 180 degrees. // param f the angel to turn, negative number for counter-clockwise // return a status value, 0 means success, otherwise failure(may be robots are blocked by wall so they can't move) int GarciaTurn(float); // The following two functions is the non-blocking version of the up two // functions, which means they will return immediately after you call them. // The robot will execute the movement concurrently. // If you call them multiple times, the robot will queue each movement and // execute them in FIFO order. int GarciaTurnN(float); int GarciaWalkN(float); // This function is to stop all movements of the robot and clear the movement // queue. The robot stop immediately when you call it. void GarciaStop(); // NOTICE: The upper two function will return a value indicating the status // of the robots. 0 means works fine. Otherwise there is a problem. // The return value and problems has a relation: /* Please refer to brainstem/aCommon/aErr.h for full list of error codes meanings. */ // Before the program, please call init(), and pass in the // laptop server address, so there is a heart beat thread which will // connect to the server address every certain time interval. // The two following constant defines the properties of the heart beat thread: // the HEARTBEAT_PORT is the port for the server to receive the heart beat. #define HEARTBEAT_INTERVAL 60 #define HEARTBEAT_PORT 5656 //! param c the ip address of the server side code, // ( this IP address will be used to send back a HEARTBEAT signal.) void init(char*); // Before your program quit, please call destroy() void destroy(); // parameters for GarciaRangeData() #define FRONT_RANGE_LEFT 1 #define FRONT_RANGE_RIGHT 2 #define SIDE_RANGE_LEFT 3 #define SIDE_RANGE_RIGHT 4 #define REAR_RANGE_LEFT 5 #define REAR_RANGE_RIGHT 6 #define BATTERY 7 // Garcia has 8 rangers, however, we here only use 6 of them. Pass in which ranger // you want to set type to REAR_RANGE_LEFT or SIDE_RANGE_LEFT, it will return the range // information. //! param type see #define //! return a reading from sensors float GarciaRangeData (int type); #ifdef __cplusplus } #endif #endif