|
||||||||
| 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 | |
|---|---|
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 float |
millimetersPerDegree
mm/deg is circumference distance divided by 360 degrees |
static float |
millimetersPerRadian
mm/rad is a circumference distance divied by two pi |
int |
speed
current speed for movement operations that don't take a speed |
static java.lang.String |
VERSION
version of the library |
static int |
wheelbase
distance between wheels on the roomba, in millimeters |
| 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 SCI 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)
|
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
| 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 SCI commands to send
public abstract boolean send(int b)
b - byte of an SCI 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_POWERpublic void sensors()
public 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 | |||||||