dLife Home Page

dlife.robot.khepera3
Class Khepera3IRSensor

java.lang.Object
  extended by java.util.Observable
      extended by dlife.robot.Device
          extended by dlife.robot.ArraySensor<Integer>
              extended by dlife.robot.khepera3.Khepera3IRSensor
Direct Known Subclasses:
Khepera3ProximitySensor

public class Khepera3IRSensor
extends ArraySensor<Integer>

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.


Figure 1: A Khepera 3 robot with the IR/Proximity sensors labeled.
Red circles represent outward facing IR/Proximity sensors.
Yellow circles represent downward facing IR/Proximity sensors.
Blue circles represent sonar sensors.
Numerals in the circles correspond to the index of the sensor data
in the 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:

It is possible to retrieve all or a sub-set of the sensor readings as an ArrayList:

It is also possible to retrieve an individual sensor reading, either by index or by using one of the defined class constants:

Methods are also provided for obtaining the maximum, minimum or average of a group of sensor readings:

Version:
August 25, 2009
Author:
Russell Toris, Grant Braught, Dickinson College

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

FRONT_GROUP

public static final int[] FRONT_GROUP
Sensor group for the Khepera 3 front sensors.


REAR_GROUP

public static final int[] REAR_GROUP
Sensor group for the Khepera 3 rear sensors.


LEFT_GROUP

public static final int[] LEFT_GROUP
Sensor group for the Khepera 3 left sensors.


RIGHT_GROUP

public static final int[] RIGHT_GROUP
Sensor group for the Khepera 3 right sensors.


GROUND_GROUP

public static final int[] GROUND_GROUP
Sensor group for the Khepera 3 ground sensors.


NON_GROUND_GROUP

public static final int[] NON_GROUND_GROUP
Sensor group for all of the outward facing Khepera 3 sensors.


BACK_LEFT

public static final int BACK_LEFT
The Khepera's back left sensor.

See Also:
Constant Field Values

LEFT

public static final int LEFT
The Khepera's left sensor.

See Also:
Constant Field Values

LEFT_FRONT

public static final int LEFT_FRONT
The Khepera's left-front sensor.

See Also:
Constant Field Values

FRONT_LEFT

public static final int FRONT_LEFT
The Khepera's front-left sensor.

See Also:
Constant Field Values

FRONT_RIGHT

public static final int FRONT_RIGHT
The Khepera's front-right sensor.

See Also:
Constant Field Values

RIGHT_FRONT

public static final int RIGHT_FRONT
The Khepera's right-front sensor.

See Also:
Constant Field Values

RIGHT

public static final int RIGHT
The Khepera's right sensor.

See Also:
Constant Field Values

BACK_RIGHT

public static final int BACK_RIGHT
The Khepera's back right sensor.

See Also:
Constant Field Values

REAR

public static final int REAR
The Khepera's rear sensor.

See Also:
Constant Field Values

GROUND_RIGHT

public static final int GROUND_RIGHT
The Khepera's right ground sensor.

See Also:
Constant Field Values

GROUND_LEFT

public static final int GROUND_LEFT
The Khepera's left ground sensor.

See Also:
Constant Field Values
Constructor Detail

Khepera3IRSensor

public Khepera3IRSensor()
Creates a new Khepera3IRSensor

Method Detail

readStateFromRobot

public void readStateFromRobot()
Uses the O command to get the ambient light data from each sensor.

Specified by:
readStateFromRobot in class Device
Throws:
RobotCommunicationException - if unable to communicate with the Khepera 3.

read

protected void read(String cmd)
Send a message to the server requesting the information from the sensors. This data is then split up and assigned to its appropriate sensor.

Parameters:
cmd - the command to send to the server
Throws:
RobotCommunicationException - if unable to communicate with the Khepera 3.

freeze

public void freeze()
Does nothing. The IR sensor does not move.

Specified by:
freeze in class Device

createGUIObjects

protected DeviceDisplay[] createGUIObjects()
Get the object that is the GUI for this Khepera3IRSensor.

Specified by:
createGUIObjects in class Device
Returns:
a reference to the GUI.

dLife Home Page