simbad.sim
Class RangeSensorBelt

java.lang.Object
  extended by simbad.sim.BaseObject
      extended by simbad.sim.Device
          extended by simbad.sim.SensorDevice
              extended by simbad.sim.PickSensor
                  extended by simbad.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.


Nested Class Summary
private  class RangeSensorBelt.RangeSensorBeltJPanel
          A JPanel Inner class for displaying the sensor belt rays in 2d.
 
Field Summary
private  double[] angles
          angular position (deduced from positions infos)
private  javax.vecmath.Color3f color
           
private  javax.vecmath.Vector3d cylinderDirection
           
private  float cylinderRadius
           
private  javax.vecmath.Point3d cylinderStart
           
private  javax.vecmath.Vector3d[] directions
          direction vector of each sensor - relative to sensor position.
private  javax.vecmath.Point3d end
           
static int FLAG_SHOW_FULL_SENSOR_RAY
           
private  int flags
           
private  boolean[] hits
           
private  float maxRange
           
private  double[] measurements
          for storing results
private  int nbSensors
           
private  boolean oneHasHit
           
private  javax.media.j3d.PickCylinderRay pickCylinder
          for picking
private  javax.media.j3d.PickSegment pickSegment
           
private  javax.vecmath.Vector3d[] positions
          position of each sensor relative to center
private  float radius
           
private  javax.vecmath.Point3d start
           
private  javax.media.j3d.Transform3D t3d
           
private  javax.media.j3d.Transform3D t3d_2
           
private  int type
           
static int TYPE_BUMPER
           
static int TYPE_IR
           
static int TYPE_LASER
           
static int TYPE_SONAR
           
 
Fields inherited from class simbad.sim.PickSensor
pickableSceneBranch
 
Fields inherited from class simbad.sim.BaseObject
black, branchGroup, canBeTraversed, compilable, detachedFromSceneGraph, group, localBounds, material, rotation, rotationGroup, translation, translationGroup, white, world
 
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
private  void create3D()
           
 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.
private  void initialize(float radius, float maxRange, int nbsensors, int type, int flags)
           
 boolean oneHasHit()
          Returns true if one of the sensors has hit.
protected  void update()
          to be overriden
 
Methods inherited from class simbad.sim.PickSensor
setPickableSceneBranch
 
Methods inherited from class simbad.sim.Device
getName, getOwner, getUpdatePerSecond, reset, setName, setOwner, setUpdateOnEachFrame, setUpdatePerSecond, update
 
Methods inherited from class simbad.sim.BaseObject
addChild, addChild, attach, compile, create3D, detach, getBounds, getCanBeTraversed, getGroup, getNode, getRotationTransform, getRotationTransformGroup, getTranslation, getTranslationTransform, getTranslationTransform, resetTransforms, rotateY, setBounds, setCanBeTraversed, setColor, setWorld, translateTo
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

type

private int type

maxRange

private float maxRange

radius

private float radius

nbSensors

private int nbSensors

measurements

private double[] measurements
for storing results


hits

private boolean[] hits

oneHasHit

private boolean oneHasHit

angles

private double[] angles
angular position (deduced from positions infos)


positions

private javax.vecmath.Vector3d[] positions
position of each sensor relative to center


directions

private javax.vecmath.Vector3d[] directions
direction vector of each sensor - relative to sensor position.


t3d

private javax.media.j3d.Transform3D t3d

t3d_2

private javax.media.j3d.Transform3D t3d_2

start

private javax.vecmath.Point3d start

end

private javax.vecmath.Point3d end

color

private javax.vecmath.Color3f color

pickCylinder

private javax.media.j3d.PickCylinderRay pickCylinder
for picking


pickSegment

private javax.media.j3d.PickSegment pickSegment

cylinderStart

private javax.vecmath.Point3d cylinderStart

cylinderRadius

private float cylinderRadius

cylinderDirection

private javax.vecmath.Vector3d cylinderDirection

flags

private int flags

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

initialize

private void initialize(float radius,
                        float maxRange,
                        int nbsensors,
                        int type,
                        int flags)

create3D

private void create3D()

update

protected void update()
Description copied from class: Device
to be overriden

Overrides:
update in class Device

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