Fawkes API  Fawkes Development Version
Roomba500 Class Reference

Roomba 500 series communication class. More...

#include "roomba_500.h"

List of all members.

Classes

struct  SensorPacketGroupAll
 Struct for packet group with everything (SENSPACK_GROUP_ALL). More...

Public Types

enum  ConnectionType { CONNTYPE_SERIAL, CONNTYPE_ROOTOOTH }
 Connection type. More...
enum  ConnectionFlags { FLAG_FIREFLY_FASTMODE = 1 }
 Connection flags. More...
enum  OpCode {
  OPCODE_START = 128, OPCODE_BAUD = 129, OPCODE_CONTROL = 130, OPCODE_SAFE = 131,
  OPCODE_FULL = 132, OPCODE_POWER = 133, OPCODE_SPOT = 134, OPCODE_CLEAN = 135,
  OPCODE_MAX = 136, OPCODE_DRIVE = 137, OPCODE_MOTORS = 138, OPCODE_LEDS = 139,
  OPCODE_SONG = 140, OPCODE_PLAY = 141, OPCODE_QUERY = 142, OPCODE_SEEK_DOCK = 143,
  OPCODE_PWM_MOTORS = 144, OPCODE_DRIVE_WHEELS = 145, OPCODE_DRIVE_PWM = 146, OPCODE_STREAM = 148,
  OPCODE_QUERY_LIST = 149, OPCODE_PAUSE_RESUME_STREAM = 150, OPCODE_SCHEDULE_LEDS = 162, OPCODE_DIGIT_LEDS_RAW = 163,
  OPCODE_DIGIT_LEDS_ASCII = 164, OPCODE_BUTTONS = 165, OPCODE_SCHEDULE = 167, OPCODE_SET_DAY_TIME = 168
}
 Roomba 500 Command op codes. More...
enum  SensorPacketID {
  SENSPACK_BUMPS_DROPS = 7, SENSPACK_WALL = 8, SENSPACK_CLIFF_LEFT = 9, SENSPACK_CLIFF_FRONT_LEFT = 10,
  SENSPACK_CLIFF_FRONT_RIGHT = 11, SENSPACK_CLIFF_RIGHT = 12, SENSPACK_VIRTUAL_WALL = 13, SENSPACK_WHEEL_OVERCURRENTS = 14,
  SENSPACK_DIRT_DETECT = 15, SENSPACK_IR_CHAR_OMNI = 17, SENSPACK_BUTTONS = 18, SENSPACK_DISTANCE = 19,
  SENSPACK_ANGLE = 20, SENSPACK_CHARGING_STATE = 21, SENSPACK_VOLTAGE = 22, SENSPACK_CURRENT = 23,
  SENSPACK_TEMPERATURE = 24, SENSPACK_BATTERY_CHARGE = 25, SENSPACK_BATTERY_CAPACITY = 26, SENSPACK_WALL_SIGNAL = 27,
  SENSPACK_CLIFF_LEFT_SIGNAL = 28, SENSPACK_CLIFF_FRONT_LEFT_SIGNAL = 29, SENSPACK_CLIFF_FRONT_RIGHT_SIGNAL = 30, SENSPACK_CLIFF_RIGHT_SIGNAL = 31,
  SENSPACK_CHARGE_SOURCES = 34, SENSPACK_OI_MODE = 35, SENSPACK_SONG_NUMBER = 36, SENSPACK_SONG_PLAYING = 37,
  SENSPACK_STREAM_PACKETS = 38, SENSPACK_REQ_VELOCITY = 39, SENSPACK_REQ_RADIUS = 40, SENSPACK_REQ_RIGHT_VELOCITY = 41,
  SENSPACK_REQ_LEFT_VELOCITY = 42, SENSPACK_RIGHT_ENCODER = 43, SENSPACK_LEFT_ENCODER = 44, SENSPACK_LIGHT_BUMPER = 45,
  SENSPACK_LIGHT_BUMPER_LEFT = 46, SENSPACK_LIGHT_BUMPER_FRONT_LEFT = 47, SENSPACK_LIGHT_BUMPER_CENTER_LEFT = 48, SENSPACK_LIGHT_BUMPER_CENTER_RIGHT = 49,
  SENSPACK_LIGHT_BUMPER_FRONT_RIGHT = 50, SENSPACK_LIGHT_BUMPER_RIGHT = 51, SENSPACK_IR_CHAR_LEFT = 52, SENSPACK_IR_CHAR_RIGHT = 53,
  SENSPACK_LEFT_MOTOR_CURRENT = 54, SENSPACK_RIGHT_MOTOR_CURRENT = 55, SENSPACK_BRUSH_MOTOR_CURRENT = 56, SENSPACK_SIDE_BRUSH_MOTOR_CURRENT = 57,
  SENSPACK_STASIS = 58, SENSPACK_GROUP_0 = 0, SENSPACK_GROUP_1 = 1, SENSPACK_GROUP_2 = 2,
  SENSPACK_GROUP_3 = 3, SENSPACK_GROUP_4 = 4, SENSPACK_GROUP_5 = 5, SENSPACK_GROUP_6 = 6,
  SENSPACK_GROUP_ALL = 100, SENSPACK_GROUP_101 = 101, SENSPACK_GROUP_106 = 106, SENSPACK_GROUP_107 = 107
}
 Roomba 500 sensor package IDs. More...
enum  Mode { MODE_OFF = 0, MODE_PASSIVE = 1, MODE_SAFE = 2, MODE_FULL = 3 }
 Roomba 500 operation mode. More...
enum  StreamState { STREAM_ENABLE = 1, STREAM_DISABLE = 0 }
 Sensor stream state. More...
enum  ChargingState {
  CHARGING_NO = 0, CHARGING_RECONDITIONING = 1, CHARGING_FULL = 2, CHARGING_TRICKLE = 3,
  CHARGING_WAITING = 4, CHARGING_ERROR = 5
}
 Charging state. More...
enum  InfraredCharacter {
  IR_REMOTE_LEFT = 129, IR_REMOTE_FORWARD = 130, IR_REMOTE_RIGHT = 131, IR_REMOTE_SPOT = 132,
  IR_REMOTE_MAX = 133, IR_REMOTE_SMALL = 134, IR_REMOTE_MEDIUM = 135, IR_REMOTE_LARGE_CLEAN = 136,
  IR_REMOTE_STOP = 137, IR_REMOTE_POWER = 138, IR_REMOTE_ARC_LEFT = 139, IR_REMOTE_ARC_RIGHT = 140,
  IR_REMOTE_STOP2 = 141, IR_SCHED_REMOTE_DOWNLOAD = 142, IR_SCHED_REMOTE_SEEK_DOCK = 143, IR_DISC_DOCK_RESERVED = 240,
  IR_DISC_DOCK_RED_BUOY = 248, IR_DISC_DOCK_GREEN_BUOY = 244, IR_DISC_DOCK_FORCE_FIELD = 242, IR_DISC_DOCK_RED_GREEN_BUOY = 252,
  IR_DISC_DOCK_RED_BUOY_FORCE_FIELD = 250, IR_DISC_DOCK_GREEN_BUOY_FORCE_FIELD = 246, IR_DISC_DOCK_RED_GREEN_BUOY_FORCE_FIELD = 254, IR_DOCK_RESERVED = 160,
  IR_DOCK_RED_BUOY = 168, IR_DOCK_GREEN_BUOY = 164, IR_DOCK_FORCE_FIELD = 161, IR_DOCK_RED_GREEN_BUOY = 172,
  IR_DOCK_RED_BUOY_FORCE_FIELD = 169, IR_DOCK_GREEN_BUOY_FORCE_FIELD = 165, IR_DOCK_RED_GREEN_BUOY_FORCE_FIELD = 173, IR_VIRTUAL_WALL = 162
}
 Infrared character values. More...
enum  ScheduleDay {
  DAY_SUNDAY = 0, DAY_MONDAY = 1, DAY_TUESDAY = 2, DAY_WEDNESDAY = 3,
  DAY_THURSDAY = 4, DAY_FRIDAY = 5, DAY_SATURDAY = 6
}
 Days for scheduler. More...
enum  TurnDirection { TURN_CLOCKWISE, TURN_COUNTER_CLOCKWISE }
 Turning direction. More...

Public Member Functions

 Roomba500 (ConnectionType conntype, const char *device, unsigned int flags=0)
 Constructor.
 ~Roomba500 ()
 Destructor.
void open ()
 Open serial port.
void close ()
 Close serial connection.
bool is_connected () const
 Check if connection has been established.
ConnectionType get_connection_type () const
 Get connection type.
const char * get_device () const
 Get device string.
Mode get_mode () const
 Get current mode.
bool is_controlled () const
 Check if robot is being controlled.
void set_mode (Mode mode)
 Set control mode.
void clean ()
 Start normal cleaning operation.
void clean_spot ()
 Start spot cleaning operation.
void seek_dock ()
 Seek for the home base and dock.
void power_down ()
 Powers down the Roomba.
void stop ()
 Stop moption of the Roomba.
void drive_straight (short int velo_mm_per_sec)
 Drive Roomba straight.
void drive_turn (TurnDirection direction)
 Turn robot on the spot.
void drive_arc (short int velo_mm_per_sec, short int radius_mm)
 Drive Roomba on an arc.
void drive (short int velocity_mm_per_sec, short int radius_mm)
 Drive Roomba.
void drive_direct (short int left_mm_per_sec, short int right_mm_per_sec)
 Directly control wheel velocities.
void drive_pwm (short int left_wheel_pwm, short int right_wheel_pwm)
 Directly control wheel velocities via PWM.
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).
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.
void set_digit_leds (const char digits[4])
 Set digit LEDs.
void enable_sensors ()
 Enable sensor data stream.
void disable_sensors ()
 Disable sensor data stream.
bool is_data_available ()
 Check if data is available.
void read_sensors ()
 Read sensor values.
void query_sensors ()
 Query sensor once.
bool has_sensor_packet () const
 Check if sensor packet is availabe.
const SensorPacketGroupAll get_sensor_packet () const
 Get latest sensor packet.
void play_fanfare ()
 Play a simple fanfare.

Static Public Member Functions

static unsigned short int get_packet_size (SensorPacketID packet)
 Get size of packet.

Static Public Attributes

static const unsigned char BUTTON_CLEAN
 Cleaning button.
static const unsigned char BUTTON_SPOT
 Spot cleaning button.
static const unsigned char BUTTON_DOCK
 Dock button.
static const unsigned char BUTTON_MINUTE
 Minute button.
static const unsigned char BUTTON_HOUR
 Hour button.
static const unsigned char BUTTON_DAY
 Day button.
static const unsigned char BUTTON_SCHEDULE
 Schedule button.
static const unsigned char BUTTON_CLOCK
 Clock button.
static const unsigned char WHEEL_DROP_LEFT
 Left wheel drop bit.
static const unsigned char WHEEL_DROP_RIGHT
 Right wheel drop bit.
static const unsigned char BUMP_LEFT
 Left bumper bit.
static const unsigned char BUMP_RIGHT
 Right bumper bit.
static const unsigned char OVERCURRENT_WHEEL_LEFT
 Left wheel bit.
static const unsigned char OVERCURRENT_WHEEL_RIGHT
 Right wheel bit.
static const unsigned char OVERCURRENT_MAIN_BRUSH
 Main brush bit.
static const unsigned char OVERCURRENT_SIDE_BRUSH
 Side brush bit.
static const unsigned char CHARGING_SOURCE_HOME_BASE
 Docking station.
static const unsigned char CHARGING_SOURCE_INTERNAL
 Internal socket.
static const unsigned char BUMPER_LEFT
 Left bumper.
static const unsigned char BUMPER_FRONT_LEFT
 Front left bumper.
static const unsigned char BUMPER_CENTER_LEFT
 Center left bumper.
static const unsigned char BUMPER_CENTER_RIGHT
 Center right bumper.
static const unsigned char BUMPER_FRONT_RIGHT
 Front right bumper.
static const unsigned char BUMPER_RIGHT
 Right bumper.
static const unsigned char LED_DEBRIS
 Debris LED bit.
static const unsigned char LED_SPOT
 Spot LED bit.
static const unsigned char LED_DOCK
 Dock LED bit.
static const unsigned char LED_CHECK_ROBOT
 Check robot LED bit.
static const unsigned char WEEKDAY_LED_SUN
 Sunday.
static const unsigned char WEEKDAY_LED_MON
 Monday.
static const unsigned char WEEKDAY_LED_TUE
 Tuesday.
static const unsigned char WEEKDAY_LED_WED
 Wednesday.
static const unsigned char WEEKDAY_LED_THU
 Thursday.
static const unsigned char WEEKDAY_LED_FRI
 Friday.
static const unsigned char WEEKDAY_LED_SAT
 Saturday.
static const unsigned char SCHEDULING_LED_COLON
 Colon LED bit.
static const unsigned char SCHEDULING_LED_PM
 PM LED bit.
static const unsigned char SCHEDULING_LED_AM
 AM LED bit.
static const unsigned char SCHEDULING_LED_CLOCK
 Clock LED bit.
static const unsigned char SCHEDULING_LED_SCHEDULE
 Schedule LED bit.
static const unsigned char DIGIT_LED_NORTH
 Top segment LED.
static const unsigned char DIGIT_LED_NORTH_WEST
 Top left segment LED.
static const unsigned char DIGIT_LED_NORTH_EAST
 Top right segment LED.
static const unsigned char DIGIT_LED_CENTER
 Center segment LED.
static const unsigned char DIGIT_LED_SOUTH_WEST
 Bottom left segment.
static const unsigned char DIGIT_LED_SOUTH_EAST
 Bottom right segment.
static const unsigned char DIGIT_LED_SOUTH
 Bottom segment LED.
static const unsigned char MOTOR_SIDE_BRUSH
 Side brush motor bit.
static const unsigned char MOTOR_VACUUM
 Vacuum motor bit.
static const unsigned char MOTOR_MAIN_BRUSHES
 Main brush motor bit.
static const unsigned char MOTOR_SIDE_BRUSH_BACKWARD
 Side backward bit.
static const unsigned char MOTOR_MAIN_BRUSHES_BACKWARD
 Main backward bit.
static const unsigned char CHARGER_HOME_BASE
 Home base charger bit.
static const unsigned char CHARGER_INTERNAL
 Internal charger bit.
static const float DIAMETER
static const float BUMPER_X_OFFSET
 X Offset of bumper.
static const float AXLE_LENGTH
 Axle length.
static const short int MAX_LIN_VEL_MM_S
 Maximum linear velocity.
static const short int MAX_RADIUS_MM
 Maximum drive radius.
static const short int MAX_PWM
 Maximum PWM value for wheels.
static const unsigned short int MAX_ENCODER_COUNT
 Maximum encoder count.
static const unsigned short int STREAM_INTERVAL_MS
 Time in ms between.
static const unsigned short int MODE_CHANGE_WAIT_MS
 Time in ms to wait after mode changes.
static const unsigned char CHECKSUM_SIZE
 Checksum byte size.

Detailed Description

Roomba 500 series communication class.

This class implements the serial communication with Roomba robots of the 500 series.

RFCOMM by reading http://people.csail.mit.edu/albert/bluez-intro/.

Author:
Tim Niemueller

Member Enumeration Documentation

Charging state.

Enumerator:
CHARGING_NO 

Not charging.

CHARGING_RECONDITIONING 

Reconditioning battery.

CHARGING_FULL 

Full charging cycle.

CHARGING_TRICKLE 

Trickle charging.

CHARGING_WAITING 

Waiting.

CHARGING_ERROR 

Fault condition.

Definition at line 162 of file roomba_500.h.

Connection flags.

These flags allow to influence the connection creation and operation.

Enumerator:
FLAG_FIREFLY_FASTMODE 

Enable fast mode, assume FireFly RooTooth.

Definition at line 45 of file roomba_500.h.

Connection type.

Enumerator:
CONNTYPE_SERIAL 

Use serial connection (device file).

CONNTYPE_ROOTOOTH 

Use BlueZ to find and connect to RooTooth.

Definition at line 38 of file roomba_500.h.

Infrared character values.

Enumerator:
IR_REMOTE_LEFT 

IR Remote Control: left button.

IR_REMOTE_FORWARD 

IR Remote Control: forward button.

IR_REMOTE_RIGHT 

IR Remote Control: right button.

IR_REMOTE_SPOT 

IR Remote Control: spot button.

IR_REMOTE_MAX 

IR Remote Control: max button.

IR_REMOTE_SMALL 

IR Remote Control: small button.

IR_REMOTE_MEDIUM 

IR Remote Control: medium button.

IR_REMOTE_LARGE_CLEAN 

IR Remote Control: large/clean button.

IR_REMOTE_STOP 

IR Remote Control: stop button.

IR_REMOTE_POWER 

IR Remote Control: power button.

IR_REMOTE_ARC_LEFT 

IR Remote Control: left arc button.

IR_REMOTE_ARC_RIGHT 

IR Remote Control: right arc button.

IR_REMOTE_STOP2 

IR Remote Control: stop button.

IR_SCHED_REMOTE_DOWNLOAD 

IR scheduling remote: download button.

IR_SCHED_REMOTE_SEEK_DOCK 

IR scheduling remote: seek dock button.

IR_DISC_DOCK_RESERVED 

Roomba Discovery dock: reserved.

IR_DISC_DOCK_RED_BUOY 

Roomba Discovery dock: red buoy.

IR_DISC_DOCK_GREEN_BUOY 

Roomba Discovery dock: green buoy.

IR_DISC_DOCK_FORCE_FIELD 

Roomba Discovery dock: red and green buoy.

IR_DISC_DOCK_RED_GREEN_BUOY 

Roomba Discovery dock: red buoy and force field.

IR_DISC_DOCK_RED_BUOY_FORCE_FIELD 

Roomba Discovery dock: green buoy and force field.

IR_DISC_DOCK_GREEN_BUOY_FORCE_FIELD 

Roomba Discovery dock: green buoy and force field.

IR_DISC_DOCK_RED_GREEN_BUOY_FORCE_FIELD 

Roomba Discovery dock: red.

and green buoy and force field

IR_DOCK_RESERVED 

Roomba 500 dock: reserved.

IR_DOCK_RED_BUOY 

Roomba 500 dock: red buoy.

IR_DOCK_GREEN_BUOY 

Roomba 500 dock: green buoy.

IR_DOCK_FORCE_FIELD 

Roomba 500 dock: red and green buoy.

IR_DOCK_RED_GREEN_BUOY 

Roomba 500 dock: red buoy and force.

field

IR_DOCK_RED_BUOY_FORCE_FIELD 

Roomba 500 dock: green buoy and force field.

IR_DOCK_GREEN_BUOY_FORCE_FIELD 

Roomba 500 dock: green buoy and force field.

IR_DOCK_RED_GREEN_BUOY_FORCE_FIELD 

Roomba 500 dock: red and green buoy and force field.

IR_VIRTUAL_WALL 

IR Virtual Wall.

Definition at line 172 of file roomba_500.h.

Roomba 500 operation mode.

Enumerator:
MODE_OFF 

No connection.

MODE_PASSIVE 

Passive mode, no control, only listening.

MODE_SAFE 

Control acquired, safety measures in place.

MODE_FULL 

Control acquired, safety measures disabled.

Definition at line 148 of file roomba_500.h.

Roomba 500 Command op codes.

Enumerator:
OPCODE_START 

Initiate communication with Roomba.

OPCODE_BAUD 

Set baud rate.

OPCODE_CONTROL 

Old alias for SAFE.

OPCODE_SAFE 

Enter safe mode.

OPCODE_FULL 

Enter full mode.

OPCODE_POWER 

Power down Roomba.

OPCODE_SPOT 

Start spot cleaning.

OPCODE_CLEAN 

Start normal cleaning mission.

OPCODE_MAX 

Start max cleaning mode.

OPCODE_DRIVE 

Drive robot.

OPCODE_MOTORS 

Set motor state.

OPCODE_LEDS 

Control LEDs.

OPCODE_SONG 

Register song.

OPCODE_PLAY 

Play song.

OPCODE_QUERY 

Query sensor info.

OPCODE_SEEK_DOCK 

Start seeking dock.

OPCODE_PWM_MOTORS 

PWM control of motors.

OPCODE_DRIVE_WHEELS 

Drive wheels.

OPCODE_DRIVE_PWM 

Drive by PWM.

OPCODE_STREAM 

Start streaming of data.

OPCODE_QUERY_LIST 

Query multiple sensor packets.

OPCODE_PAUSE_RESUME_STREAM 

Pause or resume streaming data.

OPCODE_SCHEDULE_LEDS 

Control schedule LEDs.

OPCODE_DIGIT_LEDS_RAW 

Raw control of digit LEDs.

OPCODE_DIGIT_LEDS_ASCII 

Ascii control of digit LEDs.

OPCODE_BUTTONS 

Control buttons.

OPCODE_SCHEDULE 

Manipulate schedule.

OPCODE_SET_DAY_TIME 

Set day and time.

Definition at line 50 of file roomba_500.h.

Days for scheduler.

Enumerator:
DAY_SUNDAY 

Sunday.

DAY_MONDAY 

Monday.

DAY_TUESDAY 

Tuesday.

DAY_WEDNESDAY 

Wednesday.

DAY_THURSDAY 

Thursday.

DAY_FRIDAY 

Friday.

DAY_SATURDAY 

Saturday.

Definition at line 218 of file roomba_500.h.

Roomba 500 sensor package IDs.

Enumerator:
SENSPACK_BUMPS_DROPS 

Bumper and wheel drops.

SENSPACK_WALL 

Wall sensor.

SENSPACK_CLIFF_LEFT 

Left cliff sensor.

SENSPACK_CLIFF_FRONT_LEFT 

Front left cliff sensor.

SENSPACK_CLIFF_FRONT_RIGHT 

Front right cliff sensor.

SENSPACK_CLIFF_RIGHT 

Right cliff sensor.

SENSPACK_VIRTUAL_WALL 

Virtual wall detector.

SENSPACK_WHEEL_OVERCURRENTS 

Overcurrents.

SENSPACK_DIRT_DETECT 

Dirt detection sensor.

SENSPACK_IR_CHAR_OMNI 

Omnidirectional IR receiver.

SENSPACK_BUTTONS 

Button status.

SENSPACK_DISTANCE 

Travelled distance.

SENSPACK_ANGLE 

Turned angle.

SENSPACK_CHARGING_STATE 

Charging state.

SENSPACK_VOLTAGE 

Voltage.

SENSPACK_CURRENT 

Current.

SENSPACK_TEMPERATURE 

Temperature.

SENSPACK_BATTERY_CHARGE 

Battery charge.

SENSPACK_BATTERY_CAPACITY 

Battery capacity.

SENSPACK_WALL_SIGNAL 

Wall signal value.

SENSPACK_CLIFF_LEFT_SIGNAL 

Left cliff signal value.

SENSPACK_CLIFF_FRONT_LEFT_SIGNAL 

Front left cliff signal value.

SENSPACK_CLIFF_FRONT_RIGHT_SIGNAL 

Right cliff signal value.

SENSPACK_CLIFF_RIGHT_SIGNAL 

Front right cliff signal value.

SENSPACK_CHARGE_SOURCES 

Available charge sources.

SENSPACK_OI_MODE 

Open Interface mode.

SENSPACK_SONG_NUMBER 

Song number.

SENSPACK_SONG_PLAYING 

Song playing indicator.

SENSPACK_STREAM_PACKETS 

Number of stream packets.

SENSPACK_REQ_VELOCITY 

Requested velocity.

SENSPACK_REQ_RADIUS 

Requested radius.

SENSPACK_REQ_RIGHT_VELOCITY 

Requested right velocity.

SENSPACK_REQ_LEFT_VELOCITY 

Requested left velocity.

SENSPACK_RIGHT_ENCODER 

Right encoder value.

SENSPACK_LEFT_ENCODER 

Left encoder value.

SENSPACK_LIGHT_BUMPER 

Light bumper status.

SENSPACK_LIGHT_BUMPER_LEFT 

Left bumper signal.

SENSPACK_LIGHT_BUMPER_FRONT_LEFT 

Front left bumper signal.

SENSPACK_LIGHT_BUMPER_CENTER_LEFT 

Center left bumper signal.

SENSPACK_LIGHT_BUMPER_CENTER_RIGHT 

Center right bumper signal.

SENSPACK_LIGHT_BUMPER_FRONT_RIGHT 

Front right bumper signal.

SENSPACK_LIGHT_BUMPER_RIGHT 

Right bumper signal.

SENSPACK_IR_CHAR_LEFT 

Left IR character.

SENSPACK_IR_CHAR_RIGHT 

Right IR character.

SENSPACK_LEFT_MOTOR_CURRENT 

Left motor current.

SENSPACK_RIGHT_MOTOR_CURRENT 

Right motor current.

SENSPACK_BRUSH_MOTOR_CURRENT 

Brush motor current.

SENSPACK_SIDE_BRUSH_MOTOR_CURRENT 

Side brush motor current.

SENSPACK_STASIS 

Caster wheel stasis (forward movement)

SENSPACK_GROUP_0 

Packet IDs 7-26.

SENSPACK_GROUP_1 

Packet IDs 7-16.

SENSPACK_GROUP_2 

Packet IDs 17-20.

SENSPACK_GROUP_3 

Packet IDs 21-26.

SENSPACK_GROUP_4 

Packet IDs 27-34.

SENSPACK_GROUP_5 

Packet IDs 35-42.

SENSPACK_GROUP_6 

Packet IDs 7-42.

SENSPACK_GROUP_ALL 

All packet IDs (7-58)

SENSPACK_GROUP_101 

Packet IDs 43-58.

SENSPACK_GROUP_106 

Packet IDs 46-51.

SENSPACK_GROUP_107 

Packet IDs 54-58.

Definition at line 82 of file roomba_500.h.

Sensor stream state.

Enumerator:
STREAM_ENABLE 

Stream enabled.

STREAM_DISABLE 

Stream disabled.

Definition at line 156 of file roomba_500.h.

Turning direction.

Enumerator:
TURN_CLOCKWISE 

Clockwise turning.

TURN_COUNTER_CLOCKWISE 

Counter-Clockwise turning.

Definition at line 229 of file roomba_500.h.


Constructor & Destructor Documentation

Roomba500::Roomba500 ( Roomba500::ConnectionType  conntype,
const char *  device,
unsigned int  flags = 0 
)

Constructor.

Parameters:
conntypeconnection type
devicefor CONN_SERIAL connection type this is the device file for the serial connection. For CONN_ROOTOOTH this is either a name pattern of a bluetooth device to query or a bluetooth address. The name can be the full name, or a pattern using shell globs (e.g. FireFly-*). The bluetooth address must be given in hexadecimal manner (e.g. 00:11:22:33:44:55).
flagsConnectionFlags constants, joined with bit-wise "or" (|).

Definition at line 241 of file roomba_500.cpp.

Roomba500::~Roomba500 ( )

Destructor.

Definition at line 275 of file roomba_500.cpp.


Member Function Documentation

void Roomba500::clean ( )

Start normal cleaning operation.

Transitions to passive mode.

Definition at line 845 of file roomba_500.cpp.

void Roomba500::clean_spot ( )

Start spot cleaning operation.

Transitions to passive mode.

Definition at line 857 of file roomba_500.cpp.

void Roomba500::close ( )

Close serial connection.

Definition at line 545 of file roomba_500.cpp.

void Roomba500::disable_sensors ( )

Disable sensor data stream.

Definition at line 761 of file roomba_500.cpp.

void Roomba500::drive ( short int  velo_mm_per_sec,
short int  radius_mm 
)

Drive Roomba.

Available only in safe or full mode.

Parameters:
velo_mm_per_secdesired velocity in m/sec
radius_mmdesired radius of arc in m

Definition at line 968 of file roomba_500.cpp.

void Roomba500::drive_arc ( short int  velo_mm_per_sec,
short int  radius_mm 
)

Drive Roomba on an arc.

Available only in safe or full mode.

Parameters:
velo_mm_per_secdesired velocity in m/sec
radius_mmdesired radius of arc in m

Definition at line 945 of file roomba_500.cpp.

void Roomba500::drive_direct ( short int  left_mm_per_sec,
short int  right_mm_per_sec 
)

Directly control wheel velocities.

Available only in safe or full mode.

Parameters:
left_mm_per_secvelocity of left wheel in m/sec
right_mm_per_secvelocity of right wheel in m/sec

Definition at line 992 of file roomba_500.cpp.

void Roomba500::drive_pwm ( short int  left_wheel_pwm,
short int  right_wheel_pwm 
)

Directly control wheel velocities via PWM.

Available only in safe or full mode.

Parameters:
left_wheel_pwmPWM parameter for left wheel
right_wheel_pwmPWM parameter for right wheel

Definition at line 1017 of file roomba_500.cpp.

void Roomba500::drive_straight ( short int  velo_mm_per_sec)

Drive Roomba straight.

Available only in safe or full mode.

Parameters:
velo_mm_per_secdesired velocity in m/sec

Definition at line 908 of file roomba_500.cpp.

void Roomba500::drive_turn ( Roomba500::TurnDirection  direction)

Turn robot on the spot.

Available only in safe or full mode.

Parameters:
directionturning direction

Definition at line 927 of file roomba_500.cpp.

void Roomba500::enable_sensors ( )

Enable sensor data stream.

For simplicity and efficiency only the single SENSPACK_GROUP_ALL packet can be streamed at this time. Make sure that the used connection is fast enough. 56700 bit/sec should suffice, but 115200 is strongly recommended. If using RooTooth make sure to use it in fast mode.

Definition at line 741 of file roomba_500.cpp.

ConnectionType Roomba500::get_connection_type ( ) const [inline]

Get connection type.

Returns:
connection type

Definition at line 450 of file roomba_500.h.

const char* Roomba500::get_device ( ) const [inline]

Get device string.

Returns:
device string

Definition at line 453 of file roomba_500.h.

Mode Roomba500::get_mode ( ) const [inline]

Get current mode.

Returns:
current mode.

Definition at line 457 of file roomba_500.h.

unsigned short int Roomba500::get_packet_size ( Roomba500::SensorPacketID  packet) [static]

Get size of packet.

Parameters:
packetID of packet to query size for
Returns:
size of packet
Exceptions:
Exceptionthrown for unknown packet IDs.

Definition at line 1144 of file roomba_500.cpp.

const Roomba500::SensorPacketGroupAll Roomba500::get_sensor_packet ( ) const

Get latest sensor packet.

Returns:
sensor packet

Definition at line 807 of file roomba_500.cpp.

bool Roomba500::has_sensor_packet ( ) const [inline]

Check if sensor packet is availabe.

Returns:
true if sensor packet is available, false otherwise

Definition at line 491 of file roomba_500.h.

bool Roomba500::is_connected ( ) const [inline]

Check if connection has been established.

Returns:
true if connection has been established, false otherwise.

Definition at line 446 of file roomba_500.h.

Referenced by is_controlled().

bool Roomba500::is_controlled ( ) const [inline]

Check if robot is being controlled.

Returns:
true if robot is being controlled, false otherwise.

Definition at line 461 of file roomba_500.h.

References is_connected(), MODE_SAFE, and MODE_FULL.

bool Roomba500::is_data_available ( )

Check if data is available.

Returns:
true if data is available and can be read, false otherwise

Definition at line 648 of file roomba_500.cpp.

void Roomba500::open ( )

Open serial port.

Definition at line 287 of file roomba_500.cpp.

void Roomba500::play_fanfare ( )

Play a simple fanfare.

You can play this for example upon connection to inform the user.

Definition at line 1105 of file roomba_500.cpp.

void Roomba500::power_down ( )

Powers down the Roomba.

Transitions to passive mode.

Definition at line 882 of file roomba_500.cpp.

void Roomba500::query_sensors ( )

Query sensor once.

For simplicity and efficiency only the single SENSPACK_GROUP_ALL packet can be streamed at this time.

Definition at line 779 of file roomba_500.cpp.

void Roomba500::read_sensors ( )

Read sensor values.

Enable sensors before using enable_sensors(). This method will block until new data has been read. You can call is_data_available() to check if this method will block or not.

Definition at line 673 of file roomba_500.cpp.

void Roomba500::seek_dock ( )

Seek for the home base and dock.

Transitions to passive mode.

Definition at line 869 of file roomba_500.cpp.

void Roomba500::set_digit_leds ( const char  digits[4])

Set digit LEDs.

Available only in safe or full mode. Note, that not all characters are availabe. You can use ASCII table entries 32-39, 44-63, 65-96, and 123-126.

Parameters:
digitsarray of digit values

Definition at line 1093 of file roomba_500.cpp.

void Roomba500::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.

Available only in safe or full mode.

Parameters:
debristrue to enable debris LED, false to disable
spottrue to enable spot LED, false to disable
docktrue to enable dock LED, false to disable
check_robottrue to enable check_robot LED, false to disable
clean_colorcolor of clean button LED from green (0) to red (255)
clean_intensityintensity of clean button LED from off (0) to full intensity (255)

Definition at line 1071 of file roomba_500.cpp.

void Roomba500::set_mode ( Roomba500::Mode  mode)

Set control mode.

Parameters:
modethe mode can be either MODE_FULL or MODE_SAFE (recommended). MODE_OFF and MODE_PASSIVE cannot be set explicitly. To enter MODE_PASSIVE issue a command which transitions mode, like clean() or seek_dock().
Exceptions:
Exceptionthrown if an invalid mode is passed

Definition at line 824 of file roomba_500.cpp.

void Roomba500::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).

Available only in safe or full mode.

Parameters:
maintrue to enable main brushes
sidetrue to enable side brush
vacuumtrue to enable vacuuming
main_backwardtrue to enable backward operation of main brushes
side_backwardtrue to enable backward operation of side brush

Definition at line 1044 of file roomba_500.cpp.

void Roomba500::stop ( )

Stop moption of the Roomba.

Available only in safe or full mode.

Definition at line 895 of file roomba_500.cpp.


Member Data Documentation

const float Roomba500::AXLE_LENGTH [static]

Axle length.

Definition at line 365 of file roomba_500.h.

const unsigned char Roomba500::BUMP_LEFT [static]

Left bumper bit.

Definition at line 245 of file roomba_500.h.

Referenced by Roomba500Thread::write_blackboard().

const unsigned char Roomba500::BUMP_RIGHT [static]

Right bumper bit.

Definition at line 246 of file roomba_500.h.

Referenced by Roomba500Thread::write_blackboard().

const unsigned char Roomba500::BUMPER_CENTER_LEFT [static]

Center left bumper.

Definition at line 258 of file roomba_500.h.

Referenced by Roomba500Thread::write_blackboard().

const unsigned char Roomba500::BUMPER_CENTER_RIGHT [static]

Center right bumper.

Definition at line 259 of file roomba_500.h.

Referenced by Roomba500Thread::write_blackboard().

const unsigned char Roomba500::BUMPER_FRONT_LEFT [static]

Front left bumper.

Definition at line 257 of file roomba_500.h.

Referenced by Roomba500Thread::write_blackboard().

const unsigned char Roomba500::BUMPER_FRONT_RIGHT [static]

Front right bumper.

Definition at line 260 of file roomba_500.h.

Referenced by Roomba500Thread::write_blackboard().

const unsigned char Roomba500::BUMPER_LEFT [static]

Left bumper.

Definition at line 256 of file roomba_500.h.

Referenced by Roomba500Thread::write_blackboard().

const unsigned char Roomba500::BUMPER_RIGHT [static]

Right bumper.

Definition at line 261 of file roomba_500.h.

Referenced by Roomba500Thread::write_blackboard().

const float Roomba500::BUMPER_X_OFFSET [static]

X Offset of bumper.

Definition at line 364 of file roomba_500.h.

const unsigned char Roomba500::BUTTON_CLEAN [static]

Cleaning button.

Definition at line 234 of file roomba_500.h.

Referenced by Roomba500Thread::write_blackboard().

const unsigned char Roomba500::BUTTON_CLOCK [static]

Clock button.

Definition at line 241 of file roomba_500.h.

Referenced by Roomba500Thread::write_blackboard().

const unsigned char Roomba500::BUTTON_DAY [static]

Day button.

Definition at line 239 of file roomba_500.h.

Referenced by Roomba500Thread::write_blackboard().

const unsigned char Roomba500::BUTTON_DOCK [static]

Dock button.

Definition at line 236 of file roomba_500.h.

Referenced by Roomba500Thread::write_blackboard().

const unsigned char Roomba500::BUTTON_HOUR [static]

Hour button.

Definition at line 238 of file roomba_500.h.

Referenced by Roomba500Thread::write_blackboard().

const unsigned char Roomba500::BUTTON_MINUTE [static]

Minute button.

Definition at line 237 of file roomba_500.h.

Referenced by Roomba500Thread::write_blackboard().

const unsigned char Roomba500::BUTTON_SCHEDULE [static]

Schedule button.

Definition at line 240 of file roomba_500.h.

Referenced by Roomba500Thread::write_blackboard().

const unsigned char Roomba500::BUTTON_SPOT [static]

Spot cleaning button.

Definition at line 235 of file roomba_500.h.

Referenced by Roomba500Thread::write_blackboard().

const unsigned char Roomba500::CHARGER_HOME_BASE [static]

Home base charger bit.

Definition at line 296 of file roomba_500.h.

Referenced by Roomba500Thread::write_blackboard().

const unsigned char Roomba500::CHARGER_INTERNAL [static]

Internal charger bit.

Definition at line 297 of file roomba_500.h.

Referenced by Roomba500Thread::write_blackboard().

const unsigned char Roomba500::CHARGING_SOURCE_HOME_BASE [static]

Docking station.

Definition at line 253 of file roomba_500.h.

const unsigned char Roomba500::CHARGING_SOURCE_INTERNAL [static]

Internal socket.

Definition at line 254 of file roomba_500.h.

const unsigned char Roomba500::CHECKSUM_SIZE [static]

Checksum byte size.

Definition at line 377 of file roomba_500.h.

const float Roomba500::DIAMETER [static]

Robot diameter.

Definition at line 363 of file roomba_500.h.

const unsigned char Roomba500::DIGIT_LED_CENTER [static]

Center segment LED.

Definition at line 285 of file roomba_500.h.

const unsigned char Roomba500::DIGIT_LED_NORTH [static]

Top segment LED.

Definition at line 282 of file roomba_500.h.

const unsigned char Roomba500::DIGIT_LED_NORTH_EAST [static]

Top right segment LED.

Definition at line 284 of file roomba_500.h.

const unsigned char Roomba500::DIGIT_LED_NORTH_WEST [static]

Top left segment LED.

Definition at line 283 of file roomba_500.h.

const unsigned char Roomba500::DIGIT_LED_SOUTH [static]

Bottom segment LED.

Definition at line 288 of file roomba_500.h.

const unsigned char Roomba500::DIGIT_LED_SOUTH_EAST [static]

Bottom right segment.

Definition at line 287 of file roomba_500.h.

const unsigned char Roomba500::DIGIT_LED_SOUTH_WEST [static]

Bottom left segment.

Definition at line 286 of file roomba_500.h.

const unsigned char Roomba500::LED_CHECK_ROBOT [static]

Check robot LED bit.

Definition at line 266 of file roomba_500.h.

const unsigned char Roomba500::LED_DEBRIS [static]

Debris LED bit.

Definition at line 263 of file roomba_500.h.

const unsigned char Roomba500::LED_DOCK [static]

Dock LED bit.

Definition at line 265 of file roomba_500.h.

const unsigned char Roomba500::LED_SPOT [static]

Spot LED bit.

Definition at line 264 of file roomba_500.h.

const unsigned short int Roomba500::MAX_ENCODER_COUNT [static]

Maximum encoder count.

Definition at line 371 of file roomba_500.h.

const short int Roomba500::MAX_LIN_VEL_MM_S [static]

Maximum linear velocity.

Definition at line 367 of file roomba_500.h.

const short int Roomba500::MAX_PWM [static]

Maximum PWM value for wheels.

Definition at line 370 of file roomba_500.h.

const short int Roomba500::MAX_RADIUS_MM [static]

Maximum drive radius.

Definition at line 368 of file roomba_500.h.

const unsigned short int Roomba500::MODE_CHANGE_WAIT_MS [static]

Time in ms to wait after mode changes.

Definition at line 374 of file roomba_500.h.

const unsigned char Roomba500::MOTOR_MAIN_BRUSHES [static]

Main brush motor bit.

Definition at line 292 of file roomba_500.h.

const unsigned char Roomba500::MOTOR_MAIN_BRUSHES_BACKWARD [static]

Main backward bit.

Definition at line 294 of file roomba_500.h.

const unsigned char Roomba500::MOTOR_SIDE_BRUSH [static]

Side brush motor bit.

Definition at line 290 of file roomba_500.h.

const unsigned char Roomba500::MOTOR_SIDE_BRUSH_BACKWARD [static]

Side backward bit.

Definition at line 293 of file roomba_500.h.

const unsigned char Roomba500::MOTOR_VACUUM [static]

Vacuum motor bit.

Definition at line 291 of file roomba_500.h.

const unsigned char Roomba500::OVERCURRENT_MAIN_BRUSH [static]

Main brush bit.

Definition at line 250 of file roomba_500.h.

Referenced by Roomba500Thread::write_blackboard().

const unsigned char Roomba500::OVERCURRENT_SIDE_BRUSH [static]

Side brush bit.

Definition at line 251 of file roomba_500.h.

Referenced by Roomba500Thread::write_blackboard().

const unsigned char Roomba500::OVERCURRENT_WHEEL_LEFT [static]

Left wheel bit.

Definition at line 248 of file roomba_500.h.

Referenced by Roomba500Thread::write_blackboard().

const unsigned char Roomba500::OVERCURRENT_WHEEL_RIGHT [static]

Right wheel bit.

Definition at line 249 of file roomba_500.h.

Referenced by Roomba500Thread::write_blackboard().

const unsigned char Roomba500::SCHEDULING_LED_AM [static]

AM LED bit.

Definition at line 278 of file roomba_500.h.

const unsigned char Roomba500::SCHEDULING_LED_CLOCK [static]

Clock LED bit.

Definition at line 279 of file roomba_500.h.

const unsigned char Roomba500::SCHEDULING_LED_COLON [static]

Colon LED bit.

Definition at line 276 of file roomba_500.h.

const unsigned char Roomba500::SCHEDULING_LED_PM [static]

PM LED bit.

Definition at line 277 of file roomba_500.h.

const unsigned char Roomba500::SCHEDULING_LED_SCHEDULE [static]

Schedule LED bit.

Definition at line 280 of file roomba_500.h.

const unsigned short int Roomba500::STREAM_INTERVAL_MS [static]

Time in ms between.

streamed sensor packets.

Definition at line 372 of file roomba_500.h.

Referenced by Roomba500Thread::WorkerThread::WorkerThread().

const unsigned char Roomba500::WEEKDAY_LED_FRI [static]

Friday.

Definition at line 273 of file roomba_500.h.

const unsigned char Roomba500::WEEKDAY_LED_MON [static]

Monday.

Definition at line 269 of file roomba_500.h.

const unsigned char Roomba500::WEEKDAY_LED_SAT [static]

Saturday.

Definition at line 274 of file roomba_500.h.

const unsigned char Roomba500::WEEKDAY_LED_SUN [static]

Sunday.

Definition at line 268 of file roomba_500.h.

const unsigned char Roomba500::WEEKDAY_LED_THU [static]

Thursday.

Definition at line 272 of file roomba_500.h.

const unsigned char Roomba500::WEEKDAY_LED_TUE [static]

Tuesday.

Definition at line 270 of file roomba_500.h.

const unsigned char Roomba500::WEEKDAY_LED_WED [static]

Wednesday.

Definition at line 271 of file roomba_500.h.

const unsigned char Roomba500::WHEEL_DROP_LEFT [static]

Left wheel drop bit.

Definition at line 243 of file roomba_500.h.

Referenced by Roomba500Thread::write_blackboard().

const unsigned char Roomba500::WHEEL_DROP_RIGHT [static]

Right wheel drop bit.

Definition at line 244 of file roomba_500.h.

Referenced by Roomba500Thread::write_blackboard().


The documentation for this class was generated from the following files: