|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectroombacomm.RoombaComm
public abstract class RoombaComm
The abstract base for all Roomba communications.
RoombaComm roomba = new RoombaCommSubClass(); // (e.g. RoombaCommSerial)
roomba.listports(); // if implemented
roomba.connect("someportid");
roomba.startup();
roomba.updateSensors();
while( ... ) {
roomba.sensors();
roomba.playNote( 53, 12 );
roomba.goForward( 400 );
roomba.spinRight( 45 );
if( roomba.bump() ) roomba.goBackward( 100 );
}
roomba.disconnect();
| Field Summary | |
|---|---|
static int |
ANGLE_HI
|
static int |
ANGLE_LO
|
static int |
BAUD
|
static int |
BUMP_MASK
|
static int |
BUMPLEFT_MASK
|
static int |
BUMPRIGHT_MASK
|
static int |
BUMPSWHEELDROPS
|
static int |
BUTTONS
|
static int |
BUTTONSCMD
|
static int |
CAPACITY_HI
|
static int |
CAPACITY_LO
|
static int |
CHARGE_HI
|
static int |
CHARGE_LO
|
static int |
CHARGINGSTATE
|
static int |
CLEAN
|
static int |
CLEANBUTTON_MASK
|
static int |
CLIFFFRONTLEFT
|
static int |
CLIFFFRONTRIGHT
|
static int |
CLIFFLEFT
|
static int |
CLIFFRIGHT
|
static int |
CONTROL
|
static int |
CURRENT_HI
|
static int |
CURRENT_LO
|
boolean |
debug
turns on/off various debugging messages |
static int |
defaultSensorsUpdateTime
default update time in ms for auto sensors update |
static int |
defaultSpeed
default speed for movement operations if speed isn't specified |
static int |
DIGITLEDSASCII
|
static int |
DIGITLEDSRAW
|
static int |
DIRTLEFT
|
static int |
DIRTRIGHT
|
static int |
DISTANCE_HI
|
static int |
DISTANCE_LO
|
static int |
DOCK
|
static int |
DRIVE
|
static int |
DRIVEPWM
|
static int |
DRIVEWHEELS
|
static int |
FULL
|
static int |
LEDS
|
static int |
MAX
|
static int |
MAXBUTTON_MASK
|
static float |
millimetersPerDegree
mm/deg is circumference distance divided by 360 degrees |
static float |
millimetersPerRadian
mm/rad is a circumference distance divied by two pi |
static int |
MODE_FULL
|
static int |
MODE_PASSIVE
|
static int |
MODE_SAFE
|
static int |
MODE_UNKNOWN
|
static int |
MOTOROVERCURRENTS
|
static int |
MOTORS
|
static int |
MOVERDRIVELEFT_MASK
|
static int |
MOVERDRIVERIGHT_MASK
|
static int |
MOVERMAINBRUSH_MASK
|
static int |
MOVERSIDEBRUSH_MASK
|
static int |
MOVERVACUUM_MASK
|
static int |
PLAY
|
static int |
POWER
|
static int |
POWERBUTTON_MASK
|
static int |
PWMMOTORS
|
static int |
QUERYLIST
|
static int |
REMOTE_CLEAN
|
static int |
REMOTE_FORWARD
|
static int |
REMOTE_MAX
|
static int |
REMOTE_NONE
|
static int |
REMOTE_PAUSE
|
static int |
REMOTE_POWER
|
static int |
REMOTE_SPINLEFT
|
static int |
REMOTE_SPINRIGHT
|
static int |
REMOTE_SPOT
|
static int |
REMOTEOPCODE
|
static int |
SAFE
|
static int |
SCHEDULE
|
static int |
SCHEDULINGLEDS
|
static int |
SENSORS
|
static int |
SENSORS_ALL
|
static int |
SENSORS_INTERNAL
|
static int |
SENSORS_PHYSICAL
|
static int |
SENSORS_POWER
|
static int |
SETDAYTIME
|
static int |
SONG
|
int |
speed
current speed for movement operations that don't take a speed |
static int |
SPOT
|
static int |
SPOTBUTTON_MASK
|
static int |
START
|
static int |
STOPSTARTSTREAM
|
static int |
STREAM
|
static int |
TEMPERATURE
|
static java.lang.String |
VERSION
version of the library |
static int |
VIRTUALWALL
|
static int |
VOLTAGE_HI
|
static int |
VOLTAGE_LO
|
static int |
WALL
|
static int |
wheelbase
distance between wheels on the roomba, in millimeters |
static int |
WHEELDROP_MASK
|
static int |
WHEELDROPCENT_MASK
|
static int |
WHEELDROPLEFT_MASK
|
static int |
WHEELDROPRIGHT_MASK
|
| Constructor Summary | |
|---|---|
RoombaComm()
|
|
RoombaComm(boolean autoUpdate)
|
|
RoombaComm(boolean autoUpdate,
int updateTime)
|
|
| Method Summary | |
|---|---|
short |
angle()
Angle traveled since last requested units: mm, diff in distance traveled by two drive wheels range: -32768 - 32767 |
float |
angleInDegrees()
angle since last read, but in degrees |
float |
angleInRadians()
angle since last read, but in radians |
java.lang.String |
binary(int i)
|
boolean |
bump()
Did we bump into anything |
boolean |
bumpLeft()
Left bump sensor |
boolean |
bumpRight()
Right bump sensor |
int |
bumps_wheeldrops()
lower-level func, returns raw byte |
int |
buttons()
lower-level func, returns raw byte |
int |
capacity()
Estimated charge capacity of battery units: mAh range: 0-65535 |
int |
charge()
Current charge of battery units: mAh range: 0-65535 |
int |
charging_state()
Charging state units: enumeration range: |
void |
clean()
Send the CLEAN command |
boolean |
cleanButton()
'Clean' button pressed state |
int |
cliff_frontleft()
lower-level func, returns raw byte |
int |
cliff_frontright()
lower-level func, returns raw byte |
int |
cliff_left()
lower-level func, returns raw byte |
int |
cliff_right()
lower-level func, returns raw byte |
boolean |
cliffFrontLeft()
front left cliff sensor |
boolean |
cliffFrontRight()
front right cliff sensor |
boolean |
cliffLeft()
left cliff sensor |
boolean |
cliffRight()
right cliff sensor |
boolean |
computeSafetyFault()
Compute possible safety fault. |
abstract boolean |
connect(java.lang.String portid)
Connect to a port (for serial, portid is serial port name, for net, portid is url?) |
boolean |
connected()
Returns current connected state. |
void |
control()
Send CONTROL command |
void |
createSong(int songnum,
int[] song)
Make a song |
void |
createSong(int songnum,
Note[] song)
Make a song |
short |
current()
Current flowing in or out of battery units: mA range: -332768 - 32767 |
void |
delay(int millis)
Alias to pause |
int |
dirt_left()
|
int |
dirt_right()
|
boolean |
dirt()
|
int |
dirtLeft()
amount of dirt seen by left dirt sensor |
int |
dirtRight()
amount of dirt seen by right dirt sensor |
abstract void |
disconnect()
Disconnect from a port, clean up any memory in use |
short |
distance()
Distance traveled since last requested units: mm range: -32768 - 32767 |
void |
drive(int velocity,
int radius)
Move the Roomba via the low-level velocity + radius method. |
void |
errorMessage(java.lang.String where,
java.lang.Throwable e)
General error reporting, all corraled here just in case I think of something slightly more intelligent to do. |
void |
full()
Send FULL command |
int |
getSpeed()
Get speed for movement commands |
void |
goBackward()
Go backward at the current (negative) speed |
void |
goBackward(int distance)
|
void |
goBackwardAt(int aspeed)
Go backward at a specified speed |
void |
goForward()
Go forward the current (positive) speed |
void |
goForward(int distance)
|
void |
goForwardAt(int aspeed)
Go forward at a specified speed |
void |
goStraight(int distance)
Go straight at the current speed for a specified distance. |
void |
goStraightAt(int velocity)
Go straight at a specified speed. |
java.lang.String |
hex(byte b)
|
java.lang.String |
hex(int i)
|
abstract java.lang.String[] |
listPorts()
List available ports |
void |
logmsg(java.lang.String msg)
just a little debug |
void |
max()
Send the max command |
boolean |
maxButton()
'Max' button pressed state |
int |
mode()
current ROI mode RoombaComm thinks the Roomba is in |
java.lang.String |
modeAsString()
mode as String |
int |
motor_overcurrents()
lower-level func, returns raw byte |
boolean |
motorOvercurrentDriveLeft()
overcurrent on left drive wheel |
boolean |
motorOvercurrentDriveRight()
overcurrent on right drive wheel |
boolean |
motorOvercurrentMainBrush()
overcurrent on main brush |
boolean |
motorOvercurrentSideBrush()
overcurrent on side brush |
boolean |
motorOvercurrentVacuum()
overcurrent on vacuum |
void |
pause(int millis)
Just a simple pause function. |
void |
playNote(int note,
int duration)
Play a musical note Does it via the hacky method of defining a one-note song & playing it Uses up song slot 15. |
void |
playSong(int songnum)
|
boolean |
powerButton()
'Power' button pressed state |
void |
powerOff()
Power off the Roomba. |
void |
println(java.lang.String s)
|
void |
queryList(byte[] sensorList,
int returnLen)
Query a list of sensors. |
int |
remote_opcode()
lower-level func, returns raw byte |
void |
reset()
Reset Roomba after a fault. |
void |
safe()
Send SAFE command |
boolean |
safetyFault()
|
abstract boolean |
send(byte[] bytes)
Send given byte array to Roomba. |
abstract boolean |
send(int b)
Send a single byte to the Roomba (defined as int because of stupid java signed bytes) |
void |
sensors()
get all sensor data |
void |
sensors(int packetcode)
Send the SENSORS command with one of the SENSORS_ arguments Typically, one does "sensors(SENSORS_ALL)" to get all sensor data |
java.lang.String |
sensorsAsString()
|
boolean |
sensorsAutoUpdate()
|
int |
sensorsUpdateTime()
|
boolean |
sensorsValid()
|
void |
setLEDs(boolean status_green,
boolean status_red,
boolean spot,
boolean clean,
boolean max,
boolean dirt,
int power_color,
int power_intensity)
Turns on/off the various LEDs. |
void |
setMotors(boolean mainbrush,
boolean vacuum,
boolean sidebrush)
Turns on/off the non-drive motors (main brush, vacuum, sidebrush). |
void |
setSensorsAutoUpdate(boolean b)
|
void |
setSensorsUpdateTime(int i)
|
void |
setSpeed(int s)
Set speed for movement commands |
void |
spin(int angle)
Spin right or spin left a particular number of degrees |
void |
spinLeft()
Spin in place anti-clockwise, at the current speed |
void |
spinLeft(int angle)
Spin left a specified angle at a specified speed |
void |
spinLeftAt(int aspeed)
Spin in place anti-clockwise, at the current speed. |
void |
spinRight()
Spin in place clockwise, at the current speed |
void |
spinRight(int angle)
Spin right the current speed for a specified angle |
void |
spinRightAt(int aspeed)
Spin in place clockwise, at the current speed. |
void |
spot()
Send the SPOT command |
boolean |
spotButton()
'Spot' button pressed state |
void |
start()
Send START command |
void |
startAutoUpdate()
|
void |
startup()
Put Roomba in safe mode. |
void |
stop()
Stop Rooomba's motion. |
byte |
temperature()
temperature of battery units: degrees Celcius range: -128 - 127 |
static short |
toShort(byte hi,
byte lo)
|
static int |
toUnsignedShort(byte hi,
byte lo)
|
void |
turn(int radius)
|
void |
turnLeft()
|
void |
turnRight()
|
abstract boolean |
updateSensors()
Query Roomba for sensor status and sync its state with this object's Subclasses should query Roomba and fill up 'sensor_bytes' with the full sensor data set If a RooombaComm object is constructed with 'autoUpdate' true, calling this method is not required because a separate thread is created to do sensor updating. |
void |
vacuum(boolean state)
Turn all vacuum motors on or off according to state |
int |
virtual_wall()
lower-level func, returns raw byte |
int |
voltage()
Voltage of battery units: mV range: 0 - 65535 |
void |
wakeup()
Wake's Roomba up, if possible, thus optional To wake up the Roomba requires twiddling its DD line, often hooked up to the RS-232 DTR line, which may not be available in some implementations |
boolean |
wall()
Can we see a wall? |
boolean |
wheelDropCenter()
Center wheeldrop sensor |
boolean |
wheelDropLeft()
Left wheeldrop sensor |
boolean |
wheelDropRight()
Right wheeldrop sensor |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String VERSION
public boolean debug
public static final int wheelbase
public static final float millimetersPerDegree
public static final float millimetersPerRadian
public static final int defaultSpeed
public static final int defaultSensorsUpdateTime
public int speed
public static final int MODE_UNKNOWN
public static final int MODE_PASSIVE
public static final int MODE_SAFE
public static final int MODE_FULL
public static final int START
public static final int BAUD
public static final int CONTROL
public static final int SAFE
public static final int FULL
public static final int POWER
public static final int SPOT
public static final int CLEAN
public static final int MAX
public static final int DRIVE
public static final int MOTORS
public static final int LEDS
public static final int SONG
public static final int PLAY
public static final int SENSORS
public static final int DOCK
public static final int PWMMOTORS
public static final int DRIVEWHEELS
public static final int DRIVEPWM
public static final int STREAM
public static final int QUERYLIST
public static final int STOPSTARTSTREAM
public static final int SCHEDULINGLEDS
public static final int DIGITLEDSRAW
public static final int DIGITLEDSASCII
public static final int BUTTONSCMD
public static final int SCHEDULE
public static final int SETDAYTIME
public static final int BUMPSWHEELDROPS
public static final int WALL
public static final int CLIFFLEFT
public static final int CLIFFFRONTLEFT
public static final int CLIFFFRONTRIGHT
public static final int CLIFFRIGHT
public static final int VIRTUALWALL
public static final int MOTOROVERCURRENTS
public static final int DIRTLEFT
public static final int DIRTRIGHT
public static final int REMOTEOPCODE
public static final int BUTTONS
public static final int DISTANCE_HI
public static final int DISTANCE_LO
public static final int ANGLE_HI
public static final int ANGLE_LO
public static final int CHARGINGSTATE
public static final int VOLTAGE_HI
public static final int VOLTAGE_LO
public static final int CURRENT_HI
public static final int CURRENT_LO
public static final int TEMPERATURE
public static final int CHARGE_HI
public static final int CHARGE_LO
public static final int CAPACITY_HI
public static final int CAPACITY_LO
public static final int WHEELDROP_MASK
public static final int BUMP_MASK
public static final int BUMPRIGHT_MASK
public static final int BUMPLEFT_MASK
public static final int WHEELDROPRIGHT_MASK
public static final int WHEELDROPLEFT_MASK
public static final int WHEELDROPCENT_MASK
public static final int MOVERDRIVELEFT_MASK
public static final int MOVERDRIVERIGHT_MASK
public static final int MOVERMAINBRUSH_MASK
public static final int MOVERVACUUM_MASK
public static final int MOVERSIDEBRUSH_MASK
public static final int POWERBUTTON_MASK
public static final int SPOTBUTTON_MASK
public static final int CLEANBUTTON_MASK
public static final int MAXBUTTON_MASK
public static final int SENSORS_ALL
public static final int SENSORS_PHYSICAL
public static final int SENSORS_INTERNAL
public static final int SENSORS_POWER
public static final int REMOTE_NONE
public static final int REMOTE_POWER
public static final int REMOTE_PAUSE
public static final int REMOTE_CLEAN
public static final int REMOTE_MAX
public static final int REMOTE_SPOT
public static final int REMOTE_SPINLEFT
public static final int REMOTE_FORWARD
public static final int REMOTE_SPINRIGHT
| Constructor Detail |
|---|
public RoombaComm()
public RoombaComm(boolean autoUpdate)
public RoombaComm(boolean autoUpdate,
int updateTime)
| Method Detail |
|---|
public void startAutoUpdate()
public abstract java.lang.String[] listPorts()
public abstract boolean connect(java.lang.String portid)
public abstract void disconnect()
public abstract boolean send(byte[] bytes)
bytes - byte array of ROI commands to send
public abstract boolean send(int b)
b - byte of an ROI command to send
public abstract boolean updateSensors()
public void wakeup()
public void startup()
reset()public void reset()
startup(),
updateSensors()public void start()
public void control()
public void safe()
public void full()
public void powerOff()
wakeup()public void spot()
public void clean()
public void max()
public void sensors(int packetcode)
packetcode - one of SENSORS_ALL, SENSORS_PHYSICAL,
SENSORS_INTERNAL, or SENSORS_POWER, or for roomba 5xx, it
is the sensor packet number (from the spec)public void sensors()
public void queryList(byte[] sensorList,
int returnLen)
sensorList - A byte array containing the sensor groups requested to be readreturnLen - The number of bytes of data expected to be returned from roombapublic void delay(int millis)
pause(int)public void pause(int millis)
millis - number of milliseconds to waitpublic void stop()
public void setSpeed(int s)
public int getSpeed()
public void goStraight(int distance)
distance - distance in millimeters, positive or negativepublic void goForward(int distance)
distance - distance in millimeters, positivepublic void goBackward(int distance)
distance - distance in millimeters, positivepublic void turnLeft()
public void turnRight()
public void turn(int radius)
public void spin(int angle)
angle - angle in degrees,
positive to spin left, negative to spin rightpublic void spinRight(int angle)
angle - angle in degrees, positivepublic void spinLeft(int angle)
angle - angle in degrees, positivepublic void spinLeft()
public void spinRight()
public void spinLeftAt(int aspeed)
aspeed - speed to spin atpublic void spinRightAt(int aspeed)
aspeed - speed to spin at, positivepublic void goStraightAt(int velocity)
velocity - velocity of motion in mm/secpublic void goForward()
public void goBackward()
public void goForwardAt(int aspeed)
public void goBackwardAt(int aspeed)
public void drive(int velocity,
int radius)
velocity - speed in millimeters/second,
positive forward, negative backwardradius - radius of turn in millimeters
public void playNote(int note,
int duration)
note - a note number from 31 (G0) to 127 (G8)duration - duration of note in 1/64ths of a secondpublic void playSong(int songnum)
public void createSong(int songnum,
int[] song)
songnum - number of song to definesong - array of songnotes,
even entries are notenums, odd are duration of 1/6ths
public void createSong(int songnum,
Note[] song)
songnum - number of song to definesong - array of Notes
public void setMotors(boolean mainbrush,
boolean vacuum,
boolean sidebrush)
mainbrush - mainbrush motor on/off statevacuum - vacuum motor on/off statesidebrush - sidebrush motor on/off state
public void setLEDs(boolean status_green,
boolean status_red,
boolean spot,
boolean clean,
boolean max,
boolean dirt,
int power_color,
int power_intensity)
public void vacuum(boolean state)
state - true to turn on vacuum function, false to turn it offpublic boolean computeSafetyFault()
updateSensors()public boolean connected()
public int mode()
public java.lang.String modeAsString()
public boolean sensorsAutoUpdate()
public void setSensorsAutoUpdate(boolean b)
public int sensorsUpdateTime()
public void setSensorsUpdateTime(int i)
public boolean safetyFault()
public boolean sensorsValid()
public java.lang.String sensorsAsString()
public boolean bump()
public boolean bumpLeft()
public boolean bumpRight()
public boolean wheelDropLeft()
public boolean wheelDropRight()
public boolean wheelDropCenter()
public boolean wall()
public boolean dirt()
public int dirtLeft()
public int dirtRight()
public boolean cliffLeft()
public boolean cliffFrontLeft()
public boolean cliffFrontRight()
public boolean cliffRight()
public boolean motorOvercurrentDriveLeft()
public boolean motorOvercurrentDriveRight()
public boolean motorOvercurrentMainBrush()
public boolean motorOvercurrentVacuum()
public boolean motorOvercurrentSideBrush()
public boolean powerButton()
public boolean spotButton()
public boolean cleanButton()
public boolean maxButton()
public int bumps_wheeldrops()
public int cliff_left()
public int cliff_frontleft()
public int cliff_frontright()
public int cliff_right()
public int virtual_wall()
public int motor_overcurrents()
public int dirt_left()
public int dirt_right()
public int remote_opcode()
public int buttons()
public short distance()
public short angle()
public float angleInDegrees()
public float angleInRadians()
public int charging_state()
public int voltage()
public short current()
public byte temperature()
public int charge()
public int capacity()
public static final short toShort(byte hi,
byte lo)
public static final int toUnsignedShort(byte hi,
byte lo)
public void println(java.lang.String s)
public java.lang.String hex(byte b)
public java.lang.String hex(int i)
public java.lang.String binary(int i)
public void logmsg(java.lang.String msg)
public void errorMessage(java.lang.String where,
java.lang.Throwable e)
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||