Fawkes API  Fawkes Development Version
roomba_500.h
1 
2 /***************************************************************************
3  * roomba_500.h - Roomba Open Interface implementation for 500 series
4  *
5  * Created: Sat Jan 01 19:13:38 2011
6  * Copyright 2006-2010 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Library General Public License for more details.
19  *
20  * Read the full text in the LICENSE.GPL file in the doc directory.
21  */
22 
23 #ifndef _PLUGINS_ROOMBA_ROOMBA_500_H_
24 #define _PLUGINS_ROOMBA_ROOMBA_500_H_
25 
26 #include <core/plugin.h>
27 #include <core/threading/mutex.h>
28 
29 #include <cstdint>
30 #include <string>
31 
32 class Roomba500
33 {
34 public:
35  /** Connection type. */
36  typedef enum {
37  CONNTYPE_SERIAL, ///< Use serial connection (device file).
38  CONNTYPE_ROOTOOTH ///< Use BlueZ to find and connect to RooTooth
40 
41  /** Connection flags.
42  * These flags allow to influence the connection creation and operation. */
43  typedef enum {
44  FLAG_FIREFLY_FASTMODE = 1 ///< Enable fast mode, assume FireFly RooTooth
46 
47  /** Roomba 500 Command op codes. */
48  typedef enum {
49  OPCODE_START = 128, ///< Initiate communication with Roomba.
50  OPCODE_BAUD = 129, ///< Set baud rate.
51  OPCODE_CONTROL = 130, ///< Old alias for SAFE.
52  OPCODE_SAFE = 131, ///< Enter safe mode.
53  OPCODE_FULL = 132, ///< Enter full mode.
54  OPCODE_POWER = 133, ///< Power down Roomba.
55  OPCODE_SPOT = 134, ///< Start spot cleaning.
56  OPCODE_CLEAN = 135, ///< Start normal cleaning mission.
57  OPCODE_MAX = 136, ///< Start max cleaning mode.
58  OPCODE_DRIVE = 137, ///< Drive robot.
59  OPCODE_MOTORS = 138, ///< Set motor state.
60  OPCODE_LEDS = 139, ///< Control LEDs.
61  OPCODE_SONG = 140, ///< Register song.
62  OPCODE_PLAY = 141, ///< Play song.
63  OPCODE_QUERY = 142, ///< Query sensor info.
64  OPCODE_SEEK_DOCK = 143, ///< Start seeking dock.
65  OPCODE_PWM_MOTORS = 144, ///< PWM control of motors.
66  OPCODE_DRIVE_WHEELS = 145, ///< Drive wheels.
67  OPCODE_DRIVE_PWM = 146, ///< Drive by PWM.
68  OPCODE_STREAM = 148, ///< Start streaming of data.
69  OPCODE_QUERY_LIST = 149, ///< Query multiple sensor packets.
70  OPCODE_PAUSE_RESUME_STREAM = 150, ///< Pause or resume streaming data.
71  OPCODE_SCHEDULE_LEDS = 162, ///< Control schedule LEDs.
72  OPCODE_DIGIT_LEDS_RAW = 163, ///< Raw control of digit LEDs.
73  OPCODE_DIGIT_LEDS_ASCII = 164, ///< Ascii control of digit LEDs.
74  OPCODE_BUTTONS = 165, ///< Control buttons.
75  OPCODE_SCHEDULE = 167, ///< Manipulate schedule.
76  OPCODE_SET_DAY_TIME = 168 ///< Set day and time.
77  } OpCode;
78 
79  /** Roomba 500 sensor package IDs. */
80  typedef enum {
81  SENSPACK_BUMPS_DROPS = 7, ///< Bumper and wheel drops.
82  SENSPACK_WALL = 8, ///< Wall sensor.
83  SENSPACK_CLIFF_LEFT = 9, ///< Left cliff sensor.
84  SENSPACK_CLIFF_FRONT_LEFT = 10, ///< Front left cliff sensor.
85  SENSPACK_CLIFF_FRONT_RIGHT = 11, ///< Front right cliff sensor.
86  SENSPACK_CLIFF_RIGHT = 12, ///< Right cliff sensor.
87  SENSPACK_VIRTUAL_WALL = 13, ///< Virtual wall detector.
88  SENSPACK_WHEEL_OVERCURRENTS = 14, ///< Overcurrents.
89  SENSPACK_DIRT_DETECT = 15, ///< Dirt detection sensor.
90  SENSPACK_IR_CHAR_OMNI = 17, ///< Omnidirectional IR receiver.
91  SENSPACK_BUTTONS = 18, ///< Button status.
92  SENSPACK_DISTANCE = 19, ///< Travelled distance.
93  SENSPACK_ANGLE = 20, ///< Turned angle.
94  SENSPACK_CHARGING_STATE = 21, ///< Charging state.
95  SENSPACK_VOLTAGE = 22, ///< Voltage.
96  SENSPACK_CURRENT = 23, ///< Current.
97  SENSPACK_TEMPERATURE = 24, ///< Temperature.
98  SENSPACK_BATTERY_CHARGE = 25, ///< Battery charge.
99  SENSPACK_BATTERY_CAPACITY = 26, ///< Battery capacity.
100  SENSPACK_WALL_SIGNAL = 27, ///< Wall signal value.
101  SENSPACK_CLIFF_LEFT_SIGNAL = 28, ///< Left cliff signal value.
102  SENSPACK_CLIFF_FRONT_LEFT_SIGNAL = 29, ///< Front left cliff signal value.
103  SENSPACK_CLIFF_FRONT_RIGHT_SIGNAL = 30, ///< Right cliff signal value.
104  SENSPACK_CLIFF_RIGHT_SIGNAL = 31, ///<Front right cliff signal value.
105  SENSPACK_CHARGE_SOURCES = 34, ///< Available charge sources.
106  SENSPACK_OI_MODE = 35, ///< Open Interface mode.
107  SENSPACK_SONG_NUMBER = 36, ///< Song number.
108  SENSPACK_SONG_PLAYING = 37, ///< Song playing indicator.
109  SENSPACK_STREAM_PACKETS = 38, ///< Number of stream packets.
110  SENSPACK_REQ_VELOCITY = 39, ///< Requested velocity.
111  SENSPACK_REQ_RADIUS = 40, ///< Requested radius.
112  SENSPACK_REQ_RIGHT_VELOCITY = 41, ///< Requested right velocity.
113  SENSPACK_REQ_LEFT_VELOCITY = 42, ///< Requested left velocity.
114  SENSPACK_RIGHT_ENCODER = 43, ///< Right encoder value.
115  SENSPACK_LEFT_ENCODER = 44, ///< Left encoder value.
116  SENSPACK_LIGHT_BUMPER = 45, ///< Light bumper status.
117  SENSPACK_LIGHT_BUMPER_LEFT = 46, ///< Left bumper signal.
118  SENSPACK_LIGHT_BUMPER_FRONT_LEFT = 47, ///< Front left bumper signal.
119  SENSPACK_LIGHT_BUMPER_CENTER_LEFT = 48, ///< Center left bumper signal.
120  SENSPACK_LIGHT_BUMPER_CENTER_RIGHT = 49, ///< Center right bumper signal.
121  SENSPACK_LIGHT_BUMPER_FRONT_RIGHT = 50, ///< Front right bumper signal.
122  SENSPACK_LIGHT_BUMPER_RIGHT = 51, ///< Right bumper signal.
123  SENSPACK_IR_CHAR_LEFT = 52, ///< Left IR character.
124  SENSPACK_IR_CHAR_RIGHT = 53, ///< Right IR character.
125  SENSPACK_LEFT_MOTOR_CURRENT = 54, ///< Left motor current.
126  SENSPACK_RIGHT_MOTOR_CURRENT = 55, ///< Right motor current.
127  SENSPACK_BRUSH_MOTOR_CURRENT = 56, ///< Brush motor current.
128  SENSPACK_SIDE_BRUSH_MOTOR_CURRENT = 57, ///< Side brush motor current.
129  SENSPACK_STASIS = 58, ///< Caster wheel stasis (forward
130  ///< movement)
131 
132  SENSPACK_GROUP_0 = 0, ///< Packet IDs 7-26
133  SENSPACK_GROUP_1 = 1, ///< Packet IDs 7-16
134  SENSPACK_GROUP_2 = 2, ///< Packet IDs 17-20
135  SENSPACK_GROUP_3 = 3, ///< Packet IDs 21-26
136  SENSPACK_GROUP_4 = 4, ///< Packet IDs 27-34
137  SENSPACK_GROUP_5 = 5, ///< Packet IDs 35-42
138  SENSPACK_GROUP_6 = 6, ///< Packet IDs 7-42
139  SENSPACK_GROUP_ALL = 100, ///< All packet IDs (7-58)
140  SENSPACK_GROUP_101 = 101, ///< Packet IDs 43-58
141  SENSPACK_GROUP_106 = 106, ///< Packet IDs 46-51
142  SENSPACK_GROUP_107 = 107, ///< Packet IDs 54-58
143  } SensorPacketID;
144 
145  /** Roomba 500 operation mode. */
146  typedef enum {
147  MODE_OFF = 0, ///< No connection.
148  MODE_PASSIVE = 1, ///< Passive mode, no control, only listening.
149  MODE_SAFE = 2, ///< Control acquired, safety measures in place.
150  MODE_FULL = 3 ///< Control acquired, safety measures disabled.
151  } Mode;
152 
153  /** Sensor stream state. */
154  typedef enum {
155  STREAM_ENABLE = 1, ///< Stream enabled.
156  STREAM_DISABLE = 0 ///< Stream disabled.
158 
159  /** Charging state. */
160  typedef enum {
161  CHARGING_NO = 0, ///< Not charging.
162  CHARGING_RECONDITIONING = 1, ///< Reconditioning battery.
163  CHARGING_FULL = 2, ///< Full charging cycle.
164  CHARGING_TRICKLE = 3, ///< Trickle charging.
165  CHARGING_WAITING = 4, ///< Waiting.
166  CHARGING_ERROR = 5 ///< Fault condition.
168 
169  /** Infrared character values. */
170  typedef enum {
171  IR_REMOTE_LEFT = 129, ///< IR Remote Control: left button
172  IR_REMOTE_FORWARD = 130, ///< IR Remote Control: forward button
173  IR_REMOTE_RIGHT = 131, ///< IR Remote Control: right button
174  IR_REMOTE_SPOT = 132, ///< IR Remote Control: spot button
175  IR_REMOTE_MAX = 133, ///< IR Remote Control: max button
176  IR_REMOTE_SMALL = 134, ///< IR Remote Control: small button
177  IR_REMOTE_MEDIUM = 135, ///< IR Remote Control: medium button
178  IR_REMOTE_LARGE_CLEAN = 136, ///< IR Remote Control: large/clean button
179  IR_REMOTE_STOP = 137, ///< IR Remote Control: stop button
180  IR_REMOTE_POWER = 138, ///< IR Remote Control: power button
181  IR_REMOTE_ARC_LEFT = 139, ///< IR Remote Control: left arc button
182  IR_REMOTE_ARC_RIGHT = 140, ///< IR Remote Control: right arc button
183  IR_REMOTE_STOP2 = 141, ///< IR Remote Control: stop button
184  IR_SCHED_REMOTE_DOWNLOAD = 142, ///< IR scheduling remote: download button
185  IR_SCHED_REMOTE_SEEK_DOCK = 143, ///< IR scheduling remote: seek dock button
186  // just for completeness
187  IR_DISC_DOCK_RESERVED = 240, ///< Roomba Discovery dock: reserved
188  IR_DISC_DOCK_RED_BUOY = 248, ///< Roomba Discovery dock: red buoy
189  IR_DISC_DOCK_GREEN_BUOY = 244, ///< Roomba Discovery dock: green buoy
190  IR_DISC_DOCK_FORCE_FIELD = 242, ///< Roomba Discovery dock: red
191  ///< and green buoy
192  IR_DISC_DOCK_RED_GREEN_BUOY = 252, ///< Roomba Discovery dock: red
193  ///< buoy and force field
194  IR_DISC_DOCK_RED_BUOY_FORCE_FIELD = 250, ///< Roomba Discovery dock: green
195  ///< buoy and force field
196  IR_DISC_DOCK_GREEN_BUOY_FORCE_FIELD = 246, ///< Roomba Discovery dock: green
197  ///< buoy and force field.
198  IR_DISC_DOCK_RED_GREEN_BUOY_FORCE_FIELD = 254, ///< Roomba Discovery dock: red
199  ///< and green buoy and force field
200  IR_DOCK_RESERVED = 160, ///< Roomba 500 dock: reserved
201  IR_DOCK_RED_BUOY = 168, ///< Roomba 500 dock: red buoy
202  IR_DOCK_GREEN_BUOY = 164, ///< Roomba 500 dock: green buoy
203  IR_DOCK_FORCE_FIELD = 161, ///< Roomba 500 dock: red and green buoy
204  IR_DOCK_RED_GREEN_BUOY = 172, ///< Roomba 500 dock: red buoy and force
205  ///< field
206  IR_DOCK_RED_BUOY_FORCE_FIELD = 169, ///< Roomba 500 dock: green buoy
207  ///< and force field
208  IR_DOCK_GREEN_BUOY_FORCE_FIELD = 165, ///< Roomba 500 dock: green buoy
209  ///< and force field.
210  IR_DOCK_RED_GREEN_BUOY_FORCE_FIELD = 173, ///< Roomba 500 dock: red and
211  ///< green buoy and force field.
212  IR_VIRTUAL_WALL = 162 ///< IR Virtual Wall
214 
215  /** Days for scheduler. */
216  typedef enum {
217  DAY_SUNDAY = 0, ///< Sunday.
218  DAY_MONDAY = 1, ///< Monday.
219  DAY_TUESDAY = 2, ///< Tuesday.
220  DAY_WEDNESDAY = 3, ///< Wednesday.
221  DAY_THURSDAY = 4, ///< Thursday.
222  DAY_FRIDAY = 5, ///< Friday.
223  DAY_SATURDAY = 6 ///< Saturday.
225 
226  /** Turning direction. */
227  typedef enum {
228  TURN_CLOCKWISE, ///< Clockwise turning.
229  TURN_COUNTER_CLOCKWISE ///< Counter-Clockwise turning.
231 
232  static const unsigned char BUTTON_CLEAN; ///< Cleaning button.
233  static const unsigned char BUTTON_SPOT; ///< Spot cleaning button.
234  static const unsigned char BUTTON_DOCK; ///< Dock button.
235  static const unsigned char BUTTON_MINUTE; ///< Minute button.
236  static const unsigned char BUTTON_HOUR; ///< Hour button.
237  static const unsigned char BUTTON_DAY; ///< Day button.
238  static const unsigned char BUTTON_SCHEDULE; ///< Schedule button.
239  static const unsigned char BUTTON_CLOCK; ///< Clock button.
240 
241  static const unsigned char WHEEL_DROP_LEFT; ///< Left wheel drop bit.
242  static const unsigned char WHEEL_DROP_RIGHT; ///< Right wheel drop bit.
243  static const unsigned char BUMP_LEFT; ///< Left bumper bit.
244  static const unsigned char BUMP_RIGHT; ///< Right bumper bit.
245 
246  static const unsigned char OVERCURRENT_WHEEL_LEFT; ///< Left wheel bit.
247  static const unsigned char OVERCURRENT_WHEEL_RIGHT; ///< Right wheel bit.
248  static const unsigned char OVERCURRENT_MAIN_BRUSH; ///< Main brush bit.
249  static const unsigned char OVERCURRENT_SIDE_BRUSH; ///< Side brush bit.
250 
251  static const unsigned char CHARGING_SOURCE_HOME_BASE; ///< Docking station.
252  static const unsigned char CHARGING_SOURCE_INTERNAL; ///< Internal socket.
253 
254  static const unsigned char BUMPER_LEFT; ///< Left bumper.
255  static const unsigned char BUMPER_FRONT_LEFT; ///< Front left bumper.
256  static const unsigned char BUMPER_CENTER_LEFT; ///< Center left bumper.
257  static const unsigned char BUMPER_CENTER_RIGHT; ///< Center right bumper.
258  static const unsigned char BUMPER_FRONT_RIGHT; ///< Front right bumper.
259  static const unsigned char BUMPER_RIGHT; ///< Right bumper.
260 
261  static const unsigned char LED_DEBRIS; ///< Debris LED bit.
262  static const unsigned char LED_SPOT; ///< Spot LED bit.
263  static const unsigned char LED_DOCK; ///< Dock LED bit.
264  static const unsigned char LED_CHECK_ROBOT; ///< Check robot LED bit.
265 
266  static const unsigned char WEEKDAY_LED_SUN; ///< Sunday.
267  static const unsigned char WEEKDAY_LED_MON; ///< Monday.
268  static const unsigned char WEEKDAY_LED_TUE; ///< Tuesday.
269  static const unsigned char WEEKDAY_LED_WED; ///< Wednesday.
270  static const unsigned char WEEKDAY_LED_THU; ///< Thursday.
271  static const unsigned char WEEKDAY_LED_FRI; ///< Friday.
272  static const unsigned char WEEKDAY_LED_SAT; ///< Saturday.
273 
274  static const unsigned char SCHEDULING_LED_COLON; ///< Colon LED bit.
275  static const unsigned char SCHEDULING_LED_PM; ///< PM LED bit.
276  static const unsigned char SCHEDULING_LED_AM; ///< AM LED bit.
277  static const unsigned char SCHEDULING_LED_CLOCK; ///< Clock LED bit.
278  static const unsigned char SCHEDULING_LED_SCHEDULE; ///< Schedule LED bit.
279 
280  static const unsigned char DIGIT_LED_NORTH; ///< Top segment LED.
281  static const unsigned char DIGIT_LED_NORTH_WEST; ///< Top left segment LED.
282  static const unsigned char DIGIT_LED_NORTH_EAST; ///< Top right segment LED.
283  static const unsigned char DIGIT_LED_CENTER; ///< Center segment LED.
284  static const unsigned char DIGIT_LED_SOUTH_WEST; ///< Bottom left segment.
285  static const unsigned char DIGIT_LED_SOUTH_EAST; ///< Bottom right segment.
286  static const unsigned char DIGIT_LED_SOUTH; ///< Bottom segment LED.
287 
288  static const unsigned char MOTOR_SIDE_BRUSH; ///< Side brush motor bit.
289  static const unsigned char MOTOR_VACUUM; ///< Vacuum motor bit.
290  static const unsigned char MOTOR_MAIN_BRUSHES; ///< Main brush motor bit.
291  static const unsigned char MOTOR_SIDE_BRUSH_BACKWARD; ///< Side backward bit.
292  static const unsigned char MOTOR_MAIN_BRUSHES_BACKWARD; ///< Main backward bit.
293 
294  static const unsigned char CHARGER_HOME_BASE; ///< Home base charger bit.
295  static const unsigned char CHARGER_INTERNAL; ///< Internal charger bit.
296 
297  /// @cond OBVIOUS
298  static const unsigned short int SENSPACK_SIZE_GROUP_0;
299  static const unsigned short int SENSPACK_SIZE_GROUP_1;
300  static const unsigned short int SENSPACK_SIZE_GROUP_2;
301  static const unsigned short int SENSPACK_SIZE_GROUP_3;
302  static const unsigned short int SENSPACK_SIZE_GROUP_4;
303  static const unsigned short int SENSPACK_SIZE_GROUP_5;
304  static const unsigned short int SENSPACK_SIZE_GROUP_6;
305  static const unsigned short int SENSPACK_SIZE_GROUP_ALL;
306  static const unsigned short int SENSPACK_SIZE_GROUP_101;
307  static const unsigned short int SENSPACK_SIZE_GROUP_106;
308  static const unsigned short int SENSPACK_SIZE_GROUP_107;
309  static const unsigned short int SENSPACK_SIZE_BUMPS_DROPS;
310  static const unsigned short int SENSPACK_SIZE_WALL;
311  static const unsigned short int SENSPACK_SIZE_CLIFF_LEFT;
312  static const unsigned short int SENSPACK_SIZE_CLIFF_FRONT_LEFT;
313  static const unsigned short int SENSPACK_SIZE_CLIFF_FRONT_RIGHT;
314  static const unsigned short int SENSPACK_SIZE_CLIFF_RIGHT;
315  static const unsigned short int SENSPACK_SIZE_VIRTUAL_WALL;
316  static const unsigned short int SENSPACK_SIZE_WHEEL_OVERCURRENTS;
317  static const unsigned short int SENSPACK_SIZE_DIRT_DETECT;
318  static const unsigned short int SENSPACK_SIZE_IR_CHAR_OMNI;
319  static const unsigned short int SENSPACK_SIZE_IR_CHAR_LEFT;
320  static const unsigned short int SENSPACK_SIZE_IR_CHAR_RIGHT;
321  static const unsigned short int SENSPACK_SIZE_BUTTONS;
322  static const unsigned short int SENSPACK_SIZE_DISTANCE;
323  static const unsigned short int SENSPACK_SIZE_ANGLE;
324  static const unsigned short int SENSPACK_SIZE_CHARGING_STATE;
325  static const unsigned short int SENSPACK_SIZE_VOLTAGE;
326  static const unsigned short int SENSPACK_SIZE_CURRENT;
327  static const unsigned short int SENSPACK_SIZE_TEMPERATURE;
328  static const unsigned short int SENSPACK_SIZE_BATTERY_CHARGE;
329  static const unsigned short int SENSPACK_SIZE_BATTERY_CAPACITY;
330  static const unsigned short int SENSPACK_SIZE_WALL_SIGNAL;
331  static const unsigned short int SENSPACK_SIZE_CLIFF_LEFT_SIGNAL;
332  static const unsigned short int SENSPACK_SIZE_CLIFF_FRONT_LEFT_SIGNAL;
333  static const unsigned short int SENSPACK_SIZE_CLIFF_FRONT_RIGHT_SIGNAL;
334  static const unsigned short int SENSPACK_SIZE_CLIFF_RIGHT_SIGNAL;
335  static const unsigned short int SENSPACK_SIZE_CHARGE_SOURCES;
336  static const unsigned short int SENSPACK_SIZE_OI_MODE;
337  static const unsigned short int SENSPACK_SIZE_SONG_NUMBER;
338  static const unsigned short int SENSPACK_SIZE_SONG_PLAYING;
339  static const unsigned short int SENSPACK_SIZE_STREAM_PACKETS;
340  static const unsigned short int SENSPACK_SIZE_REQ_VELOCITY;
341  static const unsigned short int SENSPACK_SIZE_REQ_RADIUS;
342  static const unsigned short int SENSPACK_SIZE_REQ_RIGHT_VELOCITY;
343  static const unsigned short int SENSPACK_SIZE_REQ_LEFT_VELOCITY;
344  static const unsigned short int SENSPACK_SIZE_RIGHT_ENCODER;
345  static const unsigned short int SENSPACK_SIZE_LEFT_ENCODER;
346  static const unsigned short int SENSPACK_SIZE_LIGHT_BUMPER;
347  static const unsigned short int SENSPACK_SIZE_LIGHT_BUMPER_LEFT;
348  static const unsigned short int SENSPACK_SIZE_LIGHT_BUMPER_FRONT_LEFT;
349  static const unsigned short int SENSPACK_SIZE_LIGHT_BUMPER_CENTER_LEFT;
350  static const unsigned short int SENSPACK_SIZE_LIGHT_BUMPER_CENTER_RIGHT;
351  static const unsigned short int SENSPACK_SIZE_LIGHT_BUMPER_FRONT_RIGHT;
352  static const unsigned short int SENSPACK_SIZE_LIGHT_BUMPER_RIGHT;
353  static const unsigned short int SENSPACK_SIZE_LEFT_MOTOR_CURRENT;
354  static const unsigned short int SENSPACK_SIZE_RIGHT_MOTOR_CURRENT;
355  static const unsigned short int SENSPACK_SIZE_BRUSH_MOTOR_CURRENT;
356  static const unsigned short int SENSPACK_SIZE_SIDE_BRUSH_MOTOR_CURRENT;
357  static const unsigned short int SENSPACK_SIZE_STASIS;
358  /// @endcond
359 
360  static const float DIAMETER; ///< Robot diameter.
361  static const float BUMPER_X_OFFSET; ///< X Offset of bumper.
362  static const float AXLE_LENGTH; ///< Axle length.
363 
364  static const short int MAX_LIN_VEL_MM_S; ///< Maximum linear velocity.
365  static const short int MAX_RADIUS_MM; ///< Maximum drive radius.
366 
367  static const short int MAX_PWM; ///< Maximum PWM value for wheels.
368  static const unsigned short int MAX_ENCODER_COUNT; ///< Maximum encoder count.
369  static const unsigned short int STREAM_INTERVAL_MS; ///< Time in ms between
370  ///< streamed sensor packets.
371  static const unsigned short int MODE_CHANGE_WAIT_MS; ///< Time in ms to wait
372  ///< after mode changes
373 
374  static const unsigned char CHECKSUM_SIZE; ///< Checksum byte size.
375 
376 #pragma pack(push, 1)
377  /** Struct for packet group with everything (SENSPACK_GROUP_ALL). */
378  typedef struct
379  {
380  uint8_t bumps_wheeldrops; ///< Bumps and wheeldrops bits.
381  uint8_t wall; ///< Wall sensor value.
382  uint8_t cliff_left; ///< Left cliff sensor.
383  uint8_t cliff_front_left; ///< Front left cliff sensor.
384  uint8_t cliff_front_right; ///< Front right cliff sensor.
385  uint8_t cliff_right; ///< Right cliff sensor.
386  uint8_t virtual_wall; ///< Wall sensor.
387  uint8_t overcurrents; ///< Overcurrents bits.
388  uint8_t dirt_detect; ///< Dirt detect sensor.
389  uint8_t unused_1; ///< Unused byte.
390  uint8_t ir_opcode_omni; ///< Omni IR receiver character.
391  uint8_t buttons; ///< Buttons bits.
392  int16_t distance; ///< Traveled distance in mm.
393  int16_t angle; ///< Turned angle in degree.
394  uint8_t charging_state; ///< Charging state.
395  uint16_t voltage; ///< Voltage in mV.
396  int16_t current; ///< Current in mA.
397  int8_t temperature; ///< Temperature in deg C.
398  uint16_t battery_charge; ///< Battery charge in mAh.
399  uint16_t battery_capacity; ///< Battery capacity in mAh.
400  uint16_t wall_signal; ///< Raw wall signal.
401  uint16_t cliff_left_signal; ///< Raw left cliff signal.
402  uint16_t cliff_front_left_signal; ///< Raw front left cliff signal.
403  uint16_t cliff_front_right_signal; ///< Raw front right cliff signal.
404  uint16_t cliff_right_signal; ///< Raw right cliff signal.
405  uint8_t unused_2; ///< Unused byte.
406  uint16_t unused_3; ///< Unused byte.
407  uint8_t charger_available; ///< Available chargers bits.
408  uint8_t mode; ///< Open Interface mode.
409  uint8_t song_number; ///< Song number.
410  uint8_t song_playing; ///< Song playing byte.
411  uint8_t stream_num_packets; ///< Number of streamed packets.
412  int16_t velocity; ///< Velocity in mm/sec.
413  int16_t radius; ///< Radius in mm.
414  int16_t velocity_right; ///< Velocity of right wheel in mm/sec.
415  int16_t velocity_left; ///< Velocity of left wheel in mm/sec.
416  uint16_t encoder_counts_left; ///< Encoder counts for left wheel.
417  uint16_t encoder_counts_right; ///< Encoder counts for right wheel.
418  uint8_t light_bumper; ///< Light bumper bits.
419  uint16_t light_bump_left; ///< Raw left light bumper signal.
420  uint16_t light_bump_front_left; ///< Raw front left light bumper signal.
421  uint16_t light_bump_center_left; ///< Raw center left light bumper signal.
422  uint16_t light_bump_center_right; ///< Raw center right light bumper signal.
423  uint16_t light_bump_front_right; ///< Raw front right light bumper signal.
424  uint16_t light_bump_right; ///< Raw right light bumper signal.
425  uint8_t ir_opcode_left; ///< Left IR receiver character.
426  uint8_t ir_opcode_right; ///< Right IR receiver character.
427  int16_t left_motor_current; ///< Raw left motor current signal.
428  int16_t right_motor_current; ///< Raw right motor current signal.
429  int16_t main_brush_current; ///< Raw main brush motor current signal.
430  int16_t side_brush_current; ///< Raw side brush motor current signal.
431  uint8_t stasis; ///< Castor stasis.
433 #pragma pack(pop)
434 
435 public:
436  Roomba500(ConnectionType conntype, const char *device, unsigned int flags = 0);
437  ~Roomba500();
438 
439  void open();
440  void close();
441 
442  /** Check if connection has been established.
443  * @return true if connection has been established, false otherwise. */
444  bool
445  is_connected() const
446  {
447  return (fd_ != -1);
448  }
449 
450  /** Get connection type.
451  * @return connection type */
454  {
455  return conntype_;
456  }
457  /** Get device string.
458  * @return device string */
459  std::string
460  get_device() const
461  {
462  return device_;
463  }
464 
465  /** Get current mode.
466  * @return current mode. */
467  Mode
468  get_mode() const
469  {
470  return mode_;
471  }
472 
473  /** Check if robot is being controlled.
474  * @return true if robot is being controlled, false otherwise. */
475  bool
477  {
478  return is_connected() && ((mode_ == MODE_SAFE) || (mode_ == MODE_FULL));
479  }
480 
481  void set_mode(Mode mode);
482  void clean();
483  void clean_spot();
484  void seek_dock();
485  void power_down();
486  void stop();
487  void drive_straight(short int velo_mm_per_sec);
488  void drive_turn(TurnDirection direction);
489  void drive_arc(short int velo_mm_per_sec, short int radius_mm);
490  void drive(short int velocity_mm_per_sec, short int radius_mm);
491  void drive_direct(short int left_mm_per_sec, short int right_mm_per_sec);
492  void drive_pwm(short int left_wheel_pwm, short int right_wheel_pwm);
493  void set_motors(bool main = true,
494  bool side = true,
495  bool vacuum = true,
496  bool main_backward = false,
497  bool side_backward = false);
498  void set_leds(bool debris,
499  bool spot,
500  bool dock,
501  bool check_robot,
502  unsigned char clean_color,
503  unsigned char clean_intensity);
504 
505  void set_digit_leds(const char digits[4]);
506 
507  void enable_sensors();
508  void disable_sensors();
509  bool is_data_available();
510  void read_sensors();
511  void query_sensors();
512  /** Check if sensor packet is availabe.
513  * @return true if sensor packet is available, false otherwise
514  */
515  bool
517  {
518  return sensor_packet_received_;
519  };
520  const SensorPacketGroupAll get_sensor_packet() const;
521 
522  void play_fanfare();
523 
524  static unsigned short int get_packet_size(SensorPacketID packet);
525 
526 private:
527  void send(OpCode opcode, const void *params = NULL, const size_t plength = 0);
528  void recv(size_t index, size_t num_bytes, unsigned int timeout_ms = 0);
529 
530  void
531  assert_control()
532  {
533  if ((mode_ != MODE_FULL) && (mode_ != MODE_SAFE)) {
534  throw fawkes::Exception("Command only available in FULL or SAFE mode.");
535  }
536  }
537  void
538  assert_connected()
539  {
540  if (mode_ == MODE_OFF)
541  throw fawkes::Exception("Not connected to robot.");
542  }
543 
544 private:
545  ConnectionType conntype_;
546  unsigned int conn_flags_;
547 
548  Mode mode_;
549  SensorPacketID packet_id_;
550  unsigned char packet_reply_id_;
551  unsigned short packet_length_;
552  bool sensors_enabled_;
553  SensorPacketGroupAll sensor_packet_;
554  bool sensor_packet_received_;
555  mutable fawkes::Mutex sensor_mutex_;
556 
557  std::string device_;
558  int fd_;
559  fawkes::Mutex read_mutex_;
560  fawkes::Mutex write_mutex_;
561 
562  unsigned char obuffer_[16];
563  unsigned char ibuffer_[82];
564 
565  int obuffer_length_;
566  int ibuffer_length_;
567 };
568 
569 #endif
Roomba 500 series communication class.
Definition: roomba_500.h:33
void read_sensors()
Read sensor values.
Definition: roomba_500.cpp:646
void seek_dock()
Seek for the home base and dock.
Definition: roomba_500.cpp:836
static const unsigned char CHARGING_SOURCE_HOME_BASE
Docking station.
Definition: roomba_500.h:251
static const unsigned char WEEKDAY_LED_WED
Wednesday.
Definition: roomba_500.h:269
static const unsigned char SCHEDULING_LED_AM
AM LED bit.
Definition: roomba_500.h:276
static const unsigned char LED_SPOT
Spot LED bit.
Definition: roomba_500.h:262
static const unsigned char BUTTON_CLEAN
Cleaning button.
Definition: roomba_500.h:232
OpCode
Roomba 500 Command op codes.
Definition: roomba_500.h:48
@ OPCODE_DIGIT_LEDS_ASCII
Ascii control of digit LEDs.
Definition: roomba_500.h:73
@ OPCODE_SPOT
Start spot cleaning.
Definition: roomba_500.h:55
@ OPCODE_PAUSE_RESUME_STREAM
Pause or resume streaming data.
Definition: roomba_500.h:70
@ OPCODE_DRIVE
Drive robot.
Definition: roomba_500.h:58
@ OPCODE_LEDS
Control LEDs.
Definition: roomba_500.h:60
@ OPCODE_BAUD
Set baud rate.
Definition: roomba_500.h:50
@ OPCODE_SEEK_DOCK
Start seeking dock.
Definition: roomba_500.h:64
@ OPCODE_PWM_MOTORS
PWM control of motors.
Definition: roomba_500.h:65
@ OPCODE_FULL
Enter full mode.
Definition: roomba_500.h:53
@ OPCODE_DRIVE_WHEELS
Drive wheels.
Definition: roomba_500.h:66
@ OPCODE_SONG
Register song.
Definition: roomba_500.h:61
@ OPCODE_BUTTONS
Control buttons.
Definition: roomba_500.h:74
@ OPCODE_SAFE
Enter safe mode.
Definition: roomba_500.h:52
@ OPCODE_PLAY
Play song.
Definition: roomba_500.h:62
@ OPCODE_START
Initiate communication with Roomba.
Definition: roomba_500.h:49
@ OPCODE_POWER
Power down Roomba.
Definition: roomba_500.h:54
@ OPCODE_STREAM
Start streaming of data.
Definition: roomba_500.h:68
@ OPCODE_MAX
Start max cleaning mode.
Definition: roomba_500.h:57
@ OPCODE_SCHEDULE
Manipulate schedule.
Definition: roomba_500.h:75
@ OPCODE_DRIVE_PWM
Drive by PWM.
Definition: roomba_500.h:67
@ OPCODE_QUERY_LIST
Query multiple sensor packets.
Definition: roomba_500.h:69
@ OPCODE_QUERY
Query sensor info.
Definition: roomba_500.h:63
@ OPCODE_MOTORS
Set motor state.
Definition: roomba_500.h:59
@ OPCODE_CLEAN
Start normal cleaning mission.
Definition: roomba_500.h:56
@ OPCODE_CONTROL
Old alias for SAFE.
Definition: roomba_500.h:51
@ OPCODE_SCHEDULE_LEDS
Control schedule LEDs.
Definition: roomba_500.h:71
@ OPCODE_DIGIT_LEDS_RAW
Raw control of digit LEDs.
Definition: roomba_500.h:72
@ OPCODE_SET_DAY_TIME
Set day and time.
Definition: roomba_500.h:76
bool is_connected() const
Check if connection has been established.
Definition: roomba_500.h:445
static const unsigned char MOTOR_MAIN_BRUSHES
Main brush motor bit.
Definition: roomba_500.h:290
static const unsigned char DIGIT_LED_NORTH_WEST
Top left segment LED.
Definition: roomba_500.h:281
static const short int MAX_LIN_VEL_MM_S
Maximum linear velocity.
Definition: roomba_500.h:364
static const unsigned char BUMPER_CENTER_LEFT
Center left bumper.
Definition: roomba_500.h:256
ConnectionFlags
Connection flags.
Definition: roomba_500.h:43
@ FLAG_FIREFLY_FASTMODE
Enable fast mode, assume FireFly RooTooth.
Definition: roomba_500.h:44
static const unsigned char OVERCURRENT_WHEEL_LEFT
Left wheel bit.
Definition: roomba_500.h:246
static const unsigned char BUMP_RIGHT
Right bumper bit.
Definition: roomba_500.h:244
static const unsigned char OVERCURRENT_MAIN_BRUSH
Main brush bit.
Definition: roomba_500.h:248
static const unsigned char OVERCURRENT_SIDE_BRUSH
Side brush bit.
Definition: roomba_500.h:249
ConnectionType get_connection_type() const
Get connection type.
Definition: roomba_500.h:453
void drive_turn(TurnDirection direction)
Turn robot on the spot.
Definition: roomba_500.cpp:892
static const unsigned char BUTTON_CLOCK
Clock button.
Definition: roomba_500.h:239
static const unsigned char WEEKDAY_LED_MON
Monday.
Definition: roomba_500.h:267
const SensorPacketGroupAll get_sensor_packet() const
Get latest sensor packet.
Definition: roomba_500.cpp:776
void set_leds(bool debris, bool spot, bool dock, bool check_robot, unsigned char clean_color, unsigned char clean_intensity)
Set LED status of main LEDs.
ScheduleDay
Days for scheduler.
Definition: roomba_500.h:216
@ DAY_THURSDAY
Thursday.
Definition: roomba_500.h:221
@ DAY_FRIDAY
Friday.
Definition: roomba_500.h:222
@ DAY_MONDAY
Monday.
Definition: roomba_500.h:218
@ DAY_TUESDAY
Tuesday.
Definition: roomba_500.h:219
@ DAY_WEDNESDAY
Wednesday.
Definition: roomba_500.h:220
@ DAY_SATURDAY
Saturday.
Definition: roomba_500.h:223
@ DAY_SUNDAY
Sunday.
Definition: roomba_500.h:217
void close()
Close serial connection.
Definition: roomba_500.cpp:519
static const unsigned char WEEKDAY_LED_SUN
Sunday.
Definition: roomba_500.h:266
void clean()
Start normal cleaning operation.
Definition: roomba_500.cpp:814
void set_mode(Mode mode)
Set control mode.
Definition: roomba_500.cpp:793
void query_sensors()
Query sensor once.
Definition: roomba_500.cpp:750
static const unsigned char BUMPER_CENTER_RIGHT
Center right bumper.
Definition: roomba_500.h:257
bool has_sensor_packet() const
Check if sensor packet is availabe.
Definition: roomba_500.h:516
~Roomba500()
Destructor.
Definition: roomba_500.cpp:263
Mode get_mode() const
Get current mode.
Definition: roomba_500.h:468
static const unsigned char DIGIT_LED_SOUTH_WEST
Bottom left segment.
Definition: roomba_500.h:284
static const unsigned char BUTTON_MINUTE
Minute button.
Definition: roomba_500.h:235
static const unsigned char SCHEDULING_LED_PM
PM LED bit.
Definition: roomba_500.h:275
static const unsigned char WEEKDAY_LED_SAT
Saturday.
Definition: roomba_500.h:272
void set_motors(bool main=true, bool side=true, bool vacuum=true, bool main_backward=false, bool side_backward=false)
Set motor states (brushes and vacuum).
static const float BUMPER_X_OFFSET
X Offset of bumper.
Definition: roomba_500.h:361
ConnectionType
Connection type.
Definition: roomba_500.h:36
@ CONNTYPE_ROOTOOTH
Use BlueZ to find and connect to RooTooth.
Definition: roomba_500.h:38
@ CONNTYPE_SERIAL
Use serial connection (device file).
Definition: roomba_500.h:37
static const unsigned char MOTOR_SIDE_BRUSH
Side brush motor bit.
Definition: roomba_500.h:288
bool is_controlled() const
Check if robot is being controlled.
Definition: roomba_500.h:476
static const float DIAMETER
Robot diameter.
Definition: roomba_500.h:360
void drive_straight(short int velo_mm_per_sec)
Drive Roomba straight.
Definition: roomba_500.cpp:871
void clean_spot()
Start spot cleaning operation.
Definition: roomba_500.cpp:825
static unsigned short int get_packet_size(SensorPacketID packet)
Get size of packet.
Roomba500(ConnectionType conntype, const char *device, unsigned int flags=0)
Constructor.
Definition: roomba_500.cpp:244
StreamState
Sensor stream state.
Definition: roomba_500.h:154
@ STREAM_DISABLE
Stream disabled.
Definition: roomba_500.h:156
@ STREAM_ENABLE
Stream enabled.
Definition: roomba_500.h:155
void drive_arc(short int velo_mm_per_sec, short int radius_mm)
Drive Roomba on an arc.
Definition: roomba_500.cpp:909
static const unsigned char CHARGING_SOURCE_INTERNAL
Internal socket.
Definition: roomba_500.h:252
static const unsigned char SCHEDULING_LED_SCHEDULE
Schedule LED bit.
Definition: roomba_500.h:278
bool is_data_available()
Check if data is available.
Definition: roomba_500.cpp:622
Mode
Roomba 500 operation mode.
Definition: roomba_500.h:146
@ MODE_OFF
No connection.
Definition: roomba_500.h:147
@ MODE_FULL
Control acquired, safety measures disabled.
Definition: roomba_500.h:150
@ MODE_PASSIVE
Passive mode, no control, only listening.
Definition: roomba_500.h:148
@ MODE_SAFE
Control acquired, safety measures in place.
Definition: roomba_500.h:149
void open()
Open serial port.
Definition: roomba_500.cpp:270
static const unsigned char LED_DEBRIS
Debris LED bit.
Definition: roomba_500.h:261
static const unsigned char BUTTON_DOCK
Dock button.
Definition: roomba_500.h:234
static const unsigned char BUMPER_FRONT_RIGHT
Front right bumper.
Definition: roomba_500.h:258
static const unsigned char WEEKDAY_LED_THU
Thursday.
Definition: roomba_500.h:270
static const unsigned char BUTTON_SCHEDULE
Schedule button.
Definition: roomba_500.h:238
static const unsigned short int STREAM_INTERVAL_MS
Time in ms between streamed sensor packets.
Definition: roomba_500.h:369
static const unsigned char DIGIT_LED_NORTH_EAST
Top right segment LED.
Definition: roomba_500.h:282
static const unsigned char SCHEDULING_LED_COLON
Colon LED bit.
Definition: roomba_500.h:274
static const unsigned char WHEEL_DROP_LEFT
Left wheel drop bit.
Definition: roomba_500.h:241
static const unsigned char DIGIT_LED_SOUTH
Bottom segment LED.
Definition: roomba_500.h:286
std::string get_device() const
Get device string.
Definition: roomba_500.h:460
ChargingState
Charging state.
Definition: roomba_500.h:160
@ CHARGING_RECONDITIONING
Reconditioning battery.
Definition: roomba_500.h:162
@ CHARGING_WAITING
Waiting.
Definition: roomba_500.h:165
@ CHARGING_FULL
Full charging cycle.
Definition: roomba_500.h:163
@ CHARGING_TRICKLE
Trickle charging.
Definition: roomba_500.h:164
@ CHARGING_ERROR
Fault condition.
Definition: roomba_500.h:166
@ CHARGING_NO
Not charging.
Definition: roomba_500.h:161
static const unsigned char DIGIT_LED_CENTER
Center segment LED.
Definition: roomba_500.h:283
static const unsigned char LED_DOCK
Dock LED bit.
Definition: roomba_500.h:263
static const unsigned char BUMPER_FRONT_LEFT
Front left bumper.
Definition: roomba_500.h:255
void power_down()
Powers down the Roomba.
Definition: roomba_500.cpp:848
static const unsigned char WEEKDAY_LED_TUE
Tuesday.
Definition: roomba_500.h:268
void drive(short int velocity_mm_per_sec, short int radius_mm)
Drive Roomba.
Definition: roomba_500.cpp:936
static const unsigned char DIGIT_LED_NORTH
Top segment LED.
Definition: roomba_500.h:280
static const unsigned char BUTTON_DAY
Day button.
Definition: roomba_500.h:237
static const unsigned short int MAX_ENCODER_COUNT
Maximum encoder count.
Definition: roomba_500.h:368
void play_fanfare()
Play a simple fanfare.
void stop()
Stop moption of the Roomba.
Definition: roomba_500.cpp:860
static const unsigned char SCHEDULING_LED_CLOCK
Clock LED bit.
Definition: roomba_500.h:277
void set_digit_leds(const char digits[4])
Set digit LEDs.
SensorPacketID
Roomba 500 sensor package IDs.
Definition: roomba_500.h:80
@ SENSPACK_BATTERY_CAPACITY
Battery capacity.
Definition: roomba_500.h:99
@ SENSPACK_CLIFF_FRONT_LEFT
Front left cliff sensor.
Definition: roomba_500.h:84
@ SENSPACK_WALL
Wall sensor.
Definition: roomba_500.h:82
@ SENSPACK_STASIS
Caster wheel stasis (forward.
Definition: roomba_500.h:129
@ SENSPACK_IR_CHAR_RIGHT
Right IR character.
Definition: roomba_500.h:124
@ SENSPACK_GROUP_107
Packet IDs 54-58.
Definition: roomba_500.h:142
@ SENSPACK_DIRT_DETECT
Dirt detection sensor.
Definition: roomba_500.h:89
@ SENSPACK_LIGHT_BUMPER_CENTER_LEFT
Center left bumper signal.
Definition: roomba_500.h:119
@ SENSPACK_CURRENT
Current.
Definition: roomba_500.h:96
@ SENSPACK_LIGHT_BUMPER_FRONT_RIGHT
Front right bumper signal.
Definition: roomba_500.h:121
@ SENSPACK_GROUP_5
Packet IDs 35-42.
Definition: roomba_500.h:137
@ SENSPACK_CLIFF_FRONT_RIGHT
Front right cliff sensor.
Definition: roomba_500.h:85
@ SENSPACK_OI_MODE
Open Interface mode.
Definition: roomba_500.h:106
@ SENSPACK_GROUP_1
Packet IDs 7-16.
Definition: roomba_500.h:133
@ SENSPACK_CLIFF_RIGHT_SIGNAL
Front right cliff signal value.
Definition: roomba_500.h:104
@ SENSPACK_RIGHT_MOTOR_CURRENT
Right motor current.
Definition: roomba_500.h:126
@ SENSPACK_TEMPERATURE
Temperature.
Definition: roomba_500.h:97
@ SENSPACK_VIRTUAL_WALL
Virtual wall detector.
Definition: roomba_500.h:87
@ SENSPACK_CLIFF_LEFT_SIGNAL
Left cliff signal value.
Definition: roomba_500.h:101
@ SENSPACK_SONG_NUMBER
Song number.
Definition: roomba_500.h:107
@ SENSPACK_CLIFF_RIGHT
Right cliff sensor.
Definition: roomba_500.h:86
@ SENSPACK_LIGHT_BUMPER_FRONT_LEFT
Front left bumper signal.
Definition: roomba_500.h:118
@ SENSPACK_LIGHT_BUMPER
Light bumper status.
Definition: roomba_500.h:116
@ SENSPACK_RIGHT_ENCODER
Right encoder value.
Definition: roomba_500.h:114
@ SENSPACK_SIDE_BRUSH_MOTOR_CURRENT
Side brush motor current.
Definition: roomba_500.h:128
@ SENSPACK_GROUP_3
Packet IDs 21-26.
Definition: roomba_500.h:135
@ SENSPACK_LEFT_MOTOR_CURRENT
Left motor current.
Definition: roomba_500.h:125
@ SENSPACK_LIGHT_BUMPER_RIGHT
Right bumper signal.
Definition: roomba_500.h:122
@ SENSPACK_GROUP_106
Packet IDs 46-51.
Definition: roomba_500.h:141
@ SENSPACK_GROUP_0
Packet IDs 7-26.
Definition: roomba_500.h:132
@ SENSPACK_LIGHT_BUMPER_CENTER_RIGHT
Center right bumper signal.
Definition: roomba_500.h:120
@ SENSPACK_GROUP_6
Packet IDs 7-42.
Definition: roomba_500.h:138
@ SENSPACK_GROUP_4
Packet IDs 27-34.
Definition: roomba_500.h:136
@ SENSPACK_SONG_PLAYING
Song playing indicator.
Definition: roomba_500.h:108
@ SENSPACK_STREAM_PACKETS
Number of stream packets.
Definition: roomba_500.h:109
@ SENSPACK_DISTANCE
Travelled distance.
Definition: roomba_500.h:92
@ SENSPACK_CHARGING_STATE
Charging state.
Definition: roomba_500.h:94
@ SENSPACK_VOLTAGE
Voltage.
Definition: roomba_500.h:95
@ SENSPACK_GROUP_101
Packet IDs 43-58.
Definition: roomba_500.h:140
@ SENSPACK_REQ_VELOCITY
Requested velocity.
Definition: roomba_500.h:110
@ SENSPACK_CLIFF_LEFT
Left cliff sensor.
Definition: roomba_500.h:83
@ SENSPACK_BRUSH_MOTOR_CURRENT
Brush motor current.
Definition: roomba_500.h:127
@ SENSPACK_BUTTONS
Button status.
Definition: roomba_500.h:91
@ SENSPACK_CLIFF_FRONT_LEFT_SIGNAL
Front left cliff signal value.
Definition: roomba_500.h:102
@ SENSPACK_GROUP_ALL
All packet IDs (7-58)
Definition: roomba_500.h:139
@ SENSPACK_ANGLE
Turned angle.
Definition: roomba_500.h:93
@ SENSPACK_CLIFF_FRONT_RIGHT_SIGNAL
Right cliff signal value.
Definition: roomba_500.h:103
@ SENSPACK_LEFT_ENCODER
Left encoder value.
Definition: roomba_500.h:115
@ SENSPACK_LIGHT_BUMPER_LEFT
Left bumper signal.
Definition: roomba_500.h:117
@ SENSPACK_IR_CHAR_OMNI
Omnidirectional IR receiver.
Definition: roomba_500.h:90
@ SENSPACK_REQ_RADIUS
Requested radius.
Definition: roomba_500.h:111
@ SENSPACK_IR_CHAR_LEFT
Left IR character.
Definition: roomba_500.h:123
@ SENSPACK_GROUP_2
Packet IDs 17-20.
Definition: roomba_500.h:134
@ SENSPACK_REQ_RIGHT_VELOCITY
Requested right velocity.
Definition: roomba_500.h:112
@ SENSPACK_BUMPS_DROPS
Bumper and wheel drops.
Definition: roomba_500.h:81
@ SENSPACK_REQ_LEFT_VELOCITY
Requested left velocity.
Definition: roomba_500.h:113
@ SENSPACK_BATTERY_CHARGE
Battery charge.
Definition: roomba_500.h:98
@ SENSPACK_WALL_SIGNAL
Wall signal value.
Definition: roomba_500.h:100
@ SENSPACK_WHEEL_OVERCURRENTS
Overcurrents.
Definition: roomba_500.h:88
@ SENSPACK_CHARGE_SOURCES
Available charge sources.
Definition: roomba_500.h:105
void disable_sensors()
Disable sensor data stream.
Definition: roomba_500.cpp:733
static const short int MAX_RADIUS_MM
Maximum drive radius.
Definition: roomba_500.h:365
static const unsigned char BUTTON_HOUR
Hour button.
Definition: roomba_500.h:236
void drive_pwm(short int left_wheel_pwm, short int right_wheel_pwm)
Directly control wheel velocities via PWM.
Definition: roomba_500.cpp:990
static const unsigned char MOTOR_SIDE_BRUSH_BACKWARD
Side backward bit.
Definition: roomba_500.h:291
static const unsigned char BUMP_LEFT
Left bumper bit.
Definition: roomba_500.h:243
static const unsigned char BUTTON_SPOT
Spot cleaning button.
Definition: roomba_500.h:233
static const unsigned char BUMPER_RIGHT
Right bumper.
Definition: roomba_500.h:259
static const unsigned char MOTOR_MAIN_BRUSHES_BACKWARD
Main backward bit.
Definition: roomba_500.h:292
static const unsigned char MOTOR_VACUUM
Vacuum motor bit.
Definition: roomba_500.h:289
static const unsigned char WEEKDAY_LED_FRI
Friday.
Definition: roomba_500.h:271
TurnDirection
Turning direction.
Definition: roomba_500.h:227
@ TURN_COUNTER_CLOCKWISE
Counter-Clockwise turning.
Definition: roomba_500.h:229
@ TURN_CLOCKWISE
Clockwise turning.
Definition: roomba_500.h:228
static const unsigned char CHARGER_INTERNAL
Internal charger bit.
Definition: roomba_500.h:295
static const float AXLE_LENGTH
Axle length.
Definition: roomba_500.h:362
static const unsigned char BUMPER_LEFT
Left bumper.
Definition: roomba_500.h:254
static const unsigned char WHEEL_DROP_RIGHT
Right wheel drop bit.
Definition: roomba_500.h:242
static const unsigned short int MODE_CHANGE_WAIT_MS
Time in ms to wait after mode changes.
Definition: roomba_500.h:371
static const unsigned char OVERCURRENT_WHEEL_RIGHT
Right wheel bit.
Definition: roomba_500.h:247
void drive_direct(short int left_mm_per_sec, short int right_mm_per_sec)
Directly control wheel velocities.
Definition: roomba_500.cpp:963
static const unsigned char CHECKSUM_SIZE
Checksum byte size.
Definition: roomba_500.h:374
static const unsigned char DIGIT_LED_SOUTH_EAST
Bottom right segment.
Definition: roomba_500.h:285
static const unsigned char LED_CHECK_ROBOT
Check robot LED bit.
Definition: roomba_500.h:264
static const unsigned char CHARGER_HOME_BASE
Home base charger bit.
Definition: roomba_500.h:294
void enable_sensors()
Enable sensor data stream.
Definition: roomba_500.cpp:714
static const short int MAX_PWM
Maximum PWM value for wheels.
Definition: roomba_500.h:367
InfraredCharacter
Infrared character values.
Definition: roomba_500.h:170
@ IR_REMOTE_MEDIUM
IR Remote Control: medium button.
Definition: roomba_500.h:177
@ IR_REMOTE_RIGHT
IR Remote Control: right button.
Definition: roomba_500.h:173
@ IR_DOCK_RED_BUOY_FORCE_FIELD
Roomba 500 dock: green buoy.
Definition: roomba_500.h:206
@ IR_REMOTE_FORWARD
IR Remote Control: forward button.
Definition: roomba_500.h:172
@ IR_DISC_DOCK_RED_GREEN_BUOY_FORCE_FIELD
Roomba Discovery dock: red.
Definition: roomba_500.h:198
@ IR_REMOTE_SPOT
IR Remote Control: spot button.
Definition: roomba_500.h:174
@ IR_DOCK_GREEN_BUOY_FORCE_FIELD
Roomba 500 dock: green buoy.
Definition: roomba_500.h:208
@ IR_DISC_DOCK_GREEN_BUOY_FORCE_FIELD
Roomba Discovery dock: green.
Definition: roomba_500.h:196
@ IR_VIRTUAL_WALL
IR Virtual Wall.
Definition: roomba_500.h:212
@ IR_REMOTE_MAX
IR Remote Control: max button.
Definition: roomba_500.h:175
@ IR_DOCK_FORCE_FIELD
Roomba 500 dock: red and green buoy.
Definition: roomba_500.h:203
@ IR_REMOTE_STOP
IR Remote Control: stop button.
Definition: roomba_500.h:179
@ IR_REMOTE_POWER
IR Remote Control: power button.
Definition: roomba_500.h:180
@ IR_REMOTE_LEFT
IR Remote Control: left button.
Definition: roomba_500.h:171
@ IR_REMOTE_SMALL
IR Remote Control: small button.
Definition: roomba_500.h:176
@ IR_REMOTE_LARGE_CLEAN
IR Remote Control: large/clean button.
Definition: roomba_500.h:178
@ IR_REMOTE_ARC_LEFT
IR Remote Control: left arc button.
Definition: roomba_500.h:181
@ IR_DISC_DOCK_GREEN_BUOY
Roomba Discovery dock: green buoy.
Definition: roomba_500.h:189
@ IR_REMOTE_STOP2
IR Remote Control: stop button.
Definition: roomba_500.h:183
@ IR_DISC_DOCK_RED_BUOY_FORCE_FIELD
Roomba Discovery dock: green.
Definition: roomba_500.h:194
@ IR_DISC_DOCK_RED_GREEN_BUOY
Roomba Discovery dock: red.
Definition: roomba_500.h:192
@ IR_SCHED_REMOTE_DOWNLOAD
IR scheduling remote: download button.
Definition: roomba_500.h:184
@ IR_DOCK_GREEN_BUOY
Roomba 500 dock: green buoy.
Definition: roomba_500.h:202
@ IR_SCHED_REMOTE_SEEK_DOCK
IR scheduling remote: seek dock button.
Definition: roomba_500.h:185
@ IR_DISC_DOCK_FORCE_FIELD
Roomba Discovery dock: red.
Definition: roomba_500.h:190
@ IR_DOCK_RESERVED
Roomba 500 dock: reserved.
Definition: roomba_500.h:200
@ IR_DOCK_RED_BUOY
Roomba 500 dock: red buoy.
Definition: roomba_500.h:201
@ IR_REMOTE_ARC_RIGHT
IR Remote Control: right arc button.
Definition: roomba_500.h:182
@ IR_DOCK_RED_GREEN_BUOY_FORCE_FIELD
Roomba 500 dock: red and.
Definition: roomba_500.h:210
@ IR_DISC_DOCK_RED_BUOY
Roomba Discovery dock: red buoy.
Definition: roomba_500.h:188
@ IR_DISC_DOCK_RESERVED
Roomba Discovery dock: reserved.
Definition: roomba_500.h:187
@ IR_DOCK_RED_GREEN_BUOY
Roomba 500 dock: red buoy and force.
Definition: roomba_500.h:204
Base class for exceptions in Fawkes.
Definition: exception.h:36
Mutex mutual exclusion lock.
Definition: mutex.h:33
Struct for packet group with everything (SENSPACK_GROUP_ALL).
Definition: roomba_500.h:379
uint8_t cliff_front_right
Front right cliff sensor.
Definition: roomba_500.h:384
uint16_t encoder_counts_left
Encoder counts for left wheel.
Definition: roomba_500.h:416
uint8_t ir_opcode_right
Right IR receiver character.
Definition: roomba_500.h:426
uint8_t unused_2
Unused byte.
Definition: roomba_500.h:405
uint8_t mode
Open Interface mode.
Definition: roomba_500.h:408
uint16_t cliff_left_signal
Raw left cliff signal.
Definition: roomba_500.h:401
uint8_t cliff_right
Right cliff sensor.
Definition: roomba_500.h:385
uint16_t light_bump_center_right
Raw center right light bumper signal.
Definition: roomba_500.h:422
uint16_t light_bump_front_right
Raw front right light bumper signal.
Definition: roomba_500.h:423
uint8_t virtual_wall
Wall sensor.
Definition: roomba_500.h:386
uint16_t wall_signal
Raw wall signal.
Definition: roomba_500.h:400
uint8_t bumps_wheeldrops
Bumps and wheeldrops bits.
Definition: roomba_500.h:380
int16_t current
Current in mA.
Definition: roomba_500.h:396
uint16_t cliff_front_right_signal
Raw front right cliff signal.
Definition: roomba_500.h:403
int16_t velocity
Velocity in mm/sec.
Definition: roomba_500.h:412
int16_t velocity_left
Velocity of left wheel in mm/sec.
Definition: roomba_500.h:415
uint16_t encoder_counts_right
Encoder counts for right wheel.
Definition: roomba_500.h:417
uint8_t stream_num_packets
Number of streamed packets.
Definition: roomba_500.h:411
int16_t radius
Radius in mm.
Definition: roomba_500.h:413
uint8_t light_bumper
Light bumper bits.
Definition: roomba_500.h:418
uint8_t ir_opcode_omni
Omni IR receiver character.
Definition: roomba_500.h:390
uint8_t charging_state
Charging state.
Definition: roomba_500.h:394
int16_t angle
Turned angle in degree.
Definition: roomba_500.h:393
int16_t velocity_right
Velocity of right wheel in mm/sec.
Definition: roomba_500.h:414
uint8_t overcurrents
Overcurrents bits.
Definition: roomba_500.h:387
int8_t temperature
Temperature in deg C.
Definition: roomba_500.h:397
uint8_t song_number
Song number.
Definition: roomba_500.h:409
uint16_t voltage
Voltage in mV.
Definition: roomba_500.h:395
uint8_t cliff_left
Left cliff sensor.
Definition: roomba_500.h:382
uint8_t buttons
Buttons bits.
Definition: roomba_500.h:391
uint8_t wall
Wall sensor value.
Definition: roomba_500.h:381
uint16_t battery_charge
Battery charge in mAh.
Definition: roomba_500.h:398
int16_t left_motor_current
Raw left motor current signal.
Definition: roomba_500.h:427
uint8_t cliff_front_left
Front left cliff sensor.
Definition: roomba_500.h:383
int16_t side_brush_current
Raw side brush motor current signal.
Definition: roomba_500.h:430
uint16_t unused_3
Unused byte.
Definition: roomba_500.h:406
uint8_t unused_1
Unused byte.
Definition: roomba_500.h:389
uint16_t light_bump_front_left
Raw front left light bumper signal.
Definition: roomba_500.h:420
uint16_t light_bump_center_left
Raw center left light bumper signal.
Definition: roomba_500.h:421
uint16_t light_bump_left
Raw left light bumper signal.
Definition: roomba_500.h:419
uint8_t charger_available
Available chargers bits.
Definition: roomba_500.h:407
uint16_t cliff_right_signal
Raw right cliff signal.
Definition: roomba_500.h:404
uint8_t song_playing
Song playing byte.
Definition: roomba_500.h:410
int16_t main_brush_current
Raw main brush motor current signal.
Definition: roomba_500.h:429
uint16_t battery_capacity
Battery capacity in mAh.
Definition: roomba_500.h:399
int16_t right_motor_current
Raw right motor current signal.
Definition: roomba_500.h:428
uint16_t cliff_front_left_signal
Raw front left cliff signal.
Definition: roomba_500.h:402
int16_t distance
Traveled distance in mm.
Definition: roomba_500.h:392
uint8_t dirt_detect
Dirt detect sensor.
Definition: roomba_500.h:388
uint8_t ir_opcode_left
Left IR receiver character.
Definition: roomba_500.h:425
uint8_t stasis
Castor stasis.
Definition: roomba_500.h:431
uint16_t light_bump_right
Raw right light bumper signal.
Definition: roomba_500.h:424