lejos.localization
Class TachoLocalizer

java.lang.Object
  extended by lejos.navigation.SimpleNavigator
      extended by lejos.localization.TachoLocalizer
All Implemented Interfaces:
Localizer, Navigator

public abstract class TachoLocalizer
extends SimpleNavigator
implements Localizer

An abstract extension to TachoNavigator that uses a map and a set of particles to implement the Monte Carlo Localization algorithm to estimate the pose of the robot as it moves about. Note that the navigator uses its own local coordinates relative to the robot's starting position, whereas the estimated pose is in global coordinates, as used by the map. This class must be extended and the takeReadings method implemented. Note that only travel and rotate methods update the particle set.

Author:
Lawrie Griffiths

Field Summary
protected  float angle
           
protected  float distance
           
protected  Map map
           
protected  Move mv
           
protected  int numParticles
           
protected  int numReadings
           
protected  ParticleSet particles
           
protected  float projection
           
protected  RangeReadings readings
           
 
Constructor Summary
TachoLocalizer(Map map, int numParticles, int numReadings, float wheelDiameter, float trackWidth, Motor leftMotor, Motor rightMotor, float projection, boolean reverse)
           
 
Method Summary
 Pose getEstimatedPose()
          Get the estimated position and angle of the robot.
 Map getMap()
          Get the map
 ParticleSet getParticles()
          Get the particle set
 float getProjection()
          Get the forward projection of the robot
 RangeReadings getReadings()
          Return readings
 int numParticles()
          Get the number of particles
 void rotate(float angle, boolean immediateReturn)
          Rotates the NXT robot a specific number of degrees in a direction (+ or -).
abstract  void takeReadings()
          Take a set of readings to the nearest map features
 void travel(float distance, boolean immediateReturn)
          Moves the NXT robot a specific distance.
 void updatePosition()
          Update the robot position and apply it to all the particles.
 
Methods inherited from class lejos.navigation.SimpleNavigator
angleTo, backward, distanceTo, forward, getAngle, getPilot, getX, getY, goTo, goTo, isMoving, rotate, rotateLeft, rotateRight, rotateTo, rotateTo, setMoveSpeed, setPosition, setSpeed, setTurnSpeed, stop, travel, turn, turn, turn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface lejos.navigation.Navigator
angleTo, backward, distanceTo, forward, getAngle, getX, getY, goTo, goTo, isMoving, rotate, rotateLeft, rotateRight, rotateTo, rotateTo, setMoveSpeed, setPosition, setTurnSpeed, stop, travel
 

Field Detail

readings

protected RangeReadings readings

projection

protected float projection

map

protected Map map

numParticles

protected int numParticles

particles

protected ParticleSet particles

angle

protected float angle

distance

protected float distance

mv

protected Move mv

numReadings

protected int numReadings
Constructor Detail

TachoLocalizer

public TachoLocalizer(Map map,
                      int numParticles,
                      int numReadings,
                      float wheelDiameter,
                      float trackWidth,
                      Motor leftMotor,
                      Motor rightMotor,
                      float projection,
                      boolean reverse)
Method Detail

takeReadings

public abstract void takeReadings()
Description copied from interface: Localizer
Take a set of readings to the nearest map features

Specified by:
takeReadings in interface Localizer

rotate

public void rotate(float angle,
                   boolean immediateReturn)
Description copied from class: SimpleNavigator
Rotates the NXT robot a specific number of degrees in a direction (+ or -). If immediateReturn is true, method returns immidiately and your code MUST call updatePostion() when the robot has stopped. Otherwise, the robot position is lost. If false, the robot position is updated automatically.

Specified by:
rotate in interface Navigator
Overrides:
rotate in class SimpleNavigator
Parameters:
angle - Angle to rotate in degrees. A positive value rotates left, a negative value right.
immediateReturn - iff true, the method returns immediately, in which case the programmer
is responsible for calling updatePosition() before the robot moves again.

travel

public void travel(float distance,
                   boolean immediateReturn)
Description copied from class: SimpleNavigator
Moves the NXT robot a specific distance. A positive value moves it forwards and a negative value moves it backwards. If immediateReturnis true, method returns immidiately and your code MUST call updatePostion() when the robot has stopped. Otherwise, the robot position is lost.

Specified by:
travel in interface Navigator
Overrides:
travel in class SimpleNavigator
Parameters:
distance - The positive or negative distance to move the robot, same units as _wheelDiameter
immediateReturn - iff true, the method returns immediately, in which case the programmer
is responsible for calling updatePosition() before the robot moves again.

updatePosition

public void updatePosition()
Update the robot position and apply it to all the particles. Note that only travel and rotate methods update the particle set.

Specified by:
updatePosition in interface Navigator
Overrides:
updatePosition in class SimpleNavigator

getProjection

public float getProjection()
Get the forward projection of the robot

Returns:
the distance from the range sensor to the front of the robot

numParticles

public int numParticles()
Get the number of particles

Returns:
the number of particles

getParticles

public ParticleSet getParticles()
Get the particle set

Returns:
the particle set

getMap

public Map getMap()
Get the map

Returns:
the map

getEstimatedPose

public Pose getEstimatedPose()
Get the estimated position and angle of the robot.

Specified by:
getEstimatedPose in interface Localizer
Returns:
the estimated pose

getReadings

public RangeReadings getReadings()
Return readings

Returns:
the range readings