Class CPosePDFParticles

Inheritance Relationships

Base Types

  • public mrpt::poses::CPosePDF (Class CPosePDF)

  • public PFDataTPose2D

  • public mrpt::bayes::CParticleFilterDataImpl< CPosePDFParticles, PFDataTPose2D::CParticleList >

Class Documentation

class CPosePDFParticles : public mrpt::poses::CPosePDF, public PFDataTPose2D, public mrpt::bayes::CParticleFilterDataImpl<CPosePDFParticles, PFDataTPose2D::CParticleList>

Declares a class that represents a Probability Density Function (PDF) over a 2D pose (x,y,phi), using a set of weighted samples.

This class is also the base for the implementation of Monte-Carlo Localization (MCL), in mrpt::slam::CMonteCarloLocalization2D.

See the application “app/pf-localization” for an example of usage.

See also

CPose2D, CPosePDF, CPoseGaussianPDF, CParticleFilterCapable

Public Functions

void clear()

Free all the memory associated to m_particles, and set the number of parts = 0

CPosePDFParticles(size_t M = 1)

Constructor

Parameters:

M – The number of m_particles.

virtual void copyFrom(const CPosePDF &o) override

Copy operator, translating if necessary (for example, between m_particles and gaussian representations)

void resetDeterministic(const mrpt::math::TPose2D &location, size_t particlesCount = 0)

Reset the PDF to a single point: All m_particles will be set exactly to the supplied pose.

See also

resetUniform, CMonteCarloLocalization2D::resetUniformFreeSpace, resetAroundSetOfPoses

Parameters:
  • location – The location to set all the m_particles.

  • particlesCount – If this is set to 0 the number of m_particles remains unchanged.

void resetUniform(const double x_min, const double x_max, const double y_min, const double y_max, const double phi_min = -M_PI, const double phi_max = M_PI, const int particlesCount = -1)

Reset the PDF to an uniformly distributed one, inside of the defined 2D area [x_min,x_max]x[y_min,y_max] (in meters) and for orientations [phi_min, phi_max] (in radians).

See also

resetDeterministic, CMonteCarloLocalization2D::resetUniformFreeSpace, resetAroundSetOfPoses

Note

Orientations can be outside of the [-pi,pi] range if so desired, but it must hold phi_max>=phi_min.

Parameters:

particlesCount – New particle count, or leave count unchanged if set to -1 (default).

void resetAroundSetOfPoses(const std::vector<mrpt::math::TPose2D> &list_poses, size_t num_particles_per_pose, const double spread_x, const double spread_y, const double spread_phi_rad)

Reset the PDF to a multimodal distribution over a set of “spots” (x,y,phi) The total number of particles will be list_poses.size() * num_particles_per_pose

.

Particles will be spread uniformly in a box of width

spread_{x,y,phi_rad} in each of the three coordinates (meters, radians), so it can be understood as the “initial uncertainty”.

See also

resetDeterministic, CMonteCarloLocalization2D::resetUniformFreeSpace

Parameters:
  • list_poses[in] The poses (x,y,phi) around which particles will be spread. Must contains at least one pose.

  • num_particles_per_pose[in] Number of particles to be spread around each of the “spots” in list_poses. Must be >=1.

void getMean(CPose2D &mean_pose) const override
std::tuple<cov_mat_t, type_value> getCovarianceAndMean() const override
mrpt::math::TPose2D getParticlePose(size_t i) const

Returns the pose of the i’th particle.

bool saveToTextFile(const std::string &file) const override

Save PDF’s m_particles to a text file. In each line it will go: “x y phi

weight”

inline size_t size() const

Get the m_particles count (equivalent to “particlesCount”)

virtual void changeCoordinatesReference(const CPose3D &newReferenceBase) override

this = p (+) this. This can be used to convert a PDF from local coordinates to global, providing the point (newReferenceBase) from which “to project” the current pdf. Result PDF substituted the currently stored one in the object.

void drawSingleSample(CPose2D &outPart) const override

Draws a single sample from the distribution (WARNING: weights are assumed to be normalized!)

void operator+=(const mrpt::math::TPose2D &Ap)

Appends (pose-composition) a given pose “p” to each particle

void append(CPosePDFParticles &o)

Appends (add to the list) a set of m_particles to the existing ones, and then normalize weights.

virtual void inverse(CPosePDF &o) const override

Returns a new PDF such as: NEW_PDF = (0,0,0) - THIS_PDF

mrpt::math::TPose2D getMostLikelyParticle() const

Returns the particle with the highest weight.

virtual void bayesianFusion(const CPosePDF &p1, const CPosePDF &p2, const double minMahalanobisDistToDrop = 0) override

Bayesian fusion.

double evaluatePDF_parzen(const double x, const double y, const double phi, const double stdXY, const double stdPhi) const

Evaluates the PDF at a given arbitrary point as reconstructed by a Parzen window.

void saveParzenPDFToTextFile(const char *fileName, const double x_min, const double x_max, const double y_min, const double y_max, const double phi, const double stepSizeXY, const double stdXY, const double stdPhi) const

Save a text file (compatible with matlab) representing the 2D evaluation of the PDF as reconstructed by a Parzen window.

virtual void printTo(std::ostream &out) const override

Write a human-readable description of this PDF to the given stream. Derived classes must override this method.