Main MRPT website > C++ reference for MRPT 1.3.2
CParticleFilter.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2015, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +---------------------------------------------------------------------------+ */
9 #ifndef CPARTICLEFILTER_H
10 #define CPARTICLEFILTER_H
11 
12 #include <mrpt/utils/core_defs.h>
15 
16 namespace mrpt
17 {
18  namespace obs { class CSensoryFrame; class CActionCollection; }
19 
20  /** The namespace for Bayesian filtering algorithm: different particle filters and Kalman filter algorithms. \ingroup mrpt_base_grp
21  */
22  namespace bayes
23  {
25 
26  /** This class acts as a common interface to the different interfaces (see CParticleFilter::TParticleFilterAlgorithm) any bayes::CParticleFilterCapable class can implement: it is the invoker of particle filter algorithms.
27  * The particle filter is executed on a probability density function (PDF) described by a CParticleFilterCapable object, passed in the constructor or alternatively through the CParticleFilter::executeOn method.<br>
28  *
29  * For a complete example and further details, see the <a href="http://www.mrpt.org/Particle_Filter_Tutorial" >Particle Filter tutorial</a>.
30  *
31  * The basic SIR algorithm (pfStandardProposal) consists of:
32  * - Execute a prediction with the given "action".
33  * - Update the weights of the particles using the likelihood of the "observation".
34  * - Normalize weights.
35  * - Perform resampling if the ESS is below the threshold options.BETA.
36  *
37  * \ingroup mrpt_base_grp
38  * \sa mrpt::poses::CPoseParticlesPDF
39  */
41  {
42  public:
43 
44  /** Defines different types of particle filter algorithms.
45  * The defined SIR implementations are:
46  * - pfStandardProposal: Standard proposal distribution + weights according to likelihood function.
47  * - pfAuxiliaryPFStandard: An auxiliary PF using the standard proposal distribution.
48  * - pfOptimalProposal: Use the optimal proposal distribution (where available!, usually this will perform approximations)
49  * - pfAuxiliaryPFOptimal: Use the optimal proposal and a auxiliary particle filter (see <a href="http://www.mrpt.org/Paper:An_Optimal_Filtering_Algorithm_for_Non-Parametric_Observation_Models_in_Robot_Localization_(ICRA_2008)" >paper</a>).
50  *
51  * See the theoretical discussion in <a href="http://www.mrpt.org/Resampling_Schemes" >resampling schemes</a>.
52  */
54  {
55  pfStandardProposal = 0,
58  pfAuxiliaryPFOptimal
59  };
60 
61  /** Defines the different resampling algorithms.
62  * The implemented resampling methods are:
63  * - prMultinomial (Default): Uses standard select with replacement (draws M random uniform numbers)
64  * - prResidual: The residual or "remainder" method.
65  * - prStratified: The stratified resampling, where a uniform sample is drawn for each of M subdivisions of the range (0,1].
66  * - prSystematic: A single uniform sample is drawn in the range (0,1/M].
67  *
68  * See the theoretical discussion in <a href="http://www.mrpt.org/Resampling_Schemes" >resampling schemes</a>.
69  */
71  {
72  prMultinomial = 0,
75  prSystematic
76  };
77 
78  /** The configuration of a particle filter.
79  */
81  {
82  public:
83  /** Initilization of default parameters
84  */
86 
87  /** See mrpt::utils::CLoadableOptions
88  */
89  void loadFromConfigFile(
90  const mrpt::utils::CConfigFileBase &source,
91  const std::string &section);
92 
93  /** See mrpt::utils::CLoadableOptions
94  */
95  void dumpToTextStream(mrpt::utils::CStream &out) const;
96 
97  /** A flag that indicates whether the CParticleFilterCapable object should perform adative sample size (default=false).
98  */
100 
101  /** The resampling of particles will be performed when ESS (in range [0,1]) < BETA (default is 0.5)
102  */
103  double BETA;
104 
105  /** The initial number of particles in the filter (it can change only if adaptiveSampleSize=true) (default=1)
106  */
107  unsigned int sampleSize;
108 
109  /** In the algorithm "CParticleFilter::pfAuxiliaryPFOptimal" (and in "CParticleFilter::pfAuxiliaryPFStandard" only if pfAuxFilterStandard_FirstStageWeightsMonteCarlo = true) the number of samples for searching the maximum likelihood value and also to estimate the "first stage weights" (see papers!) (default=100)
110  */
112 
113  /** An optional step to "smooth" dramatic changes in the observation model to affect the variance of the particle weights, eg weight*=likelihood^powFactor (default=1 = no effects).
114  */
115  double powFactor;
116 
117  /** The PF algorithm to use (default=pfStandardProposal) See TParticleFilterAlgorithm for the posibilities.
118  */
120 
121  /** The resampling algorithm to use (default=prMultinomial).
122  */
124 
125 
126  /** Only for PF_algorithm=pfAuxiliaryPFOptimal: If a given particle has a max_likelihood (from the a-priori estimate) below the maximum from all the samples - max_loglikelihood_dyn_range, then the particle is directly discarded.
127  * This is done to assure that the rejection sampling doesn't get stuck in an infinite loop trying to get an acceptable sample.
128  * Default = 15 (in logarithmic likelihood)
129  */
131 
132  /** Only for PF_algorithm==pfAuxiliaryPFStandard:
133  * If false, the APF will predict the first stage weights just at the mean of the prior of the next time step.
134  * If true, these weights will be estimated as described in the papers for the "pfAuxiliaryPFOptimal" method, i.e. through a monte carlo simulation.
135  * In that case, "pfAuxFilterOptimal_MaximumSearchSamples" is the number of MC samples used.
136  */
138 
139  bool verbose; //!< Enable extra messages for each PF iteration (Default=false)
140 
141  /** (Default=false) In the algorithm "CParticleFilter::pfAuxiliaryPFOptimal", if set to true, do not perform rejection sampling, but just the most-likely (ML) particle found in the preliminary weight-determination stage.
142  */
144  };
145 
146 
147  /** Statistics for being returned from the "execute" method.
148  */
150  {
151  TParticleFilterStats() : ESS_beforeResample(0), weightsVariance_beforeResample (0) { }
154  };
155 
156  /** Default constructor.
157  * After creating the PF object, set the options in CParticleFilter::m_options, then execute steps through CParticleFilter::executeOn.
158  */
159  CParticleFilter( );
160 
161  virtual ~CParticleFilter() {}
162 
163  /** Executes a complete prediction + update step of the selected particle filtering algorithm.
164  * The member CParticleFilter::m_options must be set before calling this to settle the algorithm parameters.
165  *
166  * \param obj The object representing the probability distribution function (PDF) which apply the particle filter algorithm to.
167  * \param action A pointer to an action in the form of a CActionCollection, or NULL if there is no action.
168  * \param observation A pointer to observations in the form of a CSensoryFrame, or NULL if there is no observation.
169  * \param stats An output structure for gathering statistics of the particle filter execution, or set to NULL if you do not need it (see CParticleFilter::TParticleFilterStats).
170  *
171  * \sa CParticleFilterCapable, executeOn
172  */
173  void executeOn(
175  const mrpt::obs::CActionCollection *action,
176  const mrpt::obs::CSensoryFrame *observation,
177  TParticleFilterStats *stats = NULL);
178 
179 
180  /** The options to be used in the PF, must be set before executing any step of the particle filter.
181  */
183 
184  }; // End of class def.
185 
186  } // end namespace
187 } // end namespace
188 #endif
unsigned int pfAuxFilterOptimal_MaximumSearchSamples
In the algorithm "CParticleFilter::pfAuxiliaryPFOptimal" (and in "CParticleFilter::pfAuxiliaryPFStand...
Statistics for being returned from the "execute" method.
Declares a class for storing a collection of robot actions.
This class allows loading and storing values and vectors of different types from a configuration text...
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:38
TParticleResamplingAlgorithm resamplingMethod
The resampling algorithm to use (default=prMultinomial).
TParticleFilterAlgorithm
Defines different types of particle filter algorithms.
Declares a class for storing a "sensory frame", a set of "observations" taken by the robot approximat...
This virtual class defines the interface that any particles based PDF class must implement in order t...
This class acts as a common interface to the different interfaces (see CParticleFilter::TParticleFilt...
bool pfAuxFilterStandard_FirstStageWeightsMonteCarlo
Only for PF_algorithm==pfAuxiliaryPFStandard: If false, the APF will predict the first stage weights ...
double BETA
The resampling of particles will be performed when ESS (in range [0,1]) < BETA (default is 0...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
bool verbose
Enable extra messages for each PF iteration (Default=false)
double max_loglikelihood_dyn_range
Only for PF_algorithm=pfAuxiliaryPFOptimal: If a given particle has a max_likelihood (from the a-prio...
double powFactor
An optional step to "smooth" dramatic changes in the observation model to affect the variance of the ...
The configuration of a particle filter.
unsigned int sampleSize
The initial number of particles in the filter (it can change only if adaptiveSampleSize=true) (defaul...
bool pfAuxFilterOptimal_MLE
(Default=false) In the algorithm "CParticleFilter::pfAuxiliaryPFOptimal", if set to true...
CParticleFilter::TParticleFilterOptions m_options
The options to be used in the PF, must be set before executing any step of the particle filter...
This base class provides a common printf-like method to send debug information to std::cout...
TParticleResamplingAlgorithm
Defines the different resampling algorithms.
TParticleFilterAlgorithm PF_algorithm
The PF algorithm to use (default=pfStandardProposal) See TParticleFilterAlgorithm for the posibilitie...
This is a virtual base class for sets of options than can be loaded from and/or saved to configuratio...
bool adaptiveSampleSize
A flag that indicates whether the CParticleFilterCapable object should perform adative sample size (d...



Page generated by Doxygen 1.8.9.1 for MRPT 1.3.2 SVN:Unversioned directory at Tue Dec 8 09:49:21 UTC 2015