|
dLife Home Page | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.Observable
dlife.robot.Device
dlife.robot.ArraySensor<Boolean>
dlife.robot.pioneer.PioneerBumpers
public class PioneerBumpers
A class for reading the state of the Pioneer's bumpers. Each sensor reading corresponds to the value of a single bumper. The assignment between the readings and the particular sensors are expressed by the class constants. Each sensor reading is a boolean value indicating if the bumper is pressed (true) or not (false).
This sensor displays readings for the 10 standard bumpers on the Pioneer (see figure 1). If either the front or rear bumpers are not currently installed then the readings for the non-installed bumpers will be false.
Methods are provided for reading the bumpers in a variety of ways as
illustrated below. The sample code shown assumes that a
PionerBumpers sensor has been created and added to the robot
(typically in the startUp method of a Controller)
as shown: here:
PioneerBumpers pb = new PioneerBumpers(); |
The state of an individual bumper can be checked by index:
boolean front = pb.bump(2); |
It is also possible to check if any of the bumpers in a group or list is currently triggered:
boolean any = pb.bump(); |
| Field Summary | |
|---|---|
static int[] |
ALL
Sensor group for all of the bumpers. |
static int[] |
FRONT
Sensor group for all of the front end bumpers. |
static int[] |
LEFT
Sensor group for the two leftmost bumpers. |
static int[] |
REAR
Sensor group for all of the rear end bumpers. |
static int[] |
RIGHT
Sensor group for the two rightmost bumpers. |
| Fields inherited from class dlife.robot.ArraySensor |
|---|
length, values |
| Fields inherited from class dlife.robot.Device |
|---|
DEFAULT_GUI_UPDATE_DELAY, DEFAULT_READ_DELAY, myRobot, readCount |
| Constructor Summary | |
|---|---|
PioneerBumpers()
Construct a new PioneerBumpers. |
|
| Method Summary | |
|---|---|
boolean |
bump()
Determine if any of the bumpers are triggered. |
boolean |
bump(int... bumperList)
Determine if any of the listed bumpers are triggered. |
protected DeviceDisplay[] |
createGUIObjects()
Get the object that is the GUI for this PioneerBumpers sensor. |
void |
freeze()
Does nothing. |
static void |
main(String[] args)
A little test program for the PioneerBumpers. |
void |
readStateFromRobot()
Get the current bumper readings from the Pioneer. |
| Methods inherited from class dlife.robot.ArraySensor |
|---|
getAverage, getAverage, getMaximum, getMaximum, getMaximumIndex, getMaximumIndex, getMinimum, getMinimum, getMinimumIndex, getMinimumIndex, getNumValues, getSubset, getValue, getValues |
| Methods inherited from class dlife.robot.Device |
|---|
getAutoRead, getGUI, getGUIUpdateDelay, getReadDelay, getRobot, getSensorReadCount, getSensorReadRate, setAutoRead, setGUIUpdateDelay, setReadDelay, setRobot, shutDown, startAutoReadTimer, startUp, stopAutoReadTimer |
| Methods inherited from class java.util.Observable |
|---|
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int[] FRONT
public static final int[] REAR
public static final int[] LEFT
public static final int[] RIGHT
public static final int[] ALL
| Constructor Detail |
|---|
public PioneerBumpers()
| Method Detail |
|---|
public boolean bump(int... bumperList)
bumperList - a comma delimited list of the indices of the bumpers to
check.
IllegalArgumentException - if any of the bumper indices listed are
invalid.public boolean bump()
public void readStateFromRobot()
readStateFromRobot in class DeviceRobotCommunicationException - if unable to communicate with the
Pioneer.public void freeze()
freeze in class Deviceprotected DeviceDisplay[] createGUIObjects()
createGUIObjects in class Device
public static void main(String[] args)
throws Exception
args - none
Exception
|
dLife Home Page | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||