23 #ifndef __PLUGINS_ROOMBA_ROOMBA_500_H_ 24 #define __PLUGINS_ROOMBA_ROOMBA_500_H_ 26 #include <core/plugin.h> 46 FLAG_FIREFLY_FASTMODE = 1
66 OPCODE_SEEK_DOCK = 143,
67 OPCODE_PWM_MOTORS = 144,
68 OPCODE_DRIVE_WHEELS = 145,
69 OPCODE_DRIVE_PWM = 146,
71 OPCODE_QUERY_LIST = 149,
72 OPCODE_PAUSE_RESUME_STREAM = 150,
73 OPCODE_SCHEDULE_LEDS = 162,
74 OPCODE_DIGIT_LEDS_RAW = 163,
75 OPCODE_DIGIT_LEDS_ASCII = 164,
77 OPCODE_SCHEDULE = 167,
78 OPCODE_SET_DAY_TIME = 168
83 SENSPACK_BUMPS_DROPS = 7,
85 SENSPACK_CLIFF_LEFT = 9,
86 SENSPACK_CLIFF_FRONT_LEFT = 10,
87 SENSPACK_CLIFF_FRONT_RIGHT = 11,
88 SENSPACK_CLIFF_RIGHT = 12,
89 SENSPACK_VIRTUAL_WALL = 13,
90 SENSPACK_WHEEL_OVERCURRENTS = 14,
91 SENSPACK_DIRT_DETECT = 15,
92 SENSPACK_IR_CHAR_OMNI = 17,
93 SENSPACK_BUTTONS = 18,
94 SENSPACK_DISTANCE = 19,
96 SENSPACK_CHARGING_STATE = 21,
97 SENSPACK_VOLTAGE = 22,
98 SENSPACK_CURRENT = 23,
99 SENSPACK_TEMPERATURE = 24,
100 SENSPACK_BATTERY_CHARGE = 25,
101 SENSPACK_BATTERY_CAPACITY = 26,
102 SENSPACK_WALL_SIGNAL = 27,
103 SENSPACK_CLIFF_LEFT_SIGNAL = 28,
104 SENSPACK_CLIFF_FRONT_LEFT_SIGNAL = 29,
105 SENSPACK_CLIFF_FRONT_RIGHT_SIGNAL = 30,
106 SENSPACK_CLIFF_RIGHT_SIGNAL = 31,
107 SENSPACK_CHARGE_SOURCES = 34,
108 SENSPACK_OI_MODE = 35,
109 SENSPACK_SONG_NUMBER = 36,
110 SENSPACK_SONG_PLAYING = 37,
111 SENSPACK_STREAM_PACKETS = 38,
112 SENSPACK_REQ_VELOCITY = 39,
113 SENSPACK_REQ_RADIUS = 40,
114 SENSPACK_REQ_RIGHT_VELOCITY = 41,
115 SENSPACK_REQ_LEFT_VELOCITY = 42,
116 SENSPACK_RIGHT_ENCODER = 43,
117 SENSPACK_LEFT_ENCODER = 44,
118 SENSPACK_LIGHT_BUMPER = 45,
119 SENSPACK_LIGHT_BUMPER_LEFT = 46,
120 SENSPACK_LIGHT_BUMPER_FRONT_LEFT = 47,
121 SENSPACK_LIGHT_BUMPER_CENTER_LEFT = 48,
122 SENSPACK_LIGHT_BUMPER_CENTER_RIGHT = 49,
123 SENSPACK_LIGHT_BUMPER_FRONT_RIGHT = 50,
124 SENSPACK_LIGHT_BUMPER_RIGHT = 51,
125 SENSPACK_IR_CHAR_LEFT = 52,
126 SENSPACK_IR_CHAR_RIGHT = 53,
127 SENSPACK_LEFT_MOTOR_CURRENT = 54,
128 SENSPACK_RIGHT_MOTOR_CURRENT = 55,
129 SENSPACK_BRUSH_MOTOR_CURRENT = 56,
130 SENSPACK_SIDE_BRUSH_MOTOR_CURRENT = 57,
131 SENSPACK_STASIS = 58,
134 SENSPACK_GROUP_0 = 0,
135 SENSPACK_GROUP_1 = 1,
136 SENSPACK_GROUP_2 = 2,
137 SENSPACK_GROUP_3 = 3,
138 SENSPACK_GROUP_4 = 4,
139 SENSPACK_GROUP_5 = 5,
140 SENSPACK_GROUP_6 = 6,
141 SENSPACK_GROUP_ALL = 100,
142 SENSPACK_GROUP_101 = 101,
143 SENSPACK_GROUP_106 = 106,
144 SENSPACK_GROUP_107 = 107,
164 CHARGING_RECONDITIONING = 1,
166 CHARGING_TRICKLE = 3,
167 CHARGING_WAITING = 4,
173 IR_REMOTE_LEFT = 129,
174 IR_REMOTE_FORWARD = 130,
175 IR_REMOTE_RIGHT = 131,
176 IR_REMOTE_SPOT = 132,
178 IR_REMOTE_SMALL = 134,
179 IR_REMOTE_MEDIUM = 135,
180 IR_REMOTE_LARGE_CLEAN = 136,
181 IR_REMOTE_STOP = 137,
182 IR_REMOTE_POWER = 138,
183 IR_REMOTE_ARC_LEFT = 139,
184 IR_REMOTE_ARC_RIGHT = 140,
185 IR_REMOTE_STOP2 = 141,
186 IR_SCHED_REMOTE_DOWNLOAD = 142,
187 IR_SCHED_REMOTE_SEEK_DOCK = 143,
189 IR_DISC_DOCK_RESERVED = 240,
190 IR_DISC_DOCK_RED_BUOY = 248,
191 IR_DISC_DOCK_GREEN_BUOY = 244,
192 IR_DISC_DOCK_FORCE_FIELD = 242,
194 IR_DISC_DOCK_RED_GREEN_BUOY = 252,
196 IR_DISC_DOCK_RED_BUOY_FORCE_FIELD = 250,
198 IR_DISC_DOCK_GREEN_BUOY_FORCE_FIELD = 246,
200 IR_DISC_DOCK_RED_GREEN_BUOY_FORCE_FIELD = 254,
202 IR_DOCK_RESERVED = 160,
203 IR_DOCK_RED_BUOY = 168,
204 IR_DOCK_GREEN_BUOY = 164,
205 IR_DOCK_FORCE_FIELD = 161,
206 IR_DOCK_RED_GREEN_BUOY = 172,
208 IR_DOCK_RED_BUOY_FORCE_FIELD = 169,
210 IR_DOCK_GREEN_BUOY_FORCE_FIELD = 165,
212 IR_DOCK_RED_GREEN_BUOY_FORCE_FIELD = 173,
214 IR_VIRTUAL_WALL = 162
231 TURN_COUNTER_CLOCKWISE
301 static const unsigned short int SENSPACK_SIZE_GROUP_0;
302 static const unsigned short int SENSPACK_SIZE_GROUP_1;
303 static const unsigned short int SENSPACK_SIZE_GROUP_2;
304 static const unsigned short int SENSPACK_SIZE_GROUP_3;
305 static const unsigned short int SENSPACK_SIZE_GROUP_4;
306 static const unsigned short int SENSPACK_SIZE_GROUP_5;
307 static const unsigned short int SENSPACK_SIZE_GROUP_6;
308 static const unsigned short int SENSPACK_SIZE_GROUP_ALL;
309 static const unsigned short int SENSPACK_SIZE_GROUP_101;
310 static const unsigned short int SENSPACK_SIZE_GROUP_106;
311 static const unsigned short int SENSPACK_SIZE_GROUP_107;
312 static const unsigned short int SENSPACK_SIZE_BUMPS_DROPS;
313 static const unsigned short int SENSPACK_SIZE_WALL;
314 static const unsigned short int SENSPACK_SIZE_CLIFF_LEFT;
315 static const unsigned short int SENSPACK_SIZE_CLIFF_FRONT_LEFT;
316 static const unsigned short int SENSPACK_SIZE_CLIFF_FRONT_RIGHT;
317 static const unsigned short int SENSPACK_SIZE_CLIFF_RIGHT;
318 static const unsigned short int SENSPACK_SIZE_VIRTUAL_WALL;
319 static const unsigned short int SENSPACK_SIZE_WHEEL_OVERCURRENTS;
320 static const unsigned short int SENSPACK_SIZE_DIRT_DETECT;
321 static const unsigned short int SENSPACK_SIZE_IR_CHAR_OMNI;
322 static const unsigned short int SENSPACK_SIZE_IR_CHAR_LEFT;
323 static const unsigned short int SENSPACK_SIZE_IR_CHAR_RIGHT;
324 static const unsigned short int SENSPACK_SIZE_BUTTONS;
325 static const unsigned short int SENSPACK_SIZE_DISTANCE;
326 static const unsigned short int SENSPACK_SIZE_ANGLE;
327 static const unsigned short int SENSPACK_SIZE_CHARGING_STATE;
328 static const unsigned short int SENSPACK_SIZE_VOLTAGE;
329 static const unsigned short int SENSPACK_SIZE_CURRENT;
330 static const unsigned short int SENSPACK_SIZE_TEMPERATURE;
331 static const unsigned short int SENSPACK_SIZE_BATTERY_CHARGE;
332 static const unsigned short int SENSPACK_SIZE_BATTERY_CAPACITY;
333 static const unsigned short int SENSPACK_SIZE_WALL_SIGNAL;
334 static const unsigned short int SENSPACK_SIZE_CLIFF_LEFT_SIGNAL;
335 static const unsigned short int SENSPACK_SIZE_CLIFF_FRONT_LEFT_SIGNAL;
336 static const unsigned short int SENSPACK_SIZE_CLIFF_FRONT_RIGHT_SIGNAL;
337 static const unsigned short int SENSPACK_SIZE_CLIFF_RIGHT_SIGNAL;
338 static const unsigned short int SENSPACK_SIZE_CHARGE_SOURCES;
339 static const unsigned short int SENSPACK_SIZE_OI_MODE;
340 static const unsigned short int SENSPACK_SIZE_SONG_NUMBER;
341 static const unsigned short int SENSPACK_SIZE_SONG_PLAYING;
342 static const unsigned short int SENSPACK_SIZE_STREAM_PACKETS;
343 static const unsigned short int SENSPACK_SIZE_REQ_VELOCITY;
344 static const unsigned short int SENSPACK_SIZE_REQ_RADIUS;
345 static const unsigned short int SENSPACK_SIZE_REQ_RIGHT_VELOCITY;
346 static const unsigned short int SENSPACK_SIZE_REQ_LEFT_VELOCITY;
347 static const unsigned short int SENSPACK_SIZE_RIGHT_ENCODER;
348 static const unsigned short int SENSPACK_SIZE_LEFT_ENCODER;
349 static const unsigned short int SENSPACK_SIZE_LIGHT_BUMPER;
350 static const unsigned short int SENSPACK_SIZE_LIGHT_BUMPER_LEFT;
351 static const unsigned short int SENSPACK_SIZE_LIGHT_BUMPER_FRONT_LEFT;
352 static const unsigned short int SENSPACK_SIZE_LIGHT_BUMPER_CENTER_LEFT;
353 static const unsigned short int SENSPACK_SIZE_LIGHT_BUMPER_CENTER_RIGHT;
354 static const unsigned short int SENSPACK_SIZE_LIGHT_BUMPER_FRONT_RIGHT;
355 static const unsigned short int SENSPACK_SIZE_LIGHT_BUMPER_RIGHT;
356 static const unsigned short int SENSPACK_SIZE_LEFT_MOTOR_CURRENT;
357 static const unsigned short int SENSPACK_SIZE_RIGHT_MOTOR_CURRENT;
358 static const unsigned short int SENSPACK_SIZE_BRUSH_MOTOR_CURRENT;
359 static const unsigned short int SENSPACK_SIZE_SIDE_BRUSH_MOTOR_CURRENT;
360 static const unsigned short int SENSPACK_SIZE_STASIS;
438 Roomba500(ConnectionType conntype,
const char *device,
unsigned int flags = 0);
462 {
return is_connected() && ( (__mode == MODE_SAFE) || (__mode == MODE_FULL) ); }
464 void set_mode(
Mode mode);
470 void drive_straight(
short int velo_mm_per_sec);
471 void drive_turn(TurnDirection direction);
472 void drive_arc(
short int velo_mm_per_sec,
short int radius_mm);
473 void drive(
short int velocity_mm_per_sec,
short int radius_mm);
474 void drive_direct(
short int left_mm_per_sec,
short int right_mm_per_sec);
475 void drive_pwm(
short int left_wheel_pwm,
short int right_wheel_pwm);
476 void set_motors(
bool main =
true,
bool side =
true,
bool vacuum =
true,
477 bool main_backward =
false,
bool side_backward =
false);
478 void set_leds(
bool debris,
bool spot,
bool dock,
bool check_robot,
479 unsigned char clean_color,
unsigned char clean_intensity);
481 void set_digit_leds(
const char digits[4]);
483 void enable_sensors();
484 void disable_sensors();
485 bool is_data_available();
487 void query_sensors();
492 {
return __sensor_packet_received; };
501 const void *params = NULL,
const size_t plength = 0);
502 void recv(
size_t index,
size_t num_bytes,
unsigned int timeout_ms = 0);
504 void assert_control()
506 if ((__mode != MODE_FULL) && (__mode != MODE_SAFE)) {
510 void assert_connected()
514 ConnectionType __conntype;
515 unsigned int __conn_flags;
519 unsigned char __packet_reply_id;
520 unsigned short __packet_length;
521 bool __sensors_enabled;
523 bool __sensor_packet_received;
531 unsigned char __obuffer[16];
532 unsigned char __ibuffer[82];
534 int __obuffer_length;
535 int __ibuffer_length;
uint8_t cliff_front_left
Front left cliff sensor.
static const unsigned short int STREAM_INTERVAL_MS
Time in ms between.
static const unsigned char MOTOR_SIDE_BRUSH
Side brush motor bit.
ScheduleDay
Days for scheduler.
bool has_sensor_packet() const
Check if sensor packet is availabe.
static const unsigned char CHARGER_HOME_BASE
Home base charger bit.
static const unsigned char OVERCURRENT_WHEEL_RIGHT
Right wheel bit.
static const unsigned char CHARGING_SOURCE_INTERNAL
Internal socket.
uint8_t stasis
Castor stasis.
uint8_t cliff_front_right
Front right cliff sensor.
bool is_controlled() const
Check if robot is being controlled.
static const short int MAX_LIN_VEL_MM_S
Maximum linear velocity.
static const unsigned char BUMPER_CENTER_RIGHT
Center right bumper.
static const unsigned char WEEKDAY_LED_THU
Thursday.
static const unsigned char WHEEL_DROP_RIGHT
Right wheel drop bit.
uint8_t overcurrents
Overcurrents bits.
static const unsigned char BUTTON_DAY
Day button.
static const unsigned char WHEEL_DROP_LEFT
Left wheel drop bit.
static const unsigned short int MODE_CHANGE_WAIT_MS
Time in ms to wait after mode changes.
static const short int MAX_RADIUS_MM
Maximum drive radius.
static const unsigned char CHECKSUM_SIZE
Checksum byte size.
static const short int MAX_PWM
Maximum PWM value for wheels.
int16_t velocity_left
Velocity of left wheel in mm/sec.
static const unsigned char LED_DEBRIS
Debris LED bit.
static const float DIAMETER
Robot diameter.
Fawkes library namespace.
const char * get_device() const
Get device string.
uint8_t unused_1
Unused byte.
int16_t angle
Turned angle in degree.
static const unsigned char LED_SPOT
Spot LED bit.
uint8_t mode
Open Interface mode.
static const float BUMPER_X_OFFSET
X Offset of bumper.
uint16_t battery_capacity
Battery capacity in mAh.
static const unsigned char BUTTON_CLEAN
Cleaning button.
static const unsigned char SCHEDULING_LED_PM
PM LED bit.
int16_t radius
Radius in mm.
static const unsigned char DIGIT_LED_NORTH_EAST
Top right segment LED.
static const unsigned char BUTTON_DOCK
Dock button.
uint8_t stream_num_packets
Number of streamed packets.
static const unsigned char BUTTON_HOUR
Hour button.
static const unsigned char BUMPER_LEFT
Left bumper.
static const unsigned char MOTOR_SIDE_BRUSH_BACKWARD
Side backward bit.
static const unsigned char DIGIT_LED_NORTH_WEST
Top left segment LED.
static const unsigned char BUMPER_FRONT_LEFT
Front left bumper.
Use serial connection (device file).
uint16_t encoder_counts_left
Encoder counts for left wheel.
static const unsigned char SCHEDULING_LED_AM
AM LED bit.
uint8_t ir_opcode_left
Left IR receiver character.
uint8_t ir_opcode_omni
Omni IR receiver character.
static const unsigned char DIGIT_LED_SOUTH_EAST
Bottom right segment.
int16_t current
Current in mA.
static const unsigned char LED_CHECK_ROBOT
Check robot LED bit.
int16_t right_motor_current
Raw right motor current signal.
Mode get_mode() const
Get current mode.
uint16_t light_bump_front_right
Raw front right light bumper signal.
static const unsigned char LED_DOCK
Dock LED bit.
uint8_t cliff_left
Left cliff sensor.
Mode
Roomba 500 operation mode.
static const unsigned short int MAX_ENCODER_COUNT
Maximum encoder count.
uint16_t light_bump_center_left
Raw center left light bumper signal.
uint8_t virtual_wall
Wall sensor.
static const unsigned char SCHEDULING_LED_SCHEDULE
Schedule LED bit.
static const unsigned char BUMPER_CENTER_LEFT
Center left bumper.
uint8_t song_number
Song number.
static const unsigned char BUTTON_SPOT
Spot cleaning button.
static const unsigned char OVERCURRENT_WHEEL_LEFT
Left wheel bit.
SensorPacketID
Roomba 500 sensor package IDs.
uint8_t light_bumper
Light bumper bits.
static const unsigned char MOTOR_MAIN_BRUSHES_BACKWARD
Main backward bit.
static const unsigned char CHARGER_INTERNAL
Internal charger bit.
uint16_t light_bump_right
Raw right light bumper signal.
static const unsigned char OVERCURRENT_MAIN_BRUSH
Main brush bit.
Base class for exceptions in Fawkes.
ConnectionType
Connection type.
static const unsigned char DIGIT_LED_CENTER
Center segment LED.
static const unsigned char BUTTON_SCHEDULE
Schedule button.
bool is_connected() const
Check if connection has been established.
int16_t velocity
Velocity in mm/sec.
uint16_t light_bump_center_right
Raw center right light bumper signal.
static const unsigned char WEEKDAY_LED_FRI
Friday.
StreamState
Sensor stream state.
static const unsigned char BUTTON_CLOCK
Clock button.
static const unsigned char WEEKDAY_LED_SAT
Saturday.
uint8_t buttons
Buttons bits.
static const unsigned char BUTTON_MINUTE
Minute button.
uint8_t charging_state
Charging state.
int16_t left_motor_current
Raw left motor current signal.
int16_t main_brush_current
Raw main brush motor current signal.
uint16_t cliff_front_right_signal
Raw front right cliff signal.
static const unsigned char SCHEDULING_LED_CLOCK
Clock LED bit.
int16_t side_brush_current
Raw side brush motor current signal.
uint8_t unused_2
Unused byte.
static const unsigned char MOTOR_MAIN_BRUSHES
Main brush motor bit.
uint16_t light_bump_front_left
Raw front left light bumper signal.
ConnectionFlags
Connection flags.
static const unsigned char WEEKDAY_LED_TUE
Tuesday.
uint16_t battery_charge
Battery charge in mAh.
static const unsigned char OVERCURRENT_SIDE_BRUSH
Side brush bit.
uint16_t unused_3
Unused byte.
static const unsigned char WEEKDAY_LED_WED
Wednesday.
uint16_t cliff_right_signal
Raw right cliff signal.
static const unsigned char BUMPER_RIGHT
Right bumper.
uint16_t wall_signal
Raw wall signal.
int16_t velocity_right
Velocity of right wheel in mm/sec.
ConnectionType get_connection_type() const
Get connection type.
uint8_t charger_available
Available chargers bits.
static const unsigned char DIGIT_LED_SOUTH
Bottom segment LED.
uint8_t song_playing
Song playing byte.
uint8_t wall
Wall sensor value.
uint8_t cliff_right
Right cliff sensor.
static const unsigned char WEEKDAY_LED_MON
Monday.
ChargingState
Charging state.
int16_t distance
Traveled distance in mm.
uint16_t cliff_left_signal
Raw left cliff signal.
static const unsigned char DIGIT_LED_NORTH
Top segment LED.
uint8_t bumps_wheeldrops
Bumps and wheeldrops bits.
InfraredCharacter
Infrared character values.
Roomba 500 series communication class.
Struct for packet group with everything (SENSPACK_GROUP_ALL).
Mutex mutual exclusion lock.
static const unsigned char BUMP_RIGHT
Right bumper bit.
static const unsigned char CHARGING_SOURCE_HOME_BASE
Docking station.
uint16_t encoder_counts_right
Encoder counts for right wheel.
int8_t temperature
Temperature in deg C.
static const unsigned char BUMPER_FRONT_RIGHT
Front right bumper.
uint16_t light_bump_left
Raw left light bumper signal.
static const unsigned char MOTOR_VACUUM
Vacuum motor bit.
uint16_t voltage
Voltage in mV.
OpCode
Roomba 500 Command op codes.
static const unsigned char DIGIT_LED_SOUTH_WEST
Bottom left segment.
TurnDirection
Turning direction.
uint16_t cliff_front_left_signal
Raw front left cliff signal.
static const unsigned char SCHEDULING_LED_COLON
Colon LED bit.
static const unsigned char BUMP_LEFT
Left bumper bit.
static const unsigned char WEEKDAY_LED_SUN
Sunday.
uint8_t ir_opcode_right
Right IR receiver character.
uint8_t dirt_detect
Dirt detect sensor.
static const float AXLE_LENGTH
Axle length.