public class MCLParticleSet
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
private int |
_iterations |
private float |
angleNoiseFactor |
private static float |
BIG_FLOAT |
private int |
border |
private Rectangle |
boundingRect |
private static boolean |
debug |
private float |
distanceNoiseFactor |
private RangeMap |
map |
static int |
maxIterations |
private float |
maxWeight |
private int |
numParticles |
private MCLParticle[] |
particles |
private java.util.Random |
random |
private float |
totalWeight |
private float |
twoSigmaSquared |
| Constructor and Description |
|---|
MCLParticleSet(RangeMap map,
int numParticles,
int border)
Create a set of particles randomly distributed within the given map.
|
MCLParticleSet(RangeMap map,
int numParticles,
int border,
RangeReadings readings,
float divisor,
float minWeight)
Generates a set of particles within the map that have a minimum weight as
as calculated from the particle pose, the range readings and the map.
|
MCLParticleSet(RangeMap map,
int numParticles,
Pose initialPose,
float radiusNoise,
float headingNoise)
Generates a circular cloud of particles centered on initialPose with random
normal radius and angle, and random normal heading.
|
| Modifier and Type | Method and Description |
|---|---|
void |
applyMove(Move move)
Apply a move to each particle
|
boolean |
calculateWeights(RangeReadings rr,
RangeMap map)
Calculate the weight for each particle
|
void |
dumpClosest(RangeReadings rr,
java.io.DataOutputStream dos,
float x,
float y)
Find the closest particle to specified coordinates and dump its
details to a data output stream.
|
void |
dumpObject(java.io.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.
|
private MCLParticle |
generateParticle()
Generate a random particle within the mapped area.
|
float |
getBorder()
Get the border where particles should not be generated
|
int |
getIterations() |
float |
getMaxWeight()
The highest weight of any particle
|
MCLParticle |
getParticle(int i)
Get a specific particle
|
void |
loadObject(java.io.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 |
setAngleNoiseFactor(float factor)
Set the distance angle factor
|
void |
setBorder(int border)
Set border where no particles should be generated
|
static void |
setDebug(boolean debug)
Set system out debugging on or off
|
void |
setDistanceNoiseFactor(float factor)
Set the distance noise factor
|
void |
setMaxIterations(int max)
Set the maximum iterations for the resample algorithm
|
void |
setSigma(float sigma)
Set the standard deviation for the sensor probability model
|
private static final float BIG_FLOAT
public static int maxIterations
private float twoSigmaSquared
private float distanceNoiseFactor
private float angleNoiseFactor
private int numParticles
private MCLParticle[] particles
private RangeMap map
private float maxWeight
private float totalWeight
private int border
private java.util.Random random
private Rectangle boundingRect
private static boolean debug
private int _iterations
public MCLParticleSet(RangeMap map, int numParticles, int border)
map - the map of the enclosed environmentpublic MCLParticleSet(RangeMap map, int numParticles, int border, RangeReadings readings, float divisor, float minWeight)
map - numParticles - - number of particlesborder - - within which no particles should be generatedreadings - - to use in calculating weightdivisor - minWeight - - the minimum wight of a particle in the mappublic MCLParticleSet(RangeMap map, int numParticles, Pose initialPose, float radiusNoise, float headingNoise)
map - the mapnumParticles - the number of particlesinitialPose - the center of the cloudradiusNoise - standard deviation of the normal of the distance from centerheadingNoise - standard deviation of headingprivate MCLParticle generateParticle()
public int numParticles()
public static void setDebug(boolean debug)
debug - true to set debug, false to set it offpublic MCLParticle getParticle(int i)
i - the index of the particlepublic boolean resample()
public boolean calculateWeights(RangeReadings rr,
RangeMap map)
rr - the robot range readingspublic void applyMove(Move move)
move - the move to applypublic float getMaxWeight()
public float getBorder()
public void setBorder(int border)
border - the borderpublic void setSigma(float sigma)
sigma - the standard deviationpublic void setDistanceNoiseFactor(float factor)
factor - the distance noise factorpublic void setAngleNoiseFactor(float factor)
factor - the distance angle factorpublic void setMaxIterations(int max)
max - the maximum iterationspublic int findClosest(float x,
float y)
x - the x-coordinatey - the y-coordinatepublic void dumpObject(java.io.DataOutputStream dos)
throws java.io.IOException
dos - the data output streamjava.io.IOExceptionpublic int getIterations()
public void loadObject(java.io.DataInputStream dis)
throws java.io.IOException
dis - the data input streamjava.io.IOExceptionpublic void dumpClosest(RangeReadings rr,
java.io.DataOutputStream dos,
float x,
float y)
throws java.io.IOException
rr - a dummy set of range readings used to determine the anglesdos - the data output streamx - the x-coordinatey - the y-coordinatejava.io.IOException