Class CPose3DPDFParticles

Inheritance Relationships

Base Types

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

  • public PFDataTPose3D

  • public mrpt::bayes::CParticleFilterDataImpl< CPose3DPDFParticles, PFDataTPose3D::CParticleList >

Class Documentation

class CPose3DPDFParticles : public mrpt::poses::CPose3DPDF, public PFDataTPose3D, public mrpt::bayes::CParticleFilterDataImpl<CPose3DPDFParticles, PFDataTPose3D::CParticleList>

Declares a class that represents a Probability Density function (PDF) of a 3D pose

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

CPose3D, CPose3DPDF, CPoseGaussianPDF

Public Functions

CPose3DPDFParticles(size_t M = 1)

Constructor

Parameters:

M – The number of m_particles.

virtual void copyFrom(const CPose3DPDF &o) override

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

void resetDeterministic(const mrpt::math::TPose3D &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

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 mrpt::math::TPose3D &corner_min, const mrpt::math::TPose3D &corner_max, const int particlesCount = -1)

Reset the PDF to an uniformly distributed one, inside of the defined “cube”.

See also

resetDeterministic 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 getMean(CPose3D &mean_pose) const override

Returns an estimate of the pose, (the mean, or mathematical expectation of the PDF), computed as a weighted average over all m_particles.

See also

getCovariance

std::tuple<cov_mat_t, type_value> getCovarianceAndMean() const override

Returns an estimate of the pose covariance matrix (6x6 cov matrix) and the mean, both at once.

See also

getMean

mrpt::math::TPose3D getParticlePose(int 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 z”

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(CPose3D &outPart) const override

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

void drawManySamples(size_t N, std::vector<mrpt::math::CVectorDouble> &outSamples) const override

Draws a number of samples from the distribution, and saves as a list of 1x6 vectors, where each row contains a (x,y,phi) datum.

void operator+=(const CPose3D &Ap)

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

void append(CPose3DPDFParticles &o)

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

virtual void inverse(CPose3DPDF &o) const override

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

mrpt::math::TPose3D getMostLikelyParticle() const

Returns the particle with the highest weight.

virtual void bayesianFusion(const CPose3DPDF &p1, const CPose3DPDF &p2) override

Bayesian fusion

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.