Main MRPT website > C++ reference
MRPT logo
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Private Attributes | Friends

mrpt::bayes::CParticleFilterCapable Class Reference


Detailed Description

This virtual class defines the interface that any particles based PDF class must implement in order to be executed by a mrpt::bayes::CParticleFilter.

See the Particle Filter tutorial explaining how to use the particle filter-related classes.

See also:
CParticleFilter, CParticleFilterData

Definition at line 45 of file CParticleFilterCapable.h.

#include <mrpt/bayes/CParticleFilterCapable.h>

Inheritance diagram for mrpt::bayes::CParticleFilterCapable:
Inheritance graph
[legend]

List of all members.

Classes

struct  TFastDrawAuxVars
 Auxiliary vectors, see CParticleFilterCapable::prepareFastDrawSample for more information. More...

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

 CParticleFilterCapable ()
virtual ~CParticleFilterCapable ()
 Virtual destructor.
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).
virtual double getW (size_t i) const =0
 Access to i'th particle (logarithm) weight, where first one is index 0.
virtual void setW (size_t i, double w)=0
 Modifies i'th particle (logarithm) weight, where first one is index 0.
virtual size_t particlesCount () const =0
 Get the m_particles count.
void prediction_and_update (const mrpt::slam::CActionCollection *action, const mrpt::slam::CSensoryFrame *observation, const bayes::CParticleFilter::TParticleFilterOptions &PF_options)
 Performs the prediction stage of the Particle Filter.
virtual void performSubstitution (const std::vector< size_t > &indx)=0
 Performs the substitution for internal use of resample in particle filter algorithm, don't call it directly.
virtual double normalizeWeights (double *out_max_log_w=NULL)=0
 Normalize the (logarithmic) weights, such as the maximum weight is zero.
virtual double ESS ()=0
 Returns the normalized ESS (Estimated Sample Size), in the range [0,1].
void performResampling (const bayes::CParticleFilter::TParticleFilterOptions &PF_options)
 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 vector_double &in_logWeights, std::vector< size_t > &out_indexes)
 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 vector_double &in_logWeights, 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::slam::CActionCollection *action, const mrpt::slam::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::slam::CActionCollection *action, const mrpt::slam::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::slam::CActionCollection *action, const mrpt::slam::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::slam::CActionCollection *action, const mrpt::slam::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

Friends

class CParticleFilter

Member Typedef Documentation

typedef double( * mrpt::bayes::CParticleFilterCapable::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".

The default evaluator function "defaultEvaluator" simply returns the particle weight.

Parameters:
indexThis is the index of the particle its probability is being computed.
actionThe value of this is the parameter passed to "prepareFastDrawSample"
observationThe value of this is the parameter passed to "prepareFastDrawSample" The action and the observation are declared as "void*" for a greater flexibility.
See also:
prepareFastDrawSample

Definition at line 72 of file CParticleFilterCapable.h.


Constructor & Destructor Documentation

mrpt::bayes::CParticleFilterCapable::CParticleFilterCapable ( ) [inline]

Definition at line 54 of file CParticleFilterCapable.h.

virtual mrpt::bayes::CParticleFilterCapable::~CParticleFilterCapable ( ) [inline, virtual]

Virtual destructor.

Definition at line 60 of file CParticleFilterCapable.h.


Member Function Documentation

static void mrpt::bayes::CParticleFilterCapable::computeResampling ( CParticleFilter::TParticleResamplingAlgorithm  method,
const vector_double in_logWeights,
std::vector< size_t > &  out_indexes 
) [static]

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

See also:
performResampling
static double mrpt::bayes::CParticleFilterCapable::defaultEvaluator ( const bayes::CParticleFilter::TParticleFilterOptions PF_options,
const CParticleFilterCapable obj,
size_t  index,
const void *  action,
const void *  observation 
) [inline, static]

The default evaluator function, which simply returns the particle weight.

The action and the observation are declared as "void*" for a greater flexibility.

See also:
prepareFastDrawSample

Definition at line 83 of file CParticleFilterCapable.h.

References getW(), and MRPT_UNUSED_PARAM.

virtual double mrpt::bayes::CParticleFilterCapable::ESS ( ) [pure virtual]

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.

size_t mrpt::bayes::CParticleFilterCapable::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).

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:

  • You MUST call "prepareFastDrawSample" ONCE before calling this method. That method must be called after modifying the particle filter (executing one step, resampling, etc...)
  • This method returns ONE index for the selected ("drawn") particle, in the range [0,M-1]
  • You do not need to call "normalizeWeights" before calling this.
    See also:
    prepareFastDrawSample
virtual double mrpt::bayes::CParticleFilterCapable::getW ( size_t  i) const [pure virtual]

Access to i'th particle (logarithm) weight, where first one is index 0.

Referenced by defaultEvaluator().

static void mrpt::bayes::CParticleFilterCapable::log2linearWeights ( const vector_double in_logWeights,
vector_double out_linWeights 
) [static]

A static method to compute the linear, normalized (the sum the unity) weights from log-weights.

See also:
performResampling
virtual double mrpt::bayes::CParticleFilterCapable::normalizeWeights ( double *  out_max_log_w = NULL) [pure virtual]

Normalize the (logarithmic) weights, such as the maximum weight is zero.

Parameters:
out_max_log_wIf provided, will return with the maximum log_w before normalizing, such as new_weights = old_weights - max_log_w.
Returns:
The max/min ratio of weights ("dynamic range")
virtual size_t mrpt::bayes::CParticleFilterCapable::particlesCount ( ) const [pure virtual]

Get the m_particles count.

void mrpt::bayes::CParticleFilterCapable::performResampling ( const bayes::CParticleFilter::TParticleFilterOptions PF_options)

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"

See also:
resample
virtual void mrpt::bayes::CParticleFilterCapable::performSubstitution ( const std::vector< size_t > &  indx) [pure virtual]

Performs the substitution for internal use of resample in particle filter algorithm, don't call it directly.

Parameters:
indxThe indices of current m_particles to be saved as the new m_particles set.
void mrpt::bayes::CParticleFilterCapable::prediction_and_update ( const mrpt::slam::CActionCollection action,
const mrpt::slam::CSensoryFrame observation,
const bayes::CParticleFilter::TParticleFilterOptions PF_options 
)

Performs the prediction stage of the Particle Filter.

This method simply selects the appropiate protected method according to the particle filter algorithm to run.

See also:
prediction_and_update_pfStandardProposal,prediction_and_update_pfAuxiliaryPFStandard,prediction_and_update_pfOptimalProposal,prediction_and_update_pfAuxiliaryPFOptimal
virtual void mrpt::bayes::CParticleFilterCapable::prediction_and_update_pfAuxiliaryPFOptimal ( const mrpt::slam::CActionCollection action,
const mrpt::slam::CSensoryFrame observation,
const bayes::CParticleFilter::TParticleFilterOptions PF_options 
) [protected, virtual]

Performs the particle filter prediction/update stages for the algorithm "pfAuxiliaryPFOptimal" (if not implemented in heritated class, it will raise a 'non-implemented' exception).

See also:
prediction_and_update

Reimplemented in mrpt::hmtslam::CLocalMetricHypothesis, mrpt::slam::CMonteCarloLocalization2D, mrpt::slam::CMonteCarloLocalization3D, and mrpt::slam::CMultiMetricMapPDF.

virtual void mrpt::bayes::CParticleFilterCapable::prediction_and_update_pfAuxiliaryPFStandard ( const mrpt::slam::CActionCollection action,
const mrpt::slam::CSensoryFrame observation,
const bayes::CParticleFilter::TParticleFilterOptions PF_options 
) [protected, virtual]

Performs the particle filter prediction/update stages for the algorithm "pfAuxiliaryPFStandard" (if not implemented in heritated class, it will raise a 'non-implemented' exception).

See also:
prediction_and_update

Reimplemented in mrpt::slam::CMonteCarloLocalization2D, and mrpt::slam::CMonteCarloLocalization3D.

virtual void mrpt::bayes::CParticleFilterCapable::prediction_and_update_pfOptimalProposal ( const mrpt::slam::CActionCollection action,
const mrpt::slam::CSensoryFrame observation,
const bayes::CParticleFilter::TParticleFilterOptions PF_options 
) [protected, virtual]

Performs the particle filter prediction/update stages for the algorithm "pfOptimalProposal" (if not implemented in heritated class, it will raise a 'non-implemented' exception).

See also:
prediction_and_update

Reimplemented in mrpt::hmtslam::CLocalMetricHypothesis, and mrpt::slam::CMultiMetricMapPDF.

virtual void mrpt::bayes::CParticleFilterCapable::prediction_and_update_pfStandardProposal ( const mrpt::slam::CActionCollection action,
const mrpt::slam::CSensoryFrame observation,
const bayes::CParticleFilter::TParticleFilterOptions PF_options 
) [protected, virtual]

Performs the particle filter prediction/update stages for the algorithm "pfStandardProposal" (if not implemented in heritated class, it will raise a 'non-implemented' exception).

See also:
prediction_and_update

Reimplemented in mrpt::slam::CMonteCarloLocalization2D, mrpt::slam::CMonteCarloLocalization3D, and mrpt::slam::CMultiMetricMapPDF.

void mrpt::bayes::CParticleFilterCapable::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.

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):

  • DYNAMIC SAMPLE SIZE=NO: In this case this method fills out an internal array (m_fastDrawAuxiliary.alreadyDrawnIndexes) with the random indexes generated according to the selected resample scheme in TParticleFilterOptions. Those indexes are read sequentially by subsequent calls to fastDrawSample.
  • DYNAMIC SAMPLE SIZE=YES: Then:
    • If TParticleFilterOptions.resamplingMethod = prMultinomial, the internal buffers will be filled out (m_fastDrawAuxiliary.CDF, CDF_indexes & PDF) and then fastDrawSample can be called an arbitrary number of times to generate random indexes.
    • For the rest of resampling algorithms, an exception will be raised since they are not appropriate for a dynamic (unknown in advance) number of particles.

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.

See also:
fastDrawSample
virtual void mrpt::bayes::CParticleFilterCapable::setW ( size_t  i,
double  w 
) [pure virtual]

Modifies i'th particle (logarithm) weight, where first one is index 0.


Friends And Related Function Documentation

friend class CParticleFilter [friend]

Definition at line 47 of file CParticleFilterCapable.h.


Member Data Documentation

Auxiliary vectors, see CParticleFilterCapable::prepareFastDrawSample for more information.

Definition at line 248 of file CParticleFilterCapable.h.

Definition at line 50 of file CParticleFilterCapable.h.




Page generated by Doxygen 1.7.3 for MRPT 0.9.4 SVN: at Sat Mar 26 06:16:28 UTC 2011