|
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<Integer>
dlife.robot.hemisson.HemissonIRSensor
public class HemissonIRSensor
A class for reading the Hemisson's infrared (IR) sensors. Each IR sensor reports an integer value in the range [0...255] with smaller values indicating more intense IR light. These sensors are passive, they detect IR light that is present in the robot's environment. The IR sensors are arranged around the robot as shown in Figure 1 below.

HemissonIRSensor and HemissonProximitySensor
objects.
Methods are provided for reading the sensors in a variety of ways as
illustrated below. The sample code shown assumes that an IR sensor has been
created and added to the robot (typically in the startUp method
of a Controller) as shown: here:
HemissonIRSensor hir = new HemissonIRSensor(); |
It is possible to retrieve all or a sub-set of the sensor readings as an
ArrayList:
ArrayList<Integer> allVals = hir.getValues(); |
It is also possible to retrieve an individual sensor reading, either by index or by using one of the defined class constants:
int frontIR = hir.getValue(0); |
Methods are also provided for obtaining the maximum, minimum or average of a group of sensor readings:
int maxIR = hir.getMaximum(); |
| Nested Class Summary | |
|---|---|
protected static class |
HemissonIRSensor.IRSensorDisplay
A display for the values of a HemissonIRSensor. |
| Field Summary | |
|---|---|
static int |
FRONT
The Hemisson's front sensor. |
static int[] |
FRONT_GROUP
Sensor group for the Hemisson's front sensors. |
static int |
FRONT_LEFT
The Hemisson's front left sensor. |
static int |
FRONT_RIGHT
The Hemisson's front right sensor. |
static int[] |
GROUND_GROUP
Sensor group for the Hemisson's ground facing sensors. |
static int |
GROUND_LEFT
The Hemisson's front left downward facing sensor. |
static int |
GROUND_RIGHT
The Hemisson's front right downward facing sensor. |
static int |
LEFT
The Hemisson's left sensor. |
static int[] |
LEFT_GROUP
Sensor group for the Hemisson's left side sensors. |
static int[] |
NON_GROUND_GROUP
Sensor group for all of the Hemisson's outward facing sensors. |
static int |
REAR
The Hemisson's rear sensor. |
static int |
RIGHT
The Hemisson's right sensor. |
static int[] |
RIGHT_GROUP
Sensor group for the Hemisson's right side sensors. |
| 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 | |
|---|---|
HemissonIRSensor()
Construct a new HemissonIRSensor. |
|
| Method Summary | |
|---|---|
protected DeviceDisplay[] |
createGUIObjects()
Get the object that is the GUI for this HemissonIRSensor. |
void |
freeze()
Does nothing. |
static void |
main(String[] args)
A little test program for the HemissonIRSensor. |
protected void |
read(String cmd)
Protected method to allow the sub-class for the proximity sensor to share this code. |
void |
readStateFromRobot()
Get the current IR light sensor readings from the Hemisson. |
| 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_GROUP
public static final int[] RIGHT_GROUP
public static final int[] LEFT_GROUP
public static final int[] GROUND_GROUP
public static final int[] NON_GROUND_GROUP
public static final int FRONT
public static final int FRONT_RIGHT
public static final int FRONT_LEFT
public static final int RIGHT
public static final int LEFT
public static final int REAR
public static final int GROUND_RIGHT
public static final int GROUND_LEFT
| Constructor Detail |
|---|
public HemissonIRSensor()
| Method Detail |
|---|
public void readStateFromRobot()
readStateFromRobot in class DeviceRobotCommunicationException - if unable to communicate with the
Hemisson.public void freeze()
freeze in class Deviceprotected void read(String cmd)
cmd - the command string for reading the sensor.
RobotCommunicationException - if unable to communicate with the
Hemisson.protected DeviceDisplay[] createGUIObjects()
createGUIObjects in class Devicepublic static void main(String[] args)
args - none
|
dLife Home Page | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||