23 #ifndef ROOMBA_COMMS_H
24 #define ROOMBA_COMMS_H
33 #define ROOMBA_OPCODE_START 128
34 #define ROOMBA_OPCODE_BAUD 129
35 #define ROOMBA_OPCODE_CONTROL 130
36 #define ROOMBA_OPCODE_SAFE 131
37 #define ROOMBA_OPCODE_FULL 132
38 #define ROOMBA_OPCODE_POWER 133
39 #define ROOMBA_OPCODE_SPOT 134
40 #define ROOMBA_OPCODE_CLEAN 135
41 #define ROOMBA_OPCODE_MAX 136
42 #define ROOMBA_OPCODE_DRIVE 137
43 #define ROOMBA_OPCODE_MOTORS 138
44 #define ROOMBA_OPCODE_LEDS 139
45 #define ROOMBA_OPCODE_SONG 140
46 #define ROOMBA_OPCODE_PLAY 141
47 #define ROOMBA_OPCODE_SENSORS 142
48 #define ROOMBA_OPCODE_FORCEDOCK 143
50 #define ROOMBA_DELAY_MODECHANGE_MS 20
52 #define ROOMBA_MODE_OFF 0
53 #define ROOMBA_MODE_PASSIVE 1
54 #define ROOMBA_MODE_SAFE 2
55 #define ROOMBA_MODE_FULL 3
57 #define ROOMBA_TVEL_MAX_MM_S 500
58 #define ROOMBA_RADIUS_MAX_MM 2000
60 #define ROOMBA_SENSOR_PACKET_SIZE 26
62 #define ROOMBA_CHARGING_NOT 0
63 #define ROOMBA_CHARGING_RECOVERY 1
64 #define ROOMBA_CHARGING_CHARGING 2
65 #define ROOMBA_CHARGING_TRICKLE 3
66 #define ROOMBA_CHARGING_WAITING 4
67 #define ROOMBA_CHARGING_ERROR 5
69 #define ROOMBA_AXLE_LENGTH 0.258
71 #define ROOMBA_DIAMETER 0.33
73 #define ROOMBA_BUMPER_XOFFSET 0.05
75 #define ROOMBA_DISCOVERY 0
79 #define MIN(a,b) ((a < b) ? (a) : (b))
82 #define MAX(a,b) ((a > b) ? (a) : (b))
85 #define NORMALIZE(z) atan2(sin(z), cos(z))
91 char serial_port[PATH_MAX];
100 unsigned int roomba_type;
103 int bumper_left, bumper_right;
104 unsigned char wheeldrop_caster, wheeldrop_left, wheeldrop_right;
106 unsigned char cliff_left, cliff_frontleft, cliff_frontright, cliff_right;
107 unsigned char virtual_wall;
108 unsigned char overcurrent_driveleft, overcurrent_driveright;
109 unsigned char overcurrent_mainbrush, overcurrent_sidebrush;
110 unsigned char overcurrent_vacuum;
111 unsigned char dirtdetector_right, dirtdetector_left;
112 unsigned char remote_opcode;
113 unsigned char button_power, button_spot, button_clean, button_max;
116 unsigned char charging_state;
129 roomba_comm_t* roomba_create(
const char* serial_port,
unsigned int roomba_type);
131 int roomba_open(
roomba_comm_t* r,
unsigned char fullcontrol);
132 int roomba_init(
roomba_comm_t* r,
unsigned char fullcontrol);
134 int roomba_set_speeds(
roomba_comm_t* r,
double tv,
double rv);
136 unsigned char* buf,
size_t buflen);
142 int roomba_set_song(
roomba_comm_t* r,
unsigned char songNumber,
143 unsigned char songLength,
unsigned char *notes,
144 unsigned char *noteLengths);
145 int roomba_play_song(
roomba_comm_t *r,
unsigned char songNumber);
149 uint8_t clean, uint8_t spot, uint8_t status,
150 uint8_t power_color, uint8_t power_intensity );
#define PLAYER_MSG1(level, msg, a)
Error message macros.
Definition: error.h:106
#define PLAYER_MSG3(level, msg, a, b, c)
Error message macros.
Definition: error.h:108
static bool MatchMessage(player_msghdr_t *hdr, int type, int subtype, player_devaddr_t addr)
Helper for message processing.
Definition: message.h:159
Definition: roomba_comms.h:89
double ReadFloat(int section, const char *name, double value)
Read a floating point (double) value.
A pose in the plane.
Definition: player.h:218
Generic message header.
Definition: player.h:162
virtual int MainSetup(void)
Sets up the resources needed by the driver thread.
Definition: driver.h:658
virtual void MainQuit(void)
Cleanup method for driver thread (called when main exits)
Definition: driver.h:664
uint8_t type
Message type; must be one of PLAYER_MSGTYPE_*.
Definition: player.h:166
#define PLAYER_WARN3(msg, a, b, c)
Error message macros.
Definition: error.h:92
Encapsulates a device (i.e., a driver bound to an interface)
Definition: device.h:75
const char * ReadString(int section, const char *name, const char *value)
Read a string value.
double pyaw
yaw [rad]
Definition: player.h:241
uint8_t subtype
Message subtype; interface specific.
Definition: player.h:168
double ReadTupleFloat(int section, const char *name, int index, double value)
Read a float (double) from a tuple field.
virtual void Main(void)=0
Main method for driver thread.
const char * ReadTupleString(int section, const char *name, int index, const char *value)
Read a string from a tuple field.
int ReadInt(int section, const char *name, int value)
Read an integer value.
#define PLAYER_MSGTYPE_DATA
A data message.
Definition: player.h:95
Request to get a double property.
Definition: player.h:470
#define PLAYER_MSGTYPE_RESP_ACK
A positive response message.
Definition: player.h:112
virtual int ProcessMessage(QueuePointer &resp_queue, player_msghdr *hdr, void *data)
Message handler.
bool ReadBool(int section, const char *name, bool value)
Read a boolean value (one of: yes, no, true, false, 1, 0)
#define PLAYER_MSGTYPE_REQ
A request message.
Definition: player.h:106
#define PLAYER_MSGTYPE_RESP_NACK
A negative response message.
Definition: player.h:125
int ReadDeviceAddr(player_devaddr_t *addr, int section, const char *name, int code, int index, const char *key)
Read a device id.
int GetTupleCount(int section, const char *name)
Get the number of values in a tuple.
Class for loading configuration file information.
Definition: configfile.h:197
virtual int Setup()
Initialize the driver.
Definition: driver.h:386
A device address.
Definition: player.h:146
An autopointer for the message queue.
Definition: message.h:74
Double property class.
Definition: property.h:143
#define PLAYER_ERROR1(msg, a)
Error message macros.
Definition: error.h:82
char * key
The property key.
Definition: player.h:474
A pose in space.
Definition: player.h:229
#define PLAYER_ERROR(msg)
Error message macros.
Definition: error.h:81
Base class for drivers which oeprate with a thread.
Definition: driver.h:553
#define PLAYER_GET_DBLPROP_REQ
Double property get request subtype.
Definition: player.h:434
uint32_t size
Size in bytes of the payload to follow.
Definition: player.h:174
#define PLAYER_WARN(msg)
Warning message macros.
Definition: error.h:89
#define PLAYER_MSGTYPE_CMD
A command message.
Definition: player.h:99
virtual int Shutdown()
Finalize the driver.
Definition: driver.h:393
Base class for all drivers.
Definition: driver.h:109
#define PLAYER_MSG0(level, msg)
General messages.
Definition: error.h:105
uint16_t index
Which device of that interface.
Definition: player.h:155
player_devaddr_t addr
Device to which this message pertains.
Definition: player.h:164
#define PLAYER_MSGQUEUE_DEFAULT_MAXLEN
Default maximum length for a message queue.
Definition: player.h:76
T max(T a, T b)
Return the maximum of a, b.
Definition: utility.h:126