23 #ifndef __PLUGINS_ROOMBA_ROOMBA_500_H_ 24 #define __PLUGINS_ROOMBA_ROOMBA_500_H_ 26 #include <core/plugin.h> 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;
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);
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()
510 void assert_connected()
515 unsigned int __conn_flags;
519 unsigned char __packet_reply_id;
520 unsigned short __packet_length;
521 bool __sensors_enabled;
522 SensorPacketGroupAll __sensor_packet;
523 bool __sensor_packet_received;
531 unsigned char __obuffer[16];
532 unsigned char __ibuffer[82];
534 int __obuffer_length;
535 int __ibuffer_length;
void play_fanfare()
Play a simple fanfare.
IR Remote Control: large/clean button.
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.
void drive_direct(short int left_mm_per_sec, short int right_mm_per_sec)
Directly control wheel velocities.
Roomba Discovery dock: red buoy and force field.
ScheduleDay
Days for scheduler.
bool has_sensor_packet() const
Check if sensor packet is availabe.
Caster wheel stasis (forward movement)
IR Remote Control: spot button.
static const unsigned char CHARGER_HOME_BASE
Home base charger bit.
IR Remote Control: medium button.
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.
void stop()
Stop moption of the Roomba.
static const unsigned char BUMPER_CENTER_RIGHT
Center right bumper.
void drive_arc(short int velo_mm_per_sec, short int radius_mm)
Drive Roomba on an arc.
Omnidirectional IR receiver.
bool is_data_available()
Check if data is available.
Roomba500(ConnectionType conntype, const char *device, unsigned int flags=0)
Constructor.
Control acquired, safety measures in place.
static const unsigned char WEEKDAY_LED_THU
Thursday.
Roomba Discovery dock: red.
static const unsigned char WHEEL_DROP_RIGHT
Right wheel drop bit.
Roomba 500 dock: green buoy and force field.
uint8_t overcurrents
Overcurrents bits.
void drive_pwm(short int left_wheel_pwm, short int right_wheel_pwm)
Directly control wheel velocities via PWM.
Roomba 500 dock: red and green buoy and force field.
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.
IR Remote Control: left arc button.
static const unsigned char LED_DEBRIS
Debris LED bit.
Roomba Discovery dock: red and green buoy.
Right cliff signal value.
static const float DIAMETER
Robot diameter.
Fawkes library namespace.
Roomba Discovery dock: red buoy.
const char * get_device() const
Get device string.
uint8_t unused_1
Unused byte.
void enable_sensors()
Enable sensor data stream.
Roomba 500 dock: green buoy and force field.
int16_t angle
Turned angle in degree.
Roomba 500 dock: green buoy.
void seek_dock()
Seek for the home base and dock.
Available charge sources.
static const unsigned char LED_SPOT
Spot LED bit.
uint8_t mode
Open Interface mode.
Use BlueZ to find and connect to RooTooth.
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.
Front right cliff signal value.
void drive_straight(short int velo_mm_per_sec)
Drive Roomba straight.
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.
Roomba Discovery dock: reserved.
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.
void power_down()
Powers down the Roomba.
void disable_sensors()
Disable sensor data stream.
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.
void clean_spot()
Start spot cleaning operation.
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.
Counter-Clockwise turning.
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.
IR Remote Control: max button.
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.
Front right bumper signal.
static const unsigned char OVERCURRENT_MAIN_BRUSH
Main brush bit.
Control acquired, safety measures disabled.
Requested right velocity.
Initiate communication with Roomba.
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.
void clean()
Start normal cleaning operation.
void close()
Close serial connection.
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.
Roomba Discovery dock: green buoy and force field.
static const unsigned char WEEKDAY_LED_FRI
Friday.
IR Remote Control: forward button.
Center right bumper signal.
void query_sensors()
Query sensor once.
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).
StreamState
Sensor stream state.
static const unsigned char BUTTON_CLOCK
Clock button.
static const unsigned char WEEKDAY_LED_SAT
Saturday.
Side brush motor current.
uint8_t buttons
Buttons bits.
static const unsigned char BUTTON_MINUTE
Minute button.
uint8_t charging_state
Charging state.
IR Remote Control: stop button.
int16_t left_motor_current
Raw left motor current signal.
int16_t main_brush_current
Raw main brush motor current signal.
const SensorPacketGroupAll get_sensor_packet() const
Get latest sensor packet.
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.
Pause or resume streaming data.
Center left bumper signal.
uint16_t light_bump_front_left
Raw front left light bumper signal.
Roomba 500 dock: reserved.
IR Remote Control: right arc button.
ConnectionFlags
Connection flags.
Query multiple sensor packets.
static const unsigned char WEEKDAY_LED_TUE
Tuesday.
Enable fast mode, assume FireFly RooTooth.
uint16_t battery_charge
Battery charge in mAh.
IR Remote Control: stop button.
Front left bumper signal.
static const unsigned char OVERCURRENT_SIDE_BRUSH
Side brush bit.
Roomba 500 dock: red buoy and force.
Front left cliff signal value.
uint16_t unused_3
Unused byte.
IR Remote Control: small button.
static const unsigned char WEEKDAY_LED_WED
Wednesday.
uint16_t cliff_right_signal
Raw right cliff signal.
Front right cliff sensor.
IR scheduling remote: seek dock button.
static const unsigned char BUMPER_RIGHT
Right bumper.
uint16_t wall_signal
Raw wall signal.
IR Remote Control: power button.
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.
Number of stream packets.
void set_mode(Mode mode)
Set control mode.
uint8_t cliff_right
Right cliff sensor.
static const unsigned char WEEKDAY_LED_MON
Monday.
Roomba 500 dock: red buoy.
ChargingState
Charging state.
int16_t distance
Traveled distance in mm.
uint16_t cliff_left_signal
Raw left cliff signal.
Passive mode, no control, only listening.
static const unsigned char DIGIT_LED_NORTH
Top segment LED.
uint8_t bumps_wheeldrops
Bumps and wheeldrops bits.
InfraredCharacter
Infrared character values.
IR Remote Control: right button.
void read_sensors()
Read sensor values.
IR scheduling remote: download button.
Start normal cleaning mission.
Roomba 500 series communication class.
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.
Struct for packet group with everything (SENSPACK_GROUP_ALL).
Mutex mutual exclusion lock.
static const unsigned char BUMP_RIGHT
Right bumper bit.
Roomba Discovery dock: green buoy.
static const unsigned char CHARGING_SOURCE_HOME_BASE
Docking station.
uint16_t encoder_counts_right
Encoder counts for right wheel.
void drive(short int velocity_mm_per_sec, short int radius_mm)
Drive Roomba.
int8_t temperature
Temperature in deg C.
static const unsigned char BUMPER_FRONT_RIGHT
Front right bumper.
IR Remote Control: left button.
uint16_t light_bump_left
Raw left light bumper signal.
static const unsigned char MOTOR_VACUUM
Vacuum motor bit.
Roomba 500 dock: red and green buoy.
Raw control of digit LEDs.
uint16_t voltage
Voltage in mV.
void open()
Open serial port.
OpCode
Roomba 500 Command op codes.
void set_digit_leds(const char digits[4])
Set digit LEDs.
Roomba Discovery dock: green buoy and force field.
static const unsigned char DIGIT_LED_SOUTH_WEST
Bottom left segment.
static unsigned short int get_packet_size(SensorPacketID packet)
Get size of packet.
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.
void drive_turn(TurnDirection direction)
Turn robot on the spot.
uint8_t dirt_detect
Dirt detect sensor.
Ascii control of digit LEDs.
static const float AXLE_LENGTH
Axle length.