dLife Home Page

dlife.robot.hemisson
Class HemissonIRSensor

java.lang.Object
  extended by java.util.Observable
      extended by dlife.robot.Device
          extended by dlife.robot.ArraySensor<Integer>
              extended by dlife.robot.hemisson.HemissonIRSensor
Direct Known Subclasses:
HemissonProximitySensor

public class HemissonIRSensor
extends ArraySensor<Integer>

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.


Figure 1: A Hemisson robot with blue-tooth radio module attached and and the IR/Proximity sensors labeled.
Red circles represent outward facing sensors.
Yellow circles represent downward facing sensors.
Numerals in the circles correspond to the index of the sensor data
in the 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:

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:
Apr 17, 2007
Author:
Grant Braught, Dickinson College

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

FRONT_GROUP

public static final int[] FRONT_GROUP
Sensor group for the Hemisson's front sensors. This group includes sensors 2, 0 and 1 in that order.


RIGHT_GROUP

public static final int[] RIGHT_GROUP
Sensor group for the Hemisson's right side sensors. This group includes sensors 1 and 3 in that order.


LEFT_GROUP

public static final int[] LEFT_GROUP
Sensor group for the Hemisson's left side sensors. This group includes sensors 2 and 4 in that order.


GROUND_GROUP

public static final int[] GROUND_GROUP
Sensor group for the Hemisson's ground facing sensors. This group includes sensors 6 and 7 in that order.


NON_GROUND_GROUP

public static final int[] NON_GROUND_GROUP
Sensor group for all of the Hemisson's outward facing sensors. This group includes sensors 0-5 in that order.


FRONT

public static final int FRONT
The Hemisson's front sensor.

See Also:
Constant Field Values

FRONT_RIGHT

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

See Also:
Constant Field Values

FRONT_LEFT

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

See Also:
Constant Field Values

RIGHT

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

See Also:
Constant Field Values

LEFT

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

See Also:
Constant Field Values

REAR

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

See Also:
Constant Field Values

GROUND_RIGHT

public static final int GROUND_RIGHT
The Hemisson's front right downward facing sensor.

See Also:
Constant Field Values

GROUND_LEFT

public static final int GROUND_LEFT
The Hemisson's front left downward facing sensor.

See Also:
Constant Field Values
Constructor Detail

HemissonIRSensor

public HemissonIRSensor()
Construct a new HemissonIRSensor.

Method Detail

readStateFromRobot

public void readStateFromRobot()
Get the current IR light sensor readings from the Hemisson. The new values are copied into the values array defined by the IntegerArraySensor class.

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

freeze

public void freeze()
Does nothing. There is no motion associated with an IR sensor to stop.

Specified by:
freeze in class Device

read

protected void read(String cmd)
Protected method to allow the sub-class for the proximity sensor to share this code.

Parameters:
cmd - the command string for reading the sensor.
Throws:
RobotCommunicationException - if unable to communicate with the Hemisson.

createGUIObjects

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

Specified by:
createGUIObjects in class Device
Returns:
an array of DeviceDisplay subclass objects that make up the GUI for this Device.

main

public static void main(String[] args)
A little test program for the HemissonIRSensor. This creates a new Hemisson and a new HemissonIRSensor. It displays the GUI for the ir sensor readings until the window is closed.

Parameters:
args - none

dLife Home Page