|
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.khepera3.Khepera3IRSensor
public class Khepera3IRSensor
A class for reading the Khepera 3's IR sensors. The IR sensors measure the amount of infrared (IR) light presents at the sensor. The sensor returns an integer where the smaller the number, the stronger the IR light is. Values are in the range of [0...4095]. The Khepera 3 has 11 IR sensors. Nine sensors are outward facing and two are downward facing. Figure 1 below shows the locations of the sensors and the index of the sensor value.

Khepera3IRSensor, Khepera3ProximitySensor
and Khepera3SonarSensor objects. 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:
Khepera3IRSensor kir = new Khepera3IRSensor(); |
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 frontLeftIR = kir.getValue(2); |
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 |
Khepera3IRSensor.IRDisplay
Display for the Khepera3IRSensor. |
| Field Summary | |
|---|---|
static int |
BACK_LEFT
The Khepera's back left sensor. |
static int |
BACK_RIGHT
The Khepera's back right sensor. |
static int[] |
FRONT_GROUP
Sensor group for the Khepera 3 front sensors. |
static int |
FRONT_LEFT
The Khepera's front-left sensor. |
static int |
FRONT_RIGHT
The Khepera's front-right sensor. |
static int[] |
GROUND_GROUP
Sensor group for the Khepera 3 ground sensors. |
static int |
GROUND_LEFT
The Khepera's left ground sensor. |
static int |
GROUND_RIGHT
The Khepera's right ground sensor. |
static int |
LEFT
The Khepera's left sensor. |
static int |
LEFT_FRONT
The Khepera's left-front sensor. |
static int[] |
LEFT_GROUP
Sensor group for the Khepera 3 left sensors. |
static int[] |
NON_GROUND_GROUP
Sensor group for all of the outward facing Khepera 3 sensors. |
static int |
REAR
The Khepera's rear sensor. |
static int[] |
REAR_GROUP
Sensor group for the Khepera 3 rear sensors. |
static int |
RIGHT
The Khepera's right sensor. |
static int |
RIGHT_FRONT
The Khepera's right-front sensor. |
static int[] |
RIGHT_GROUP
Sensor group for the Khepera 3 right 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 | |
|---|---|
Khepera3IRSensor()
Creates a new Khepera3IRSensor |
|
| Method Summary | |
|---|---|
protected DeviceDisplay[] |
createGUIObjects()
Get the object that is the GUI for this Khepera3IRSensor. |
void |
freeze()
Does nothing. |
protected void |
read(String cmd)
Send a message to the server requesting the information from the sensors. |
void |
readStateFromRobot()
Uses the O command to get the ambient light data from each sensor. |
| 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[] REAR_GROUP
public static final int[] LEFT_GROUP
public static final int[] RIGHT_GROUP
public static final int[] GROUND_GROUP
public static final int[] NON_GROUND_GROUP
public static final int BACK_LEFT
public static final int LEFT
public static final int LEFT_FRONT
public static final int FRONT_LEFT
public static final int FRONT_RIGHT
public static final int RIGHT_FRONT
public static final int RIGHT
public static final int BACK_RIGHT
public static final int REAR
public static final int GROUND_RIGHT
public static final int GROUND_LEFT
| Constructor Detail |
|---|
public Khepera3IRSensor()
| Method Detail |
|---|
public void readStateFromRobot()
readStateFromRobot in class DeviceRobotCommunicationException - if unable to communicate with the
Khepera 3.protected void read(String cmd)
cmd - the command to send to the server
RobotCommunicationException - if unable to communicate with the
Khepera 3.public void freeze()
freeze in class Deviceprotected DeviceDisplay[] createGUIObjects()
createGUIObjects in class Device
|
dLife Home Page | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||