00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef CREATE_COMMS_H
00024 #define CREATE_COMMS_H
00025
00026 #ifdef __cplusplus
00027 extern "C" {
00028 #endif
00029
00030 #include <limits.h>
00031
00032
00033 #define CREATE_OPCODE_START 128
00034 #define CREATE_OPCODE_BAUD 129
00035 #define CREATE_OPCODE_SAFE 131
00036 #define CREATE_OPCODE_FULL 132
00037 #define CREATE_OPCODE_SPOT 134
00038 #define CREATE_OPCODE_COVER 135
00039 #define CREATE_OPCODE_DEMO 136
00040 #define CREATE_OPCODE_DRIVE 137
00041 #define CREATE_OPCODE_MOTORS 138
00042 #define CREATE_OPCODE_LEDS 139
00043 #define CREATE_OPCODE_SONG 140
00044 #define CREATE_OPCODE_PLAY 141
00045 #define CREATE_OPCODE_SENSORS 142
00046 #define CREATE_OPCODE_COVERDOCK 143
00047 #define CREATE_OPCODE_PWM_MOTORS 144
00048 #define CREATE_OPCODE_DRIVE_WHEELS 145
00049 #define CREATE_OPCODE_DIGITAL_OUTPUTS 147
00050 #define CREATE_OPCODE_STREAM 148
00051 #define CREATE_OPCODE_QUERY_LIST 149
00052 #define CREATE_OPCODE_DO_STREAM 150
00053 #define CREATE_OPCODE_SEND_IR_CHAR 151
00054 #define CREATE_OPCODE_SCRIPT 152
00055 #define CREATE_OPCODE_PLAY_SCRIPT 153
00056 #define CREATE_OPCODE_SHOW_SCRIPT 154
00057 #define CREATE_OPCODE_WAIT_TIME 155
00058 #define CREATE_OPCODE_WAIT_DISTANCE 156
00059 #define CREATE_OPCODE_WAIT_ANGLE 157
00060 #define CREATE_OPCODE_WAIT_EVENT 158
00061
00062
00063 #define CREATE_DELAY_MODECHANGE_MS 20
00064
00065 #define CREATE_MODE_OFF 0
00066 #define CREATE_MODE_PASSIVE 1
00067 #define CREATE_MODE_SAFE 2
00068 #define CREATE_MODE_FULL 3
00069
00070 #define CREATE_TVEL_MAX_MM_S 500
00071 #define CREATE_RADIUS_MAX_MM 2000
00072
00073 #define CREATE_SENSOR_PACKET_SIZE 26
00074
00075 #define CREATE_CHARGING_NOT 0
00076 #define CREATE_CHARGING_RECOVERY 1
00077 #define CREATE_CHARGING_CHARGING 2
00078 #define CREATE_CHARGING_TRICKLE 3
00079 #define CREATE_CHARGING_WAITING 4
00080 #define CREATE_CHARGING_ERROR 5
00081
00082 #define CREATE_AXLE_LENGTH 0.258
00083
00084 #define CREATE_DIAMETER 0.33
00085
00086 #define CREATE_BUMPER_XOFFSET 0.05
00087
00088 #ifndef MIN
00089 #define MIN(a,b) ((a < b) ? (a) : (b))
00090 #endif
00091 #ifndef MAX
00092 #define MAX(a,b) ((a > b) ? (a) : (b))
00093 #endif
00094 #ifndef NORMALIZE
00095 #define NORMALIZE(z) atan2(sin(z), cos(z))
00096 #endif
00097
00098 typedef struct
00099 {
00100
00101 char serial_port[PATH_MAX];
00102
00103
00104 int fd;
00105
00106 unsigned char mode;
00107
00108 double ox, oy, oa;
00109
00110
00111 int bumper_left, bumper_right;
00112 unsigned char wheeldrop_caster, wheeldrop_left, wheeldrop_right;
00113 unsigned char wall;
00114 unsigned char cliff_left, cliff_frontleft, cliff_frontright, cliff_right;
00115 unsigned char virtual_wall;
00116 unsigned char overcurrent_driveleft, overcurrent_driveright;
00117 unsigned char overcurrent_mainbrush, overcurrent_sidebrush;
00118 unsigned char overcurrent_vacuum;
00119 unsigned char dirtdetector_right, dirtdetector_left;
00120 unsigned char remote_opcode;
00121 unsigned char button_power, button_spot, button_clean, button_max;
00122
00123
00124 unsigned char charging_state;
00125
00126 double voltage;
00127
00128 double current;
00129
00130 double temperature;
00131
00132 double charge;
00133
00134 double capacity;
00135 } create_comm_t;
00136
00137 create_comm_t* create_create(const char* serial_port);
00138 void create_destroy(create_comm_t* r);
00139 int create_open(create_comm_t* r, unsigned char fullcontrol);
00140 int create_init(create_comm_t* r, unsigned char fullcontrol);
00141 int create_close(create_comm_t* r);
00142 int create_set_speeds(create_comm_t* r, double tv, double rv);
00143 int create_parse_sensor_packet(create_comm_t* r,
00144 unsigned char* buf, size_t buflen);
00145 int create_get_sensors(create_comm_t* r, int timeout);
00146 void create_print(create_comm_t* r);
00147
00148 int create_set_song(create_comm_t* r, unsigned char songNumber,
00149 unsigned char songLength, unsigned char *notes,
00150 unsigned char *noteLengths);
00151 int create_play_song(create_comm_t *r, unsigned char songNumber);
00152
00153 int create_vacuum(create_comm_t *r, int state);
00154 int create_set_leds(create_comm_t *r, uint8_t dirt_detect, uint8_t max,
00155 uint8_t clean, uint8_t spot, uint8_t status,
00156 uint8_t power_color, uint8_t power_intensity );
00157
00158 int create_run_demo(create_comm_t *r, uint8_t num);
00159
00160 #ifdef __cplusplus
00161 }
00162 #endif
00163
00164 #endif
00165