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;
376 #pragma pack(push, 1) 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];
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 streamed sensor packets.
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.
ScheduleDay
Days for scheduler.
bool has_sensor_packet() const
Check if sensor packet is availabe.
Caster wheel stasis (forward.
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.
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.
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.
Right cliff signal value.
static const float DIAMETER
Robot diameter.
Roomba Discovery dock: red buoy.
uint8_t unused_1
Unused byte.
void enable_sensors()
Enable sensor data stream.
Roomba 500 dock: green buoy.
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.
std::string get_device() const
Get device string.
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.
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.
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.