simbad.sim
Class RangeSensorBelt

java.lang.Object
  extended bysimbad.sim.BaseObject
      extended bysimbad.sim.Device
          extended bysimbad.sim.SensorDevice
              extended bysimbad.sim.PickSensor
                  extended bysimbad.sim.RangeSensorBelt

public class RangeSensorBelt
extends PickSensor

This class models a circular belt of range sensors : Sonar , Bumpers (future : Laser, Ir). Sensors are arranged circularly around the robot. User can access to the measurement and hits state of each sensor individualy or obtain an average measurement in a quadrant.

Note that the sensors are not affected by noise. however you can easily add some gaussian noise with the java.util.Random class.
Random generator = new Random(seed);
and
value = sonars.getMeasurement(0)+generator.nextGaussian()*stddev;


Implementation notes : We use java 3D picking feature to emulate sensing. A PickCylinderRay is used on each update to test whether there is an potential obstacle. Each ray is then checked with a PickSegement.


Field Summary
static int FLAG_SHOW_FULL_SENSOR_RAY
           
static int TYPE_BUMPER
           
static int TYPE_IR
           
static int TYPE_LASER
           
static int TYPE_SONAR
           
 
Constructor Summary
RangeSensorBelt(float radius, float minRange, float maxRange, int nbsensors, int type, int flags)
          Constructs a RangeSensorBelt.
RangeSensorBelt(javax.vecmath.Vector3d[] positions, javax.vecmath.Vector3d[] directions, int type, int flags)
          Constructs a RangeSensorBelt.
 
Method Summary
 javax.swing.JPanel createInspectorPanel()
          Creates the panel associated to the device.
 int getBackLeftQuadrantHits()
          Returns number of sensor hits in the back left quadrant: [PI/2,PI].
 double getBackLeftQuadrantMeasurement()
          Returns the averaged measure of the sensors situated in the bacck left quadrant: [PI/2,PI].
 int getBackQuadrantHits()
          Returns number of sensor hits in the back quadrant: [3PI/4,5PI/4].
 double getBackQuadrantMeasurement()
          Returns the averaged measure of the sensors situated in the back quadrant: [3PI/4,4*PI/4].
 int getBackRightQuadrantHits()
          Returns number of sensor hits in the back right quadrant: [PI,3PI/2].
 double getBackRightQuadrantMeasurement()
          Returns the averaged measure of the sensors situated in the back right quadrant: [PI,3*PI/2].
 int getFrontLeftQuadrantHits()
          Returns number of sensor hits in the front left quadrant: [0,PI/4].
 double getFrontLeftQuadrantMeasurement()
          Returns the averaged measure of the sensors situated in the front left quadrant: [0,PI/4].
 int getFrontQuadrantHits()
          Returns number of sensor hits in the front quadrant: [-PI/4,PI/4].
 double getFrontQuadrantMeasurement()
          Returns the averaged measure of the sensors situated in the front quadrant: [-PI/4,PI/4].
 int getFrontRightQuadrantHits()
          Returns number of sensor hits in the front right quadrant: [3PI/2,2*PI].
 double getFrontRightQuadrantMeasurement()
          Returns the averaged measure of the sensors situated in the front right quadrant: [3PI/2,2*PI].
 int getLeftQuadrantHits()
          Returns number of sensor hits in the left quadrant: [PI/4,PI*3/4].
 double getLeftQuadrantMeasurement()
          Returns the averaged measure of the sensors situated in the left quadrant: [PI/4,PI*3/4].
 float getMaxRange()
          Returns the maximum sensing range in meters.
 double getMeasurement(int sensorNum)
          Returns the last measure collected for the individual sensor.
 int getNumSensors()
          Return the number of individual sensor in the belt.
 int getQuadrantHits(double minAngle, double maxAngle)
          Returns number of hits in quadrant [minAngle,maxAngle].
 double getQuadrantMeasurement(double minAngle, double maxAngle)
          Returns the averaged measure of the sensors situated in quadrant [minAngle,maxAngle].
 int getRightQuadrantHits()
          Returns number of sensor hits in the right quadrant: [5PI/4,7PI/4].
 double getRightQuadrantMeasurement()
          Returns the averaged measure of the sensors situated in the right quadrant: [5*PI/4,7*PI/4].
 double getSensorAngle(int sensorNum)
          Returns the angle of this sensor.
 boolean hasHit(int sensorNum)
          Returns the hit state of the sensor.
 boolean oneHasHit()
          Returns true if one of the sensors has hit.
 
Methods inherited from class simbad.sim.Device
attach, detach, getCanBeTraversed, getName, getRotationTransform, getTranslationTransform, getUpdatePerSecond, rotateY, setCanBeTraversed, setColor, setUpdateOnEachFrame, setUpdatePerSecond, translateTo
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TYPE_SONAR

public static final int TYPE_SONAR
See Also:
Constant Field Values

TYPE_IR

public static final int TYPE_IR
See Also:
Constant Field Values

TYPE_LASER

public static final int TYPE_LASER
See Also:
Constant Field Values

TYPE_BUMPER

public static final int TYPE_BUMPER
See Also:
Constant Field Values

FLAG_SHOW_FULL_SENSOR_RAY

public static final int FLAG_SHOW_FULL_SENSOR_RAY
See Also:
Constant Field Values
Constructor Detail

RangeSensorBelt

public RangeSensorBelt(float radius,
                       float minRange,
                       float maxRange,
                       int nbsensors,
                       int type,
                       int flags)
Constructs a RangeSensorBelt. The sensor type can be either TYPE_BUMPER,TYPE_SONAR,TYPE_IR or TYPE_LASER. Ranges are measured from the belt perimeter (not from the belt center).

Parameters:
radius - - the radius of the belt.
minRange - - the minimal range of each sensor ray. Not used for TYPE_BUMPER.
maxRange - - the maximal range of each sensor ray. Not used for TYPE_BUMPER.
nbsensors - - the number of sensors in the belt (typically 4,6,12,24 or 36).
type - - to specify the sensor behavior

RangeSensorBelt

public RangeSensorBelt(javax.vecmath.Vector3d[] positions,
                       javax.vecmath.Vector3d[] directions,
                       int type,
                       int flags)
Constructs a RangeSensorBelt. The sensor type can be either TYPE_BUMPER,TYPE_SONAR,TYPE_IR or TYPE_LASER.

Parameters:
positions - : the position of each sensor relative to belt center.
directions - : the sensing ray direction of each sensor relative to sensor positions. the magnitude of the vector corresponds to the max range.
Method Detail

getMeasurement

public double getMeasurement(int sensorNum)
Returns the last measure collected for the individual sensor. Measurement is made from the circle perimeter.

Parameters:
sensorNum - num of the sensor.
Returns:
the range measurment.

getFrontQuadrantMeasurement

public double getFrontQuadrantMeasurement()
Returns the averaged measure of the sensors situated in the front quadrant: [-PI/4,PI/4].

Returns:
the averaged measurment.

getFrontLeftQuadrantMeasurement

public double getFrontLeftQuadrantMeasurement()
Returns the averaged measure of the sensors situated in the front left quadrant: [0,PI/4].

Returns:
the averaged measurment.

getFrontRightQuadrantMeasurement

public double getFrontRightQuadrantMeasurement()
Returns the averaged measure of the sensors situated in the front right quadrant: [3PI/2,2*PI].

Returns:
the averaged measurment.

getLeftQuadrantMeasurement

public double getLeftQuadrantMeasurement()
Returns the averaged measure of the sensors situated in the left quadrant: [PI/4,PI*3/4].

Returns:
the averaged measurment.

getBackLeftQuadrantMeasurement

public double getBackLeftQuadrantMeasurement()
Returns the averaged measure of the sensors situated in the bacck left quadrant: [PI/2,PI].

Returns:
the averaged measurment.

getBackQuadrantMeasurement

public double getBackQuadrantMeasurement()
Returns the averaged measure of the sensors situated in the back quadrant: [3PI/4,4*PI/4].

Returns:
the averaged measurment.

getBackRightQuadrantMeasurement

public double getBackRightQuadrantMeasurement()
Returns the averaged measure of the sensors situated in the back right quadrant: [PI,3*PI/2].

Returns:
the averaged measurment.

getRightQuadrantMeasurement

public double getRightQuadrantMeasurement()
Returns the averaged measure of the sensors situated in the right quadrant: [5*PI/4,7*PI/4].

Returns:
the averaged measurment.

getQuadrantMeasurement

public double getQuadrantMeasurement(double minAngle,
                                     double maxAngle)
Returns the averaged measure of the sensors situated in quadrant [minAngle,maxAngle].

Parameters:
minAngle - in radians the right limit of the quadrant.
maxAngle - in radians the left limit of the quadrant.
Returns:
the averaged measurment.

getFrontQuadrantHits

public int getFrontQuadrantHits()
Returns number of sensor hits in the front quadrant: [-PI/4,PI/4].

Returns:
the number of hits.

getFrontLeftQuadrantHits

public int getFrontLeftQuadrantHits()
Returns number of sensor hits in the front left quadrant: [0,PI/4].

Returns:
the number of hits.

getFrontRightQuadrantHits

public int getFrontRightQuadrantHits()
Returns number of sensor hits in the front right quadrant: [3PI/2,2*PI].

Returns:
the number of hits.

getLeftQuadrantHits

public int getLeftQuadrantHits()
Returns number of sensor hits in the left quadrant: [PI/4,PI*3/4].

Returns:
the number of hits.

getBackLeftQuadrantHits

public int getBackLeftQuadrantHits()
Returns number of sensor hits in the back left quadrant: [PI/2,PI].

Returns:
the number of hits.

getBackQuadrantHits

public int getBackQuadrantHits()
Returns number of sensor hits in the back quadrant: [3PI/4,5PI/4].

Returns:
the number of hits.

getBackRightQuadrantHits

public int getBackRightQuadrantHits()
Returns number of sensor hits in the back right quadrant: [PI,3PI/2].

Returns:
the number of hits.

getRightQuadrantHits

public int getRightQuadrantHits()
Returns number of sensor hits in the right quadrant: [5PI/4,7PI/4].

Returns:
the number of hits.

getQuadrantHits

public int getQuadrantHits(double minAngle,
                           double maxAngle)
Returns number of hits in quadrant [minAngle,maxAngle].

Parameters:
minAngle - in radians the right limit of the quadrant.
maxAngle - in radians the left limit of the quadrant.
Returns:
the number of hits.

hasHit

public boolean hasHit(int sensorNum)
Returns the hit state of the sensor.

Parameters:
sensorNum - num of the sensor.
Returns:
true if the sensor ray has hit an obstacle

oneHasHit

public boolean oneHasHit()
Returns true if one of the sensors has hit.

Returns:
true if one ray has hit an obstacle

getNumSensors

public int getNumSensors()
Return the number of individual sensor in the belt.

Returns:
the number of sensors.

getSensorAngle

public double getSensorAngle(int sensorNum)
Returns the angle of this sensor.

Parameters:
sensorNum - - num of the sensor.
Returns:
the angle in radians.

getMaxRange

public float getMaxRange()
Returns the maximum sensing range in meters.

Returns:
the maximum range.

createInspectorPanel

public javax.swing.JPanel createInspectorPanel()
Description copied from class: Device
Creates the panel associated to the device. This panel can be inserted in the inspector window for monitoring.

Overrides:
createInspectorPanel in class Device
Returns:
the JPanel. null if no panel can be associated