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.
Definition at line 31 of file CPosePDFParticles.h.
#include <mrpt/poses/CPosePDFParticles.h>
Public Types | |
enum | { is_3D_val = 0 } |
enum | { is_PDF_val = 1 } |
typedef CPose2D | type_value |
The type of the state the PDF represents. More... | |
typedef CProbabilityDensityFunction< CPose2D, STATE_LEN > | self_t |
typedef CPose2D | CParticleDataContent |
This is the type inside the corresponding CParticleData class. More... | |
typedef CProbabilityParticle< CPose2D > | CParticleData |
Use this to refer to each element in the m_particles array. More... | |
typedef std::deque< CParticleData > | CParticleList |
Use this type to refer to the list of particles m_particles. More... | |
using | TParticleProbabilityEvaluator = std::function< double(size_t index)> |
A callback function type for evaluating the probability of m_particles of being selected, used in "fastDrawSample". More... | |
Public Member Functions | |
void * | operator new (size_t size) |
void * | operator new[] (size_t size) |
void | operator delete (void *ptr) noexcept |
void | operator delete[] (void *ptr) noexcept |
void | operator delete (void *memory, void *ptr) noexcept |
void * | operator new (size_t size, const std::nothrow_t &) noexcept |
void | operator delete (void *ptr, const std::nothrow_t &) noexcept |
void | clear () |
Free all the memory associated to m_particles, and set the number of parts = 0. More... | |
CPosePDFParticles (size_t M=1) | |
Constructor. More... | |
void | copyFrom (const CPosePDF &o) override |
Copy operator, translating if necesary (for example, between m_particles and gaussian representations) More... | |
void | resetDeterministic (const CPose2D &location, size_t particlesCount=0) |
Reset the PDF to a single point: All m_particles will be set exactly to the supplied pose. More... | |
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 cube. More... | |
void | resetAroundSetOfPoses (const std::vector< mrpt::math::TPose2D > &list_poses, const 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 . More... | |
void | getMean (CPose2D &mean_pose) const override |
Returns an estimate of the pose, (the mean, or mathematical expectation of the PDF). More... | |
void | getCovarianceAndMean (mrpt::math::CMatrixDouble33 &cov, CPose2D &mean_point) const override |
Returns an estimate of the pose covariance matrix (3x3 cov matrix) and the mean, both at once. More... | |
CPose2D | getParticlePose (size_t i) const |
Returns the pose of the i'th particle. More... | |
void | saveToTextFile (const std::string &file) const override |
Save PDF's m_particles to a text file. More... | |
size_t | size () const |
Get the m_particles count (equivalent to "particlesCount") More... | |
void | changeCoordinatesReference (const CPose3D &newReferenceBase) override |
this = p (+) this. More... | |
void | drawSingleSample (CPose2D &outPart) const override |
Draws a single sample from the distribution (WARNING: weights are assumed to be normalized!) More... | |
void | operator+= (const CPose2D &Ap) |
Appends (pose-composition) a given pose "p" to each particle. More... | |
void | append (CPosePDFParticles &o) |
Appends (add to the list) a set of m_particles to the existing ones, and then normalize weights. More... | |
void | inverse (CPosePDF &o) const override |
Returns a new PDF such as: NEW_PDF = (0,0,0) - THIS_PDF. More... | |
CPose2D | getMostLikelyParticle () const |
Returns the particle with the highest weight. More... | |
void | bayesianFusion (const CPosePDF &p1, const CPosePDF &p2, const double &minMahalanobisDistToDrop=0) override |
Bayesian fusion. More... | |
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. More... | |
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. More... | |
template<class OPENGL_SETOFOBJECTSPTR > | |
void | getAs3DObject (OPENGL_SETOFOBJECTSPTR &out_obj) const |
Returns a 3D representation of this PDF (it doesn't clear the current contents of out_obj, but append new OpenGL objects to that list) More... | |
template<class OPENGL_SETOFOBJECTSPTR > | |
OPENGL_SETOFOBJECTSPTR | getAs3DObject () const |
Returns a 3D representation of this PDF. More... | |
virtual mxArray * | writeToMatlab () const |
Introduces a pure virtual method responsible for writing to a mxArray Matlab object, typically a MATLAB struct whose contents are documented in each derived class. More... | |
virtual void | getMean (CPose2D &mean_point) const=0 |
Returns the mean, or mathematical expectation of the probability density distribution (PDF). More... | |
virtual void | getCovarianceAndMean (mrpt::math::CMatrixFixedNumeric< double, STATE_LEN, STATE_LEN > &cov, CPose2D &mean_point) const=0 |
Returns an estimate of the pose covariance matrix (STATE_LENxSTATE_LEN cov matrix) and the mean, both at once. More... | |
void | getCovarianceDynAndMean (mrpt::math::CMatrixDouble &cov, CPose2D &mean_point) const |
Returns an estimate of the pose covariance matrix (STATE_LENxSTATE_LEN cov matrix) and the mean, both at once. More... | |
CPose2D | getMeanVal () const |
Returns the mean, or mathematical expectation of the probability density distribution (PDF). More... | |
void | getCovariance (mrpt::math::CMatrixDouble &cov) const |
Returns the estimate of the covariance matrix (STATE_LEN x STATE_LEN covariance matrix) More... | |
void | getCovariance (mrpt::math::CMatrixFixedNumeric< double, STATE_LEN, STATE_LEN > &cov) const |
Returns the estimate of the covariance matrix (STATE_LEN x STATE_LEN covariance matrix) More... | |
mrpt::math::CMatrixFixedNumeric< double, STATE_LEN, STATE_LEN > | getCovariance () const |
Returns the estimate of the covariance matrix (STATE_LEN x STATE_LEN covariance matrix) More... | |
virtual bool | isInfType () const |
Returns whether the class instance holds the uncertainty in covariance or information form. More... | |
virtual void | getInformationMatrix (mrpt::math::CMatrixFixedNumeric< double, STATE_LEN, STATE_LEN > &inf) const |
Returns the information (inverse covariance) matrix (a STATE_LEN x STATE_LEN matrix) Unless reimplemented in derived classes, this method first reads the covariance, then invert it. More... | |
virtual void | drawSingleSample (CPose2D &outPart) const=0 |
Draws a single sample from the distribution. More... | |
virtual void | drawManySamples (size_t N, std::vector< mrpt::math::CVectorDouble > &outSamples) const |
Draws a number of samples from the distribution, and saves as a list of 1xSTATE_LEN vectors, where each row contains a (x,y,z,yaw,pitch,roll) datum. More... | |
double | getCovarianceEntropy () const |
Compute the entropy of the estimated covariance matrix. More... | |
void | clearParticles () |
Free the memory of all the particles and reset the array "m_particles" to length zero. More... | |
void | writeParticlesToStream (STREAM &out) const |
Dumps the sequence of particles and their weights to a stream (requires T implementing CSerializable). More... | |
void | readParticlesFromStream (STREAM &in) |
Reads the sequence of particles and their weights from a stream (requires T implementing CSerializable). More... | |
void | getWeights (std::vector< double > &out_logWeights) const |
Returns a vector with the sequence of the logaritmic weights of all the samples. More... | |
const CPosePDFParticles & | derived () const |
CRTP helper method. More... | |
CPosePDFParticles & | derived () |
CRTP helper method. More... | |
double | getW (size_t i) const override |
Access to i'th particle (logarithm) weight, where first one is index 0. More... | |
void | setW (size_t i, double w) override |
Modifies i'th particle (logarithm) weight, where first one is index 0. More... | |
size_t | particlesCount () const override |
Get the m_particles count. More... | |
double | normalizeWeights (double *out_max_log_w=nullptr) override |
Normalize the (logarithmic) weights, such as the maximum weight is zero. More... | |
double | ESS () const override |
Returns the normalized ESS (Estimated Sample Size), in the range [0,1]. More... | |
void | performSubstitution (const std::vector< size_t > &indx) override |
Replaces the old particles by copies determined by the indexes in "indx", performing an efficient copy of the necesary particles only and allowing the number of particles to change. More... | |
void | prepareFastDrawSample (const bayes::CParticleFilter::TParticleFilterOptions &PF_options) const |
The default evaluator function, which simply returns the particle weight. More... | |
void | prepareFastDrawSample (const bayes::CParticleFilter::TParticleFilterOptions &PF_options, TParticleProbabilityEvaluator partEvaluator) const |
Prepares data structures for calling fastDrawSample method next. More... | |
size_t | fastDrawSample (const bayes::CParticleFilter::TParticleFilterOptions &PF_options) const |
Draws a random sample from the particle filter, in such a way that each particle has a probability proportional to its weight (in the standard PF algorithm). More... | |
void | performResampling (const bayes::CParticleFilter::TParticleFilterOptions &PF_options, size_t out_particle_count=0) |
Performs a resample of the m_particles, using the method selected in the constructor. More... | |
RTTI classes and functions | |
mrpt::utils::CObject::Ptr | duplicateGetSmartPtr () const |
Returns a copy of the object, indepently of its class, as a smart pointer (the newly created object will exist as long as any copy of this smart pointer). More... | |
Static Public Member Functions | |
static void * | operator new (size_t size, void *ptr) |
static void | jacobiansPoseComposition (const CPose2D &x, const CPose2D &u, mrpt::math::CMatrixDouble33 &df_dx, mrpt::math::CMatrixDouble33 &df_du, const bool compute_df_dx=true, const bool compute_df_du=true) |
This static method computes the pose composition Jacobians, with these formulas: More... | |
static void | jacobiansPoseComposition (const CPosePDFGaussian &x, const CPosePDFGaussian &u, mrpt::math::CMatrixDouble33 &df_dx, mrpt::math::CMatrixDouble33 &df_du) |
static bool | is_3D () |
static bool | is_PDF () |
static void | computeResampling (CParticleFilter::TParticleResamplingAlgorithm method, const std::vector< double > &in_logWeights, std::vector< size_t > &out_indexes, size_t out_particle_count=0) |
A static method to perform the computation of the samples resulting from resampling a given set of particles, given their logarithmic weights, and a resampling method. More... | |
static void | log2linearWeights (const std::vector< double > &in_logWeights, std::vector< double > &out_linWeights) |
A static method to compute the linear, normalized (the sum the unity) weights from log-weights. More... | |
Public Attributes | |
CParticleList | m_particles |
The array of particles. More... | |
Static Public Attributes | |
static const size_t | state_length |
The length of the variable, for example, 3 for a 3D point, 6 for a 3D pose (x y z yaw pitch roll). More... | |
Protected Member Functions | |
CSerializable virtual methods | |
void | writeToStream (mrpt::utils::CStream &out, int *getVersion) const override |
Introduces a pure virtual method responsible for writing to a CStream. More... | |
void | readFromStream (mrpt::utils::CStream &in, int version) override |
Introduces a pure virtual method responsible for loading from a CStream This can not be used directly be users, instead use "stream >> object;" for reading it from a stream or "stream >> object_ptr;" if the class is unknown apriori. More... | |
Protected Attributes | |
TFastDrawAuxVars | m_fastDrawAuxiliary |
Auxiliary vectors, see CParticleFilterCapable::prepareFastDrawSample for more information. More... | |
RTTI stuff | |
using | Ptr = std::shared_ptr< CPosePDFParticles > |
using | ConstPtr = std::shared_ptr< const CPosePDFParticles > |
static mrpt::utils::CLASSINIT | _init_CPosePDFParticles |
static const mrpt::utils::TRuntimeClassId | runtimeClassId |
static constexpr const char * | className = "CPosePDFParticles" |
static const mrpt::utils::TRuntimeClassId * | _GetBaseClass () |
static const mrpt::utils::TRuntimeClassId & | GetRuntimeClassIdStatic () |
static mrpt::utils::CObject * | CreateObject () |
template<typename... Args> | |
static Ptr | Create (Args &&... args) |
virtual const mrpt::utils::TRuntimeClassId * | GetRuntimeClass () const override |
Returns information about the class of an object in runtime. More... | |
virtual mrpt::utils::CObject * | clone () const override |
Returns a deep copy (clone) of the object, indepently of its class. More... | |
using mrpt::poses::CPosePDFParticles::ConstPtr = std::shared_ptr<const CPosePDFParticles > |
Definition at line 38 of file CPosePDFParticles.h.
|
inherited |
Use this to refer to each element in the m_particles array.
Definition at line 203 of file CParticleFilterData.h.
|
inherited |
This is the type inside the corresponding CParticleData class.
Definition at line 201 of file CParticleFilterData.h.
|
inherited |
Use this type to refer to the list of particles m_particles.
Definition at line 205 of file CParticleFilterData.h.
using mrpt::poses::CPosePDFParticles::Ptr = std::shared_ptr< CPosePDFParticles > |
A typedef for the associated smart pointer
Definition at line 38 of file CPosePDFParticles.h.
|
inherited |
Definition at line 37 of file CProbabilityDensityFunction.h.
|
inherited |
A callback function type for evaluating the probability of m_particles of being selected, used in "fastDrawSample".
The default evaluator function "defaultEvaluator" simply returns the particle weight.
index | This is the index of the particle its probability is being computed. |
action | The value of this is the parameter passed to "prepareFastDrawSample" |
observation | The value of this is the parameter passed to "prepareFastDrawSample" The action and the observation are declared as "void*" for a greater flexibility. |
Definition at line 60 of file CParticleFilterCapable.h.
|
inherited |
The type of the state the PDF represents.
Definition at line 36 of file CProbabilityDensityFunction.h.
|
inherited |
Enumerator | |
---|---|
is_3D_val |
Definition at line 94 of file CPosePDF.h.
|
inherited |
Enumerator | |
---|---|
is_PDF_val |
Definition at line 99 of file CPosePDF.h.
CPosePDFParticles::CPosePDFParticles | ( | size_t | M = 1 | ) |
Constructor.
M | The number of m_particles. |
Definition at line 35 of file CPosePDFParticles.cpp.
|
staticprotected |
void CPosePDFParticles::append | ( | CPosePDFParticles & | o | ) |
Appends (add to the list) a set of m_particles to the existing ones, and then normalize weights.
Definition at line 375 of file CPosePDFParticles.cpp.
References mrpt::bayes::CProbabilityParticle< T >::d, mrpt::bayes::CProbabilityParticle< T >::log_w, and mrpt::bayes::CParticleFilterData< T >::m_particles.
|
overridevirtual |
Bayesian fusion.
Implements mrpt::poses::CPosePDF.
Definition at line 429 of file CPosePDFParticles.cpp.
References MRPT_UNUSED_PARAM, and THROW_EXCEPTION.
|
overridevirtual |
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.
Implements mrpt::utils::CProbabilityDensityFunction< CPose2D, 3 >.
Definition at line 329 of file CPosePDFParticles.cpp.
void CPosePDFParticles::clear | ( | ) |
Free all the memory associated to m_particles, and set the number of parts = 0.
Definition at line 95 of file CPosePDFParticles.cpp.
Referenced by mrpt::slam::CMonteCarloLocalization2D::resetUniformFreeSpace().
|
inlineinherited |
Free the memory of all the particles and reset the array "m_particles" to length zero.
Definition at line 214 of file CParticleFilterData.h.
|
overridevirtual |
Returns a deep copy (clone) of the object, indepently of its class.
Implements mrpt::utils::CObject.
|
staticinherited |
A static method to perform the computation of the samples resulting from resampling a given set of particles, given their logarithmic weights, and a resampling method.
It returns the sequence of indexes from the resampling. The number of output samples is the same than the input population. This generic method just computes these indexes, to actually perform a resampling in a particle filter object, call performResampling
[in] | out_particle_count | The desired number of output particles after resampling; 0 means don't modify the current number. |
Definition at line 61 of file CParticleFilterCapable.cpp.
References ASSERT_, mrpt::random::CRandomGenerator::drawUniform(), mrpt::random::CRandomGenerator::drawUniformVector(), mrpt::format(), mrpt::random::getRandomGenerator(), mrpt::math::maximum(), MRPT_END, MRPT_START, R, and THROW_EXCEPTION.
Copy operator, translating if necesary (for example, between m_particles and gaussian representations)
Implements mrpt::poses::CPosePDF.
Definition at line 49 of file CPosePDFParticles.cpp.
References ASSERT_, CLASS_ID, mrpt::poses::CPosePDFGaussian::cov, mrpt::random::CRandomGenerator::drawGaussianMultivariateMany(), mrpt::random::getRandomGenerator(), mrpt::poses::CPosePDF::GetRuntimeClass(), mrpt::bayes::CParticleFilterData< T >::m_particles, mrpt::poses::CPosePDFGaussian::mean, MRPT_END, MRPT_START, mrpt::poses::CPose2D::phi(), mrpt::poses::CPoseOrPoint< DERIVEDCLASS >::x(), and mrpt::poses::CPoseOrPoint< DERIVEDCLASS >::y().
Referenced by inverse().
|
inlinestatic |
Definition at line 38 of file CPosePDFParticles.h.
|
static |
|
inlineinherited |
CRTP helper method.
Definition at line 35 of file CParticleFilterData.h.
|
inlineinherited |
CRTP helper method.
Definition at line 40 of file CParticleFilterData.h.
|
inlinevirtualinherited |
Draws a number of samples from the distribution, and saves as a list of 1xSTATE_LEN vectors, where each row contains a (x,y,z,yaw,pitch,roll) datum.
This base method just call N times to drawSingleSample, but derived classes should implemented optimized method for each particular PDF.
Reimplemented in mrpt::poses::CPosePDFSOG, mrpt::poses::CPosePDFGaussianInf, mrpt::poses::CPosePDFGaussian, and mrpt::poses::CPosePDFGrid.
Definition at line 154 of file CProbabilityDensityFunction.h.
References mrpt::utils::CProbabilityDensityFunction< TDATA, STATE_LEN >::drawSingleSample().
Draws a single sample from the distribution (WARNING: weights are assumed to be normalized!)
Definition at line 342 of file CPosePDFParticles.cpp.
References mrpt::random::CRandomGenerator::drawUniform(), and mrpt::random::getRandomGenerator().
Referenced by mrpt::poses::CPoseRandomSampler::do_sample_2D().
|
pure virtualinherited |
Draws a single sample from the distribution.
|
inlineoverridevirtualinherited |
Returns the normalized ESS (Estimated Sample Size), in the range [0,1].
Note that you do NOT need to normalize the weights before calling this.
Implements mrpt::bayes::CParticleFilterCapable.
Definition at line 87 of file CParticleFilterData.h.
double CPosePDFParticles::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.
Definition at line 443 of file CPosePDFParticles.cpp.
References mrpt::math::normalPDF(), and mrpt::math::wrapToPi().
|
inherited |
Draws a random sample from the particle filter, in such a way that each particle has a probability proportional to its weight (in the standard PF algorithm).
This method can be used to generate a variable number of m_particles when resampling: to vary the number of m_particles in the filter. See prepareFastDrawSample for more information, or the Particle Filter tutorial.
NOTES:
Definition at line 389 of file CParticleFilterCapable.cpp.
References mrpt::bayes::CParticleFilter::TParticleFilterOptions::adaptiveSampleSize, mrpt::random::CRandomGenerator::drawUniform(), mrpt::random::getRandomGenerator(), MRPT_END, MRPT_END_WITH_CLEAN_UP, MRPT_START, mrpt::bayes::CParticleFilter::TParticleFilterOptions::resamplingMethod, and THROW_EXCEPTION.
|
inlineinherited |
Returns a 3D representation of this PDF (it doesn't clear the current contents of out_obj, but append new OpenGL objects to that list)
Definition at line 113 of file CPosePDF.h.
References mrpt::opengl::posePDF2opengl().
|
inlineinherited |
Returns a 3D representation of this PDF.
Definition at line 124 of file CPosePDF.h.
References mrpt::opengl::posePDF2opengl().
|
inlineinherited |
Returns the estimate of the covariance matrix (STATE_LEN x STATE_LEN covariance matrix)
Definition at line 81 of file CProbabilityDensityFunction.h.
References mrpt::utils::CProbabilityDensityFunction< TDATA, STATE_LEN >::getCovarianceDynAndMean().
|
inlineinherited |
Returns the estimate of the covariance matrix (STATE_LEN x STATE_LEN covariance matrix)
Definition at line 91 of file CProbabilityDensityFunction.h.
References mrpt::utils::CProbabilityDensityFunction< TDATA, STATE_LEN >::getCovarianceAndMean().
|
inlineinherited |
Returns the estimate of the covariance matrix (STATE_LEN x STATE_LEN covariance matrix)
Definition at line 104 of file CProbabilityDensityFunction.h.
References mrpt::math::cov(), mrpt::utils::CProbabilityDensityFunction< TDATA, STATE_LEN >::getCovarianceAndMean(), and mrpt::math::UNINITIALIZED_MATRIX.
|
pure virtualinherited |
Returns an estimate of the pose covariance matrix (STATE_LENxSTATE_LEN cov matrix) and the mean, both at once.
|
override |
Returns an estimate of the pose covariance matrix (3x3 cov matrix) and the mean, both at once.
Definition at line 126 of file CPosePDFParticles.cpp.
References mrpt::math::cov(), M_2PI, mean(), mrpt::math::square(), and mrpt::math::wrapToPi().
Referenced by mrpt::poses::CPosePDFGrid::getCovarianceAndMean(), and run_test_pf_localization().
|
inlineinherited |
Returns an estimate of the pose covariance matrix (STATE_LENxSTATE_LEN cov matrix) and the mean, both at once.
Definition at line 57 of file CProbabilityDensityFunction.h.
References mrpt::math::cov(), mrpt::utils::CProbabilityDensityFunction< TDATA, STATE_LEN >::getCovarianceAndMean(), and mrpt::math::UNINITIALIZED_MATRIX.
|
inlineinherited |
Compute the entropy of the estimated covariance matrix.
Definition at line 178 of file CProbabilityDensityFunction.h.
References det(), and mrpt::utils::CProbabilityDensityFunction< TDATA, STATE_LEN >::getCovariance().
|
inlinevirtualinherited |
Returns the information (inverse covariance) matrix (a STATE_LEN x STATE_LEN matrix) Unless reimplemented in derived classes, this method first reads the covariance, then invert it.
Definition at line 127 of file CProbabilityDensityFunction.h.
References mrpt::math::cov(), mrpt::utils::CProbabilityDensityFunction< TDATA, STATE_LEN >::getCovarianceAndMean(), and mrpt::math::UNINITIALIZED_MATRIX.
|
pure virtualinherited |
Returns the mean, or mathematical expectation of the probability density distribution (PDF).
Returns an estimate of the pose, (the mean, or mathematical expectation of the PDF).
Definition at line 102 of file CPosePDFParticles.cpp.
References mrpt::poses::SE_average< 2 >::append(), and mrpt::poses::SE_average< 2 >::get_average().
|
inlineinherited |
Returns the mean, or mathematical expectation of the probability density distribution (PDF).
Definition at line 70 of file CProbabilityDensityFunction.h.
References mrpt::utils::CProbabilityDensityFunction< TDATA, STATE_LEN >::getMean().
CPose2D CPosePDFParticles::getMostLikelyParticle | ( | ) | const |
Returns the particle with the highest weight.
Definition at line 409 of file CPosePDFParticles.cpp.
CPose2D CPosePDFParticles::getParticlePose | ( | size_t | i | ) | const |
Returns the pose of the i'th particle.
Definition at line 321 of file CPosePDFParticles.cpp.
|
overridevirtual |
Returns information about the class of an object in runtime.
Reimplemented from mrpt::poses::CPosePDF.
|
static |
|
inlineoverridevirtualinherited |
Access to i'th particle (logarithm) weight, where first one is index 0.
Implements mrpt::bayes::CParticleFilterCapable.
Definition at line 41 of file CParticleFilterData.h.
|
inlineinherited |
Returns a vector with the sequence of the logaritmic weights of all the samples.
Definition at line 256 of file CParticleFilterData.h.
Returns a new PDF such as: NEW_PDF = (0,0,0) - THIS_PDF.
Implements mrpt::poses::CPosePDF.
Definition at line 391 of file CPosePDFParticles.cpp.
References ASSERT_, CLASS_ID, copyFrom(), mrpt::poses::CPosePDF::GetRuntimeClass(), MRPT_END, and MRPT_START.
|
inlinestaticinherited |
Definition at line 98 of file CPosePDF.h.
References mrpt::poses::CPosePDF::is_3D_val.
|
inlinestaticinherited |
Definition at line 103 of file CPosePDF.h.
References mrpt::poses::CPosePDF::is_PDF_val.
|
inlinevirtualinherited |
Returns whether the class instance holds the uncertainty in covariance or information form.
Reimplemented in mrpt::poses::CPosePDFGaussianInf.
Definition at line 120 of file CProbabilityDensityFunction.h.
|
staticinherited |
This static method computes the pose composition Jacobians, with these formulas:
Definition at line 32 of file CPosePDF.cpp.
References mrpt::poses::CPoseOrPoint< DERIVEDCLASS >::x(), and mrpt::poses::CPoseOrPoint< DERIVEDCLASS >::y().
Referenced by mrpt::poses::CPosePDFGaussian::composePoint(), mrpt::poses::CPosePDF::jacobiansPoseComposition(), mrpt::math::jacobians::jacobs_2D_pose_comp(), mrpt::poses::CPosePDFGaussian::operator+=(), and mrpt::poses::CPosePDFGaussianInf::operator+=().
|
staticinherited |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 22 of file CPosePDF.cpp.
References mrpt::poses::CPosePDF::jacobiansPoseComposition().
|
staticinherited |
A static method to compute the linear, normalized (the sum the unity) weights from log-weights.
Definition at line 455 of file CParticleFilterCapable.cpp.
References ASSERT_, MRPT_END, and MRPT_START.
|
inlineoverridevirtualinherited |
Normalize the (logarithmic) weights, such as the maximum weight is zero.
out_max_log_w | If provided, will return with the maximum log_w before normalizing, such as new_weights = old_weights - max_log_w. |
Implements mrpt::bayes::CParticleFilterCapable.
Definition at line 60 of file CParticleFilterData.h.
Definition at line 38 of file CPosePDFParticles.h.
Definition at line 38 of file CPosePDFParticles.h.
|
inlinenoexcept |
Definition at line 38 of file CPosePDFParticles.h.
Definition at line 38 of file CPosePDFParticles.h.
|
inline |
Definition at line 38 of file CPosePDFParticles.h.
Definition at line 38 of file CPosePDFParticles.h.
|
inlinenoexcept |
Definition at line 38 of file CPosePDFParticles.h.
|
inline |
Definition at line 38 of file CPosePDFParticles.h.
Appends (pose-composition) a given pose "p" to each particle.
Definition at line 365 of file CPosePDFParticles.cpp.
|
inlineoverridevirtualinherited |
Get the m_particles count.
Implements mrpt::bayes::CParticleFilterCapable.
Definition at line 55 of file CParticleFilterData.h.
|
inherited |
Performs a resample of the m_particles, using the method selected in the constructor.
After computing the surviving samples, this method internally calls "performSubstitution" to actually perform the particle replacement. This method is called automatically by CParticleFilter::execute, andshould not be invoked manually normally. To just obtaining the sequence of resampled indexes from a sequence of weights, use "resample"
[in] | out_particle_count | The desired number of output particles after resampling; 0 means don't modify the current number. |
Definition at line 29 of file CParticleFilterCapable.cpp.
References ASSERT_, MRPT_END, MRPT_START, and mrpt::bayes::CParticleFilter::TParticleFilterOptions::resamplingMethod.
|
inlineoverridevirtualinherited |
Replaces the old particles by copies determined by the indexes in "indx", performing an efficient copy of the necesary particles only and allowing the number of particles to change.
Implements mrpt::bayes::CParticleFilterCapable.
Definition at line 114 of file CParticleFilterData.h.
|
inlineinherited |
The default evaluator function, which simply returns the particle weight.
The action and the observation are declared as "void*" for a greater flexibility.
Definition at line 68 of file CParticleFilterCapable.h.
References mrpt::bayes::CParticleFilterCapable::getW().
|
inherited |
Prepares data structures for calling fastDrawSample method next.
This method must be called once before using "fastDrawSample" (calling this more than once has no effect, but it takes time for nothing!) The behavior depends on the configuration of the PF (see CParticleFilter::TParticleFilterOptions):
The function pointed by "partEvaluator" should take into account the particle filter algorithm selected in "m_PFAlgorithm". If called without arguments (defaultEvaluator), the default behavior is to draw samples with a probability proportional to their current weights. The action and the observation are declared as "void*" for a greater flexibility. For a more detailed information see the Particle Filter tutorial. Custom supplied "partEvaluator" functions must take into account the previous particle weight, i.e. multiplying the current observation likelihood by the weights.
Definition at line 276 of file CParticleFilterCapable.cpp.
References mrpt::bayes::CParticleFilter::TParticleFilterOptions::adaptiveSampleSize, ASSERT_, mrpt::math::maximum(), MRPT_CHECK_NORMAL_NUMBER, MRPT_END, MRPT_END_WITH_CLEAN_UP, MRPT_START, mrpt::bayes::CParticleFilter::TParticleFilterOptions::resamplingMethod, and THROW_EXCEPTION.
|
overrideprotectedvirtual |
Introduces a pure virtual method responsible for loading from a CStream This can not be used directly be users, instead use "stream >> object;" for reading it from a stream or "stream >> object_ptr;" if the class is unknown apriori.
in | The input binary stream where the object data must read from. |
version | The version of the object stored in the stream: use this version number in your code to know how to read the incoming data. |
std::exception | On any error, see CStream::ReadBuffer |
Implements mrpt::utils::CSerializable.
Definition at line 195 of file CPosePDFParticles.cpp.
References MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION.
|
inlineinherited |
Reads the sequence of particles and their weights from a stream (requires T implementing CSerializable).
Definition at line 236 of file CParticleFilterData.h.
void CPosePDFParticles::resetAroundSetOfPoses | ( | const std::vector< mrpt::math::TPose2D > & | list_poses, |
const 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
.
[in] | list_poses | The poses (x,y,phi) around which particles will be spread. Must contains at least one pose. |
[in] | num_particles_per_pose | Number of particles to be spread around each of the "spots" in list_poses. Must be >=1. |
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".
Definition at line 260 of file CPosePDFParticles.cpp.
References ASSERT_, ASSERT_EQUAL_, mrpt::utils::clear(), mrpt::random::getRandomGenerator(), MRPT_END, and MRPT_START.
Reset the PDF to a single point: All m_particles will be set exactly to the supplied pose.
location | The location to set all the m_particles. |
particlesCount | If this is set to 0 the number of m_particles remains unchanged. |
Definition at line 213 of file CPosePDFParticles.cpp.
References mrpt::utils::clear().
Referenced by mrpt::obs::CActionRobotMovement2D::computeFromOdometry_modelThrun(), and mrpt::poses::CPosePDFGrid::getCovarianceAndMean().
void CPosePDFParticles::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 cube.
If particlesCount is set to -1 the number of m_particles remains unchanged.
Definition at line 233 of file CPosePDFParticles.cpp.
References mrpt::utils::clear(), mrpt::random::getRandomGenerator(), MRPT_END, and MRPT_START.
Referenced by run_test_pf_localization().
void CPosePDFParticles::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.
Definition at line 465 of file CPosePDFParticles.cpp.
References mrpt::system::os::fclose(), mrpt::system::os::fopen(), and mrpt::system::os::fprintf().
|
overridevirtual |
Save PDF's m_particles to a text file.
In each line it will go: "x y phi weight"
Implements mrpt::utils::CProbabilityDensityFunction< CPose2D, 3 >.
Definition at line 304 of file CPosePDFParticles.cpp.
References mrpt::system::os::fclose(), mrpt::system::os::fopen(), and mrpt::system::os::fprintf().
|
inlineoverridevirtualinherited |
Modifies i'th particle (logarithm) weight, where first one is index 0.
Implements mrpt::bayes::CParticleFilterCapable.
Definition at line 48 of file CParticleFilterData.h.
|
inline |
Get the m_particles count (equivalent to "particlesCount")
Definition at line 120 of file CPosePDFParticles.h.
References mrpt::bayes::CParticleFilterData< CPose2D >::m_particles.
|
inlineinherited |
Dumps the sequence of particles and their weights to a stream (requires T implementing CSerializable).
Definition at line 220 of file CParticleFilterData.h.
|
inlinevirtualinherited |
Introduces a pure virtual method responsible for writing to a mxArray
Matlab object, typically a MATLAB struct
whose contents are documented in each derived class.
mxArray
(caller is responsible of memory freeing) or nullptr is class does not support conversion to MATLAB. Definition at line 89 of file CSerializable.h.
|
overrideprotectedvirtual |
Introduces a pure virtual method responsible for writing to a CStream.
This can not be used directly be users, instead use "stream << object;" for writing it to a stream.
out | The output binary stream where object must be dumped. |
getVersion | If nullptr, the object must be dumped. If not, only the version of the object dump must be returned in this pointer. This enables the versioning of objects dumping and backward compatibility with previously stored data. |
std::exception | On any error, see CStream::WriteBuffer |
Implements mrpt::utils::CSerializable.
Definition at line 181 of file CPosePDFParticles.cpp.
|
staticprotected |
Definition at line 38 of file CPosePDFParticles.h.
|
static |
Definition at line 38 of file CPosePDFParticles.h.
|
mutableprotectedinherited |
Auxiliary vectors, see CParticleFilterCapable::prepareFastDrawSample for more information.
Definition at line 237 of file CParticleFilterCapable.h.
|
inherited |
|
staticprotected |
Definition at line 38 of file CPosePDFParticles.h.
|
staticinherited |
The length of the variable, for example, 3 for a 3D point, 6 for a 3D pose (x y z yaw pitch roll).
Definition at line 34 of file CProbabilityDensityFunction.h.
Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019 |