A curiously recurring template pattern (CRTP) approach to providing the basic functionality of any CParticleFilterData<> class.
Users should inherit from CParticleFilterData<>, which in turn will automatically inhirit from this base class.
Definition at line 31 of file CParticleFilterData.h.
#include <mrpt/bayes/CParticleFilterData.h>
Public Types | |
typedef double(* | TParticleProbabilityEvaluator) (const bayes::CParticleFilter::TParticleFilterOptions &PF_options, const CParticleFilterCapable *obj, size_t index, const void *action, const void *observation) |
A callback function type for evaluating the probability of m_particles of being selected, used in "fastDrawSample". | |
Public Member Functions | |
const Derived & | derived () const |
CRTP helper method. | |
Derived & | derived () |
CRTP helper method. | |
double | getW (size_t i) const MRPT_OVERRIDE |
Access to i'th particle (logarithm) weight, where first one is index 0. | |
void | setW (size_t i, double w) MRPT_OVERRIDE |
Modifies i'th particle (logarithm) weight, where first one is index 0. | |
size_t | particlesCount () const MRPT_OVERRIDE |
Get the m_particles count. | |
double | normalizeWeights (double *out_max_log_w=NULL) MRPT_OVERRIDE |
Normalize the (logarithmic) weights, such as the maximum weight is zero. | |
double | ESS () const MRPT_OVERRIDE |
Returns the normalized ESS (Estimated Sample Size), in the range [0,1]. | |
void | performSubstitution (const std::vector< size_t > &indx) MRPT_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. | |
void | prepareFastDrawSample (const bayes::CParticleFilter::TParticleFilterOptions &PF_options, TParticleProbabilityEvaluator partEvaluator=defaultEvaluator, const void *action=NULL, const void *observation=NULL) const |
Prepares data structures for calling fastDrawSample method next. | |
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). | |
void | prediction_and_update (const mrpt::obs::CActionCollection *action, const mrpt::obs::CSensoryFrame *observation, const bayes::CParticleFilter::TParticleFilterOptions &PF_options) |
Performs the prediction stage of the Particle Filter. | |
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. | |
Static Public Member Functions | |
static double | defaultEvaluator (const bayes::CParticleFilter::TParticleFilterOptions &PF_options, const CParticleFilterCapable *obj, size_t index, const void *action, const void *observation) |
The default evaluator function, which simply returns the particle weight. | |
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. | |
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. | |
Protected Member Functions | |
virtual void | prediction_and_update_pfStandardProposal (const mrpt::obs::CActionCollection *action, const mrpt::obs::CSensoryFrame *observation, const bayes::CParticleFilter::TParticleFilterOptions &PF_options) |
Performs the particle filter prediction/update stages for the algorithm "pfStandardProposal" (if not implemented in heritated class, it will raise a 'non-implemented' exception). | |
virtual void | prediction_and_update_pfAuxiliaryPFStandard (const mrpt::obs::CActionCollection *action, const mrpt::obs::CSensoryFrame *observation, const bayes::CParticleFilter::TParticleFilterOptions &PF_options) |
Performs the particle filter prediction/update stages for the algorithm "pfAuxiliaryPFStandard" (if not implemented in heritated class, it will raise a 'non-implemented' exception). | |
virtual void | prediction_and_update_pfOptimalProposal (const mrpt::obs::CActionCollection *action, const mrpt::obs::CSensoryFrame *observation, const bayes::CParticleFilter::TParticleFilterOptions &PF_options) |
Performs the particle filter prediction/update stages for the algorithm "pfOptimalProposal" (if not implemented in heritated class, it will raise a 'non-implemented' exception). | |
virtual void | prediction_and_update_pfAuxiliaryPFOptimal (const mrpt::obs::CActionCollection *action, const mrpt::obs::CSensoryFrame *observation, const bayes::CParticleFilter::TParticleFilterOptions &PF_options) |
Performs the particle filter prediction/update stages for the algorithm "pfAuxiliaryPFOptimal" (if not implemented in heritated class, it will raise a 'non-implemented' exception). | |
Protected Attributes | |
TFastDrawAuxVars | m_fastDrawAuxiliary |
Auxiliary vectors, see CParticleFilterCapable::prepareFastDrawSample for more information. | |
Static Private Attributes | |
static const unsigned | PARTICLE_FILTER_CAPABLE_FAST_DRAW_BINS |
|
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 54 of file CParticleFilterCapable.h.
|
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. |
|
inlinestaticinherited |
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 65 of file CParticleFilterCapable.h.
References mrpt::bayes::CParticleFilterCapable::getW(), and MRPT_UNUSED_PARAM.
|
inline |
CRTP helper method.
Definition at line 36 of file CParticleFilterData.h.
|
inline |
CRTP helper method.
Definition at line 34 of file CParticleFilterData.h.
Referenced by mrpt::bayes::CParticleFilterDataImpl< Derived, particle_list_t >::ESS(), mrpt::bayes::CParticleFilterDataImpl< Derived, particle_list_t >::getW(), mrpt::bayes::CParticleFilterDataImpl< Derived, particle_list_t >::normalizeWeights(), mrpt::bayes::CParticleFilterDataImpl< Derived, particle_list_t >::particlesCount(), mrpt::bayes::CParticleFilterDataImpl< Derived, particle_list_t >::performSubstitution(), and mrpt::bayes::CParticleFilterDataImpl< Derived, particle_list_t >::setW().
|
inlinevirtual |
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 78 of file CParticleFilterData.h.
References mrpt::bayes::CParticleFilterDataImpl< Derived, particle_list_t >::derived(), MRPT_END, MRPT_START, and mrpt::utils::square().
|
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:
|
inlinevirtual |
Access to i'th particle (logarithm) weight, where first one is index 0.
Implements mrpt::bayes::CParticleFilterCapable.
Definition at line 38 of file CParticleFilterData.h.
References mrpt::bayes::CParticleFilterDataImpl< Derived, particle_list_t >::derived(), and THROW_EXCEPTION_CUSTOM_MSG1.
|
staticinherited |
A static method to compute the linear, normalized (the sum the unity) weights from log-weights.
|
inlinevirtual |
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 55 of file CParticleFilterData.h.
References mrpt::bayes::CParticleFilterDataImpl< Derived, particle_list_t >::derived(), MRPT_END, and MRPT_START.
|
inlinevirtual |
Get the m_particles count.
Implements mrpt::bayes::CParticleFilterCapable.
Definition at line 50 of file CParticleFilterData.h.
References mrpt::bayes::CParticleFilterDataImpl< Derived, particle_list_t >::derived().
|
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. |
|
inlinevirtual |
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 98 of file CParticleFilterData.h.
References ASSERT_, mrpt::bayes::CParticleFilterDataImpl< Derived, particle_list_t >::derived(), MRPT_END, and MRPT_START.
|
inherited |
Performs the prediction stage of the Particle Filter.
This method simply selects the appropiate protected method according to the particle filter algorithm to run.
|
protectedvirtualinherited |
Performs the particle filter prediction/update stages for the algorithm "pfAuxiliaryPFOptimal" (if not implemented in heritated class, it will raise a 'non-implemented' exception).
Reimplemented in mrpt::hmtslam::CLocalMetricHypothesis, mrpt::maps::CMultiMetricMapPDF, mrpt::slam::CMonteCarloLocalization2D, and mrpt::slam::CMonteCarloLocalization3D.
|
protectedvirtualinherited |
Performs the particle filter prediction/update stages for the algorithm "pfAuxiliaryPFStandard" (if not implemented in heritated class, it will raise a 'non-implemented' exception).
Reimplemented in mrpt::slam::CMonteCarloLocalization2D, and mrpt::slam::CMonteCarloLocalization3D.
|
protectedvirtualinherited |
Performs the particle filter prediction/update stages for the algorithm "pfOptimalProposal" (if not implemented in heritated class, it will raise a 'non-implemented' exception).
Reimplemented in mrpt::hmtslam::CLocalMetricHypothesis, and mrpt::maps::CMultiMetricMapPDF.
|
protectedvirtualinherited |
Performs the particle filter prediction/update stages for the algorithm "pfStandardProposal" (if not implemented in heritated class, it will raise a 'non-implemented' exception).
Reimplemented in mrpt::maps::CMultiMetricMapPDF, mrpt::slam::CMonteCarloLocalization2D, and mrpt::slam::CMonteCarloLocalization3D.
|
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.
|
inlinevirtual |
Modifies i'th particle (logarithm) weight, where first one is index 0.
Implements mrpt::bayes::CParticleFilterCapable.
Definition at line 44 of file CParticleFilterData.h.
References mrpt::bayes::CParticleFilterDataImpl< Derived, particle_list_t >::derived(), and THROW_EXCEPTION_CUSTOM_MSG1.
|
mutableprotectedinherited |
Auxiliary vectors, see CParticleFilterCapable::prepareFastDrawSample for more information.
Definition at line 233 of file CParticleFilterCapable.h.
|
staticprivateinherited |
Definition at line 32 of file CParticleFilterCapable.h.
Page generated by Doxygen 1.9.6 for MRPT 1.4.0 SVN: at Thu Mar 23 03:22:58 UTC 2023 |