lejos.localization
Class ParticleSet

java.lang.Object
  extended by lejos.localization.ParticleSet

public class ParticleSet
extends Object

Represents a particle set for the particle filtering algorithm.

Author:
Lawrie Griffiths

WARNING: THIS CLASS IS SHARED BETWEEN THE classes AND pccomms PROJECTS. DO NOT EDIT THE VERSION IN pccomms AS IT WILL BE OVERWRITTEN WHEN THE PROJECT IS BUILT.

Field Summary
static float angleNoiseFactor
           
static int border
           
static float distanceNoiseFactor
           
static int forwardReading
           
static int maxIterations
           
static int numReadings
           
static int rangeReadingAngle
           
static float[] readings
           
static float twoSigmaSquared
           
 
Constructor Summary
ParticleSet(Map map, int numParticles)
          Create a set of particles randomly distributed with the given map.
 
Method Summary
 void applyMove(Move move)
          Apply a move to each particle
 void calculateWeights(RangeReadings rr, Map map)
          Calculate the weight for each particle
 void dumpClosest(DataOutputStream dos, float x, float y)
          Find the closest particle to specified coordinates and dump its details to a data output stream.
 void dumpEstimation(DataOutputStream dos)
          Dump the serialized estimate of pose to a data output stream
 void dumpParticles(DataOutputStream dos)
          Serialize the particle set to a data output stream
 int findClosest(float x, float y)
          Find the index of the particle closest to a given co-ordinates
 Pose getEstimatedPose()
          Get the estimated pose of the robot
 float getMaxWeight()
          The highest weight of any particle
 float getMaxX()
          Get the maximum X value of the estimated position
 float getMaxY()
          Get the maximum Y value of the estimated position
 float getMinX()
          Get the minimum X value of the estimated position
 float getMinY()
          Get the minimum Y value of the estimated position
 Particle getParticle(int i)
          Get a specific particle
 void loadEstimation(DataInputStream dis)
          Load serialized estimated pose from a data input stream
 void loadParticles(DataInputStream dis)
          Load serialized particles from a data input stream
 int numParticles()
          Return the number of particles in the set
 boolean resample()
          Resample the set picking those with higher weights.
 void resetEstimate()
          Reset the estimated position to unknown
static void setAngleNoiseFactor(float factor)
          Set the distance angle factor
static void setBorder(int border)
          Set border
static void setDistanceNoiseFactor(float factor)
          Set the distance noise factor
static void setForwardReading(int index)
          Set the index of the reading that is straight ahead
static void setMaxIterations(int max)
          Set the maximum iterations for the resample algorithm
static void setNumReadings(int num)
          Set the number of range readings
static void setRangeReadingAngle(int angle)
          Set the range reading angle
static void setSigma(float sigma)
          Set the standard deviation for the sensor probability model
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

maxIterations

public static int maxIterations

twoSigmaSquared

public static float twoSigmaSquared

distanceNoiseFactor

public static float distanceNoiseFactor

angleNoiseFactor

public static float angleNoiseFactor

numReadings

public static int numReadings

rangeReadingAngle

public static int rangeReadingAngle

forwardReading

public static int forwardReading

border

public static int border

readings

public static float[] readings
Constructor Detail

ParticleSet

public ParticleSet(Map map,
                   int numParticles)
Create a set of particles randomly distributed with the given map.

Parameters:
map - the map of the enclosed environment
Method Detail

numParticles

public int numParticles()
Return the number of particles in the set

Returns:
the number of particles

getParticle

public Particle getParticle(int i)
Get a specific particle

Parameters:
i - the index of the particle
Returns:
the particle

resample

public boolean resample()
Resample the set picking those with higher weights. Note that the new set has multiple instances of the particles with higher weights.

Returns:
true iff lost

calculateWeights

public void calculateWeights(RangeReadings rr,
                             Map map)
Calculate the weight for each particle

Parameters:
rr - the robot range readings

applyMove

public void applyMove(Move move)
Apply a move to each particle

Parameters:
move - the move to apply

getEstimatedPose

public Pose getEstimatedPose()
Get the estimated pose of the robot

Returns:
the estimated pose

getMinX

public float getMinX()
Get the minimum X value of the estimated position

Returns:
the minimum X value

getMaxX

public float getMaxX()
Get the maximum X value of the estimated position

Returns:
the maximum X value

getMinY

public float getMinY()
Get the minimum Y value of the estimated position

Returns:
the minimum Y value

getMaxY

public float getMaxY()
Get the maximum Y value of the estimated position

Returns:
the maximum Y value

resetEstimate

public void resetEstimate()
Reset the estimated position to unknown


getMaxWeight

public float getMaxWeight()
The highest weight of any particle

Returns:
the highest weight

setBorder

public static void setBorder(int border)
Set border

Parameters:
border - the border where no particles should be generated

setSigma

public static void setSigma(float sigma)
Set the standard deviation for the sensor probability model

Parameters:
sigma - the standard deviation

setDistanceNoiseFactor

public static void setDistanceNoiseFactor(float factor)
Set the distance noise factor

Parameters:
factor - the distance noise factor

setAngleNoiseFactor

public static void setAngleNoiseFactor(float factor)
Set the distance angle factor

Parameters:
factor - the distance angle factor

setRangeReadingAngle

public static void setRangeReadingAngle(int angle)
Set the range reading angle

Parameters:
angle - the angle between range readings

setForwardReading

public static void setForwardReading(int index)
Set the index of the reading that is straight ahead

Parameters:
index - the forward reading index

setNumReadings

public static void setNumReadings(int num)
Set the number of range readings

Parameters:
num - the number of range readings

setMaxIterations

public static void setMaxIterations(int max)
Set the maximum iterations for the resample algorithm

Parameters:
max - the maximum iterations

findClosest

public int findClosest(float x,
                       float y)
Find the index of the particle closest to a given co-ordinates

Parameters:
x - the x-coordinate
y - the y-coordinate
Returns:
the index

dumpParticles

public void dumpParticles(DataOutputStream dos)
                   throws IOException
Serialize the particle set to a data output stream

Parameters:
dos - the data output stream
Throws:
IOException

loadParticles

public void loadParticles(DataInputStream dis)
                   throws IOException
Load serialized particles from a data input stream

Parameters:
dis - the data input stream
Throws:
IOException

dumpEstimation

public void dumpEstimation(DataOutputStream dos)
                    throws IOException
Dump the serialized estimate of pose to a data output stream

Parameters:
dos - the data output stream
Throws:
IOException

loadEstimation

public void loadEstimation(DataInputStream dis)
                    throws IOException
Load serialized estimated pose from a data input stream

Parameters:
dis - the data imput stream
Throws:
IOException

dumpClosest

public void dumpClosest(DataOutputStream dos,
                        float x,
                        float y)
                 throws IOException
Find the closest particle to specified coordinates and dump its details to a data output stream.

Parameters:
dos - the data output stream
x - the x-coordinate
y - the y-coordinate
Throws:
IOException