public class MCLPoseProvider extends java.lang.Object implements PoseProvider, MoveListener
MCLParticleSet
to represent the probability distribution of the
estimated pose.
It uses a MoveProvider
to supply odometry
data whenever a movement is completed,
from which the Pose
of each particle is updated.
It then uses a lejos.robotics.RangeScanner
to provide
lejos.robotics.RangeReadings
which are used, together with the
RangeMap
to calculate the
probability weight of each MCLParticle
.Modifier and Type | Class and Description |
---|---|
(package private) class |
MCLPoseProvider.Updater
Predicts particle pose from odometry data.
|
Modifier and Type | Field and Description |
---|---|
private float |
_heading |
private float |
_x |
private float |
_y |
private float |
BIG_FLOAT |
private int |
border |
private boolean |
busy |
private boolean |
debug |
private boolean |
incomplete |
private boolean |
lost |
private RangeMap |
map |
private float |
maxX |
private float |
maxY |
private float |
minX |
private float |
minY |
private int |
numParticles |
private MCLParticleSet |
particles |
private RangeReadings |
readings |
private RangeScanner |
scanner |
private boolean |
updated |
private MCLPoseProvider.Updater |
updater |
private double |
varH |
private double |
varX |
private double |
varY |
Constructor and Description |
---|
MCLPoseProvider(MoveProvider mp,
RangeScanner scanner,
RangeMap map,
int numParticles,
int border)
Allocates a new MCLPoseProvider.
|
MCLPoseProvider(RangeMap map,
int numParticles,
int border)
Constructor for use on PC
|
Modifier and Type | Method and Description |
---|---|
void |
dumpObject(java.io.DataOutputStream dos)
Dump the serialized estimate of pose to a data output stream
|
void |
estimatePose()
Estimate pose from weighted average of the particles
Calculate statistics
|
void |
generateParticles()
Generate a new particle set, uniformly distributed within the map, and
uniformly distributed heading.
|
Rectangle2D |
getErrorRect()
Returns the minimum rectangle enclosing all the particles
|
Pose |
getEstimatedPose() |
float |
getMaxX()
Returns the maximum value of X in the particle set
|
float |
getMaxY()
Returns the maximum value of Y in the particle set;
|
float |
getMinX()
Returns the minimum value of X in the particle set;
|
float |
getMinY()
Returns the minimum value of Y in the particle set;
|
MCLParticleSet |
getParticles()
Returns the particle set
|
Pose |
getPose()
Returns the best best estimate of the current pose;
|
RangeReadings |
getRangeReadings()
Returns most recent range readings
|
RangeReadings |
getReadings()
Get the current range readings
|
RangeScanner |
getScanner()
Returns the range scanner
|
float |
getSigmaHeading()
Returns the standard deviation of the heading values in the particle set;
|
float |
getSigmaX()
Returns the standard deviation of the X values in the particle set;
|
float |
getSigmaY()
Returns the standard deviation of the Y values in the particle set;
|
float |
getXRange()
Returns the difference between max X and min X
|
float |
getYRange()
Return difference between max Y and min Y
|
boolean |
incompleteRanges()
returns range scanner failure status
|
boolean |
isBusy()
returns true if particle weights are being updated.
|
boolean |
isLost()
returns lost status - all particles have very low probability weights
|
boolean |
isUpdated()
Returns update success flag
|
void |
loadObject(java.io.DataInputStream dis)
Load serialized estimated pose from a data input stream
|
void |
moveStarted(Move event,
MoveProvider mp)
Required by MoveListener interface; does nothing
|
void |
moveStopped(Move event,
MoveProvider mp)
Required by MoveListener interface.
|
void |
setDebug(boolean on)
Set debugging on or off
|
void |
setInitialPose(Pose aPose,
float radiusNoise,
float headingNoise)
Generates an initial particle set in a circular normal distribution, centered
on aPose.
|
void |
setInitialPose(RangeReadings readings,
float sigma)
Generates an initial particle set using the range readings.
|
void |
setMap(RangeMap map)
Associates a map with the MCLPoseProvider
(for example a map send from the PC).
|
void |
setParticles(MCLParticleSet particles)
Associate a particle set with the MCLPoseProvider
(e.g.
|
void |
setPose(Pose aPose)
set the initial pose cloud with radius noise 1 and heading noise 1
|
boolean |
update()
Calls range scanner to get range readings, calculates the probabilities
of each particle from the range readings and the map and calls resample(()
|
boolean |
update(RangeReadings readings)
Calculates particle weights from readings, then resamples the particle set;
|
private MCLParticleSet particles
private RangeScanner scanner
private RangeMap map
private int numParticles
private float _x
private float _y
private float _heading
private float minX
private float maxX
private float minY
private float maxY
private double varX
private double varY
private double varH
private boolean updated
private MCLPoseProvider.Updater updater
private int border
private boolean debug
private boolean busy
private float BIG_FLOAT
private RangeReadings readings
private boolean lost
private boolean incomplete
public MCLPoseProvider(MoveProvider mp, RangeScanner scanner, RangeMap map, int numParticles, int border)
mp
- - the MoveProivderscanner
- - the RangeScannermap
- - the RangeMapnumParticles
- number of particlesborder
- of the mappublic MCLPoseProvider(RangeMap map, int numParticles, int border)
map
- the RangeMapnumParticles
- the numbers of particlesborder
- of the mappublic void setMap(RangeMap map)
map
- the RangeMappublic void setInitialPose(Pose aPose, float radiusNoise, float headingNoise)
aPose
- - center of the cloudradiusNoise
- - standard deviation of the radius of the cloudheadingNoise
- - standard deviation of the heading;public void setInitialPose(RangeReadings readings, float sigma)
readings
- sigma
- range reading noise standard deviation.public void setDebug(boolean on)
on
- true = on, false = offpublic void setPose(Pose aPose)
setPose
in interface PoseProvider
public MCLParticleSet getParticles()
public RangeReadings getReadings()
public void setParticles(MCLParticleSet particles)
particles
- the particle setpublic void generateParticles()
public void moveStarted(Move event, MoveProvider mp)
moveStarted
in interface MoveListener
event
- the movementmp
- the movement providerpublic void moveStopped(Move event, MoveProvider mp)
moveStopped
in interface MoveListener
event
- the move just completedmp
- the MoveProviderpublic boolean update()
public boolean update(RangeReadings readings)
readings
- public boolean isUpdated()
public boolean isLost()
public boolean incompleteRanges()
public float getXRange()
public float getYRange()
public Pose getPose()
getPose
in interface PoseProvider
public Pose getEstimatedPose()
public void estimatePose()
public RangeReadings getRangeReadings()
public Rectangle2D getErrorRect()
public float getMaxX()
public float getMinX()
public float getMaxY()
public float getMinY()
public float getSigmaX()
public float getSigmaY()
public float getSigmaHeading()
public RangeScanner getScanner()
public void dumpObject(java.io.DataOutputStream dos) throws java.io.IOException
dos
- the data output streamjava.io.IOException
public void loadObject(java.io.DataInputStream dis) throws java.io.IOException
dis
- the data input streamjava.io.IOException
public boolean isBusy()