Fawkes API
Fawkes Development Version
|
23 #ifndef _PLUGINS_ROOMBA_ROOMBA_500_H_
24 #define _PLUGINS_ROOMBA_ROOMBA_500_H_
26 #include <core/plugin.h>
27 #include <core/threading/mutex.h>
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;
367 static const short int MAX_PWM;
376 #pragma pack(push, 1)
380 uint8_t bumps_wheeldrops;
383 uint8_t cliff_front_left;
384 uint8_t cliff_front_right;
386 uint8_t virtual_wall;
387 uint8_t overcurrents;
390 uint8_t ir_opcode_omni;
394 uint8_t charging_state;
398 uint16_t battery_charge;
399 uint16_t battery_capacity;
400 uint16_t wall_signal;
401 uint16_t cliff_left_signal;
402 uint16_t cliff_front_left_signal;
403 uint16_t cliff_front_right_signal;
404 uint16_t cliff_right_signal;
407 uint8_t charger_available;
410 uint8_t song_playing;
411 uint8_t stream_num_packets;
414 int16_t velocity_right;
415 int16_t velocity_left;
416 uint16_t encoder_counts_left;
417 uint16_t encoder_counts_right;
418 uint8_t light_bumper;
419 uint16_t light_bump_left;
420 uint16_t light_bump_front_left;
421 uint16_t light_bump_center_left;
422 uint16_t light_bump_center_right;
423 uint16_t light_bump_front_right;
424 uint16_t light_bump_right;
425 uint8_t ir_opcode_left;
426 uint8_t ir_opcode_right;
427 int16_t left_motor_current;
428 int16_t right_motor_current;
429 int16_t main_brush_current;
430 int16_t side_brush_current;
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);
496 bool main_backward =
false,
497 bool side_backward =
false);
502 unsigned char clean_color,
503 unsigned char clean_intensity);
518 return sensor_packet_received_;
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);
546 unsigned int conn_flags_;
550 unsigned char packet_reply_id_;
551 unsigned short packet_length_;
552 bool sensors_enabled_;
553 SensorPacketGroupAll sensor_packet_;
554 bool sensor_packet_received_;
562 unsigned char obuffer_[16];
563 unsigned char ibuffer_[82];
Mode
Roomba 500 operation mode.
ChargingState
Charging state.
IR Remote Control: right arc button.
bool is_controlled() const
Check if robot is being controlled.
void set_digit_leds(const char digits[4])
Set digit LEDs.
SensorPacketID
Roomba 500 sensor package IDs.
TurnDirection
Turning direction.
Front right cliff signal value.
bool has_sensor_packet() const
Check if sensor packet is availabe.
const SensorPacketGroupAll get_sensor_packet() const
Get latest sensor packet.
static const unsigned char WEEKDAY_LED_FRI
Friday.
static const unsigned char BUTTON_CLEAN
Cleaning button.
void drive_straight(short int velo_mm_per_sec)
Drive Roomba straight.
static const unsigned char BUMPER_CENTER_LEFT
Center left bumper.
static const unsigned char WEEKDAY_LED_THU
Thursday.
Roomba 500 dock: red and.
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 unsigned char WEEKDAY_LED_SAT
Saturday.
void power_down()
Powers down the Roomba.
Raw control of digit LEDs.
Caster wheel stasis (forward.
void play_fanfare()
Play a simple fanfare.
ConnectionFlags
Connection flags.
static const unsigned char MOTOR_VACUUM
Vacuum motor bit.
static const unsigned char BUMPER_CENTER_RIGHT
Center right bumper.
static const unsigned char BUMP_LEFT
Left bumper bit.
static const unsigned char BUTTON_DOCK
Dock button.
void clean()
Start normal cleaning operation.
Right cliff signal value.
ScheduleDay
Days for scheduler.
OpCode
Roomba 500 Command op codes.
IR Remote Control: left button.
Roomba 500 dock: green buoy.
Struct for packet group with everything (SENSPACK_GROUP_ALL).
IR Remote Control: stop button.
IR scheduling remote: download button.
Roomba 500 dock: red and green buoy.
ConnectionType get_connection_type() const
Get connection type.
static const unsigned char BUMPER_LEFT
Left bumper.
static const unsigned char SCHEDULING_LED_PM
PM LED bit.
static const unsigned char DIGIT_LED_NORTH_WEST
Top left segment LED.
void set_mode(Mode mode)
Set control mode.
static const unsigned char WEEKDAY_LED_WED
Wednesday.
static const short int MAX_PWM
Maximum PWM value for wheels.
Side brush motor current.
static const unsigned char LED_CHECK_ROBOT
Check robot LED bit.
void clean_spot()
Start spot cleaning operation.
void disable_sensors()
Disable sensor data stream.
Roomba 500 dock: red buoy.
static const unsigned char DIGIT_LED_SOUTH_WEST
Bottom left segment.
static const unsigned char BUMPER_RIGHT
Right bumper.
void drive_direct(short int left_mm_per_sec, short int right_mm_per_sec)
Directly control wheel velocities.
static const unsigned char CHARGING_SOURCE_HOME_BASE
Docking station.
Available charge sources.
IR Remote Control: medium button.
Roomba Discovery dock: reserved.
static const unsigned char SCHEDULING_LED_AM
AM LED bit.
static const unsigned char WHEEL_DROP_LEFT
Left wheel drop bit.
Initiate communication with Roomba.
void read_sensors()
Read sensor values.
Roomba Discovery dock: red.
static const unsigned char SCHEDULING_LED_CLOCK
Clock LED bit.
static const unsigned char BUTTON_HOUR
Hour button.
static const unsigned char BUTTON_DAY
Day button.
static const unsigned char BUMP_RIGHT
Right bumper bit.
Control acquired, safety measures disabled.
void drive_turn(TurnDirection direction)
Turn robot on the spot.
Center left bumper signal.
void enable_sensors()
Enable sensor data stream.
Roomba500(ConnectionType conntype, const char *device, unsigned int flags=0)
Constructor.
static const unsigned char CHARGER_HOME_BASE
Home base charger bit.
Front right cliff sensor.
Query multiple sensor packets.
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.
Roomba 500 dock: green buoy.
static const unsigned char CHECKSUM_SIZE
Checksum byte size.
ConnectionType
Connection type.
static const unsigned short int MAX_ENCODER_COUNT
Maximum encoder count.
IR scheduling remote: seek dock button.
static const unsigned char LED_SPOT
Spot LED bit.
Roomba Discovery dock: green.
Roomba Discovery dock: green buoy.
IR Remote Control: left arc button.
static const float BUMPER_X_OFFSET
X Offset of bumper.
static const unsigned char OVERCURRENT_SIDE_BRUSH
Side brush bit.
Roomba Discovery dock: red.
static unsigned short int get_packet_size(SensorPacketID packet)
Get size of packet.
static const short int MAX_LIN_VEL_MM_S
Maximum linear velocity.
Roomba 500 dock: red buoy and force.
static const unsigned char MOTOR_SIDE_BRUSH
Side brush motor bit.
Roomba Discovery dock: red buoy.
static const unsigned char LED_DOCK
Dock LED bit.
Front left bumper signal.
void open()
Open serial port.
static const unsigned char BUMPER_FRONT_LEFT
Front left bumper.
static const unsigned char OVERCURRENT_WHEEL_RIGHT
Right wheel bit.
void drive_pwm(short int left_wheel_pwm, short int right_wheel_pwm)
Directly control wheel velocities via PWM.
static const float AXLE_LENGTH
Axle length.
void query_sensors()
Query sensor once.
IR Remote Control: forward button.
static const unsigned char BUTTON_MINUTE
Minute button.
Mode get_mode() const
Get current mode.
Roomba Discovery dock: red.
static const unsigned char MOTOR_MAIN_BRUSHES
Main brush motor bit.
IR Remote Control: small button.
static const unsigned char DIGIT_LED_NORTH
Top segment LED.
Control acquired, safety measures in place.
InfraredCharacter
Infrared character values.
static const unsigned char DIGIT_LED_NORTH_EAST
Top right segment LED.
IR Remote Control: power button.
bool is_data_available()
Check if data is available.
static const unsigned char MOTOR_SIDE_BRUSH_BACKWARD
Side backward bit.
Passive mode, no control, only listening.
Omnidirectional IR receiver.
void seek_dock()
Seek for the home base and dock.
Front left cliff signal value.
static const unsigned char DIGIT_LED_CENTER
Center segment LED.
Requested right velocity.
static const unsigned char SCHEDULING_LED_COLON
Colon LED bit.
static const unsigned char BUTTON_SCHEDULE
Schedule button.
Roomba 500 dock: green buoy.
static const unsigned char WEEKDAY_LED_MON
Monday.
static const unsigned char DIGIT_LED_SOUTH_EAST
Bottom right segment.
std::string get_device() const
Get device string.
void drive(short int velocity_mm_per_sec, short int radius_mm)
Drive Roomba.
IR Remote Control: large/clean button.
Use serial connection (device file).
static const unsigned char OVERCURRENT_MAIN_BRUSH
Main brush bit.
static const unsigned char BUTTON_SPOT
Spot cleaning button.
static const unsigned char WEEKDAY_LED_SUN
Sunday.
Ascii control of digit LEDs.
static const unsigned char LED_DEBRIS
Debris LED bit.
static const unsigned char OVERCURRENT_WHEEL_LEFT
Left wheel bit.
Pause or resume streaming data.
static const unsigned char WHEEL_DROP_RIGHT
Right wheel drop bit.
void drive_arc(short int velo_mm_per_sec, short int radius_mm)
Drive Roomba on an arc.
Start normal cleaning mission.
Use BlueZ to find and connect to RooTooth.
IR Remote Control: stop button.
static const unsigned char BUMPER_FRONT_RIGHT
Front right bumper.
IR Remote Control: spot button.
static const unsigned char CHARGER_INTERNAL
Internal charger bit.
void close()
Close serial connection.
static const unsigned short int STREAM_INTERVAL_MS
Time in ms between streamed sensor packets.
StreamState
Sensor stream state.
static const unsigned char BUTTON_CLOCK
Clock button.
Front right bumper signal.
bool is_connected() const
Check if connection has been established.
static const unsigned char DIGIT_LED_SOUTH
Bottom segment LED.
static const unsigned char SCHEDULING_LED_SCHEDULE
Schedule LED bit.
IR Remote Control: right button.
static const unsigned char CHARGING_SOURCE_INTERNAL
Internal socket.
IR Remote Control: max button.
Roomba Discovery dock: green.
void stop()
Stop moption of the Roomba.
Counter-Clockwise turning.
Roomba 500 dock: reserved.
static const short int MAX_RADIUS_MM
Maximum drive radius.
Number of stream packets.
Enable fast mode, assume FireFly RooTooth.
static const unsigned char MOTOR_MAIN_BRUSHES_BACKWARD
Main backward bit.
static const float DIAMETER
Robot diameter.
Center right bumper signal.
static const unsigned char WEEKDAY_LED_TUE
Tuesday.
static const unsigned short int MODE_CHANGE_WAIT_MS
Time in ms to wait after mode changes.