|
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.khepera2.Khepera2IRSensor
public class Khepera2IRSensor
A class for reading the Khepera2's infrared (IR) sensors. Each IR sensor reports an integer value in the range [0...1023] 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.

Khepera2IRSensor and Khepera2ProximitySensor
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:
Khepera2IRSensor kir = new Khepera2IRSensor(); |
It is possible to retrieve all or a sub-set of the sensor readings as an
ArrayList:
ArrayList<Integer> allVals = kir.getValues(); |
It is also possible to retrieve an individual sensor reading, either by index or by using one of the defined class constants:
int LeftIR = kir.getValue(0); |
Methods are also provided for obtaining the maximum, minimum or average of a group of sensor readings:
int maxIR = kir.getMaximum(); |
| Nested Class Summary | |
|---|---|
protected static class |
Khepera2IRSensor.IRSensorDisplay
A display for the values of a Khepera2IRSensor. |
| Field Summary | |
|---|---|
static int[] |
ALL
Sensor group containing all of the sensors. |
static int[] |
FRONT_GROUP
Sensor group for the Khepera2's front sensors. |
static int |
FRONT_LEFT
The Khepera2's front left sensor. |
static int |
FRONT_RIGHT
The Khepera2's front right sensor. |
static int |
LEFT
The Khepera2's left sensor. |
static int |
LEFT_FRONT
The Khepera2's left front sensor. |
static int[] |
LEFT_GROUP
Sensor group for the Khepera2's left side sensors. |
static int |
LEFT_REAR
The Khepera2's left rear sensor. |
static int[] |
REAR_GROUP
Sensor group for the Khepera2's rear facing sensors. |
static int |
RIGHT
The Khepera2's right sensor. |
static int |
RIGHT_FRONT
The Khepera2's right front sensor. |
static int[] |
RIGHT_GROUP
Sensor group for the Khepera2's right side sensors. |
static int |
RIGHT_REAR
The Khepera2's right rear sensor. |
| 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 | |
|---|---|
Khepera2IRSensor()
Construct a new Khepera2IRSensor. |
|
| Method Summary | |
|---|---|
protected DeviceDisplay[] |
createGUIObjects()
Get the object that is the GUI for this Khepera2IRSensor. |
void |
freeze()
Does nothing. |
static void |
main(String[] args)
A little test program for the Khepera2IRSensor. |
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 Khepara2. |
| 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[] REAR_GROUP
public static final int[] ALL
public static final int FRONT_LEFT
public static final int FRONT_RIGHT
public static final int LEFT_FRONT
public static final int RIGHT_FRONT
public static final int LEFT
public static final int RIGHT
public static final int RIGHT_REAR
public static final int LEFT_REAR
| Constructor Detail |
|---|
public Khepera2IRSensor()
| Method Detail |
|---|
public void readStateFromRobot()
readStateFromRobot in class DeviceRobotCommunicationException - if unable to communicate with the
Khepara2.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
Khepara2.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 | |||||||||