Main MRPT website > C++ reference for MRPT 1.9.9
CParticleFilter.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, 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 
10 #include "base-precomp.h" // Precompiled headers
11 
12 #include <cmath> // for exp
13 #include <mrpt/bayes/CParticleFilter.h> // for CParticleFilter::TPar...
14 #include <mrpt/utils/CConfigFileBase.h> // for CConfigFileBase, MRPT...
15 #include <mrpt/utils/CStream.h> // for CStream
16 #include <stddef.h> // for size_t
17 #include <exception> // for exception
18 #include <string> // for string, allocator
19 #include <mrpt/utils/COutputLogger.h> // for COutputLogger, MRPT_L...
20 #include <mrpt/utils/bits.h> // for format, square
21 #include <mrpt/utils/mrpt_macros.h> // for MRPT_END, MRPT_START, e
22 namespace mrpt
23 {
24 namespace obs
25 {
26 class CActionCollection;
27 }
28 }
29 namespace mrpt
30 {
31 namespace obs
32 {
33 class CSensoryFrame;
34 }
35 }
36 
37 using namespace mrpt::bayes;
38 using namespace mrpt::utils;
39 
41  : mrpt::utils::COutputLogger("CParticleFilter"), m_options()
42 {
43 }
44 
45 /*---------------------------------------------------------------
46  TParticleFilterOptions
47  ---------------------------------------------------------------*/
49  : adaptiveSampleSize(false),
50  BETA(0.5),
51  sampleSize(1),
52  pfAuxFilterOptimal_MaximumSearchSamples(100),
53  powFactor(1),
54  PF_algorithm(pfStandardProposal),
55  resamplingMethod(prMultinomial),
56  max_loglikelihood_dyn_range(15),
57  pfAuxFilterStandard_FirstStageWeightsMonteCarlo(false),
58  pfAuxFilterOptimal_MLE(false)
59 {
60 }
61 
64 {
66  PF_algorithm, "The PF algorithm to use. See TParticleFilterAlgorithm");
68  resamplingMethod,
69  "The resampling algorithm to use. See TParticleResamplingAlgorithm");
70 
72  adaptiveSampleSize,
73  "A flag that indicates whether the CParticleFilterCapable object "
74  "should perform adative sample size (default=false)");
76  BETA,
77  "The resampling of particles will be performed when ESS (in range "
78  "[0,1]) < BETA (default is 0.5)");
80  sampleSize,
81  "The initial number of particles in the filter (it can change only if "
82  "adaptiveSampleSize=true) (default=1)");
84  pfAuxFilterOptimal_MaximumSearchSamples, "See Doxygen docs");
86  powFactor,
87  "An optional step to smooth dramatic changes in the observation model "
88  "to affect the variance of the particle weights (default=1)");
90  max_loglikelihood_dyn_range,
91  "Only for PF_algorithm=pfAuxiliaryPFOptimal");
93  pfAuxFilterStandard_FirstStageWeightsMonteCarlo,
94  "Only for PF_algorithm==pfAuxiliaryPFStandard");
95  MRPT_SAVE_CONFIG_VAR_COMMENT(pfAuxFilterOptimal_MLE, "See doxygen docs.");
96 }
97 
98 /*---------------------------------------------------------------
99  loadFromConfigFile
100  ---------------------------------------------------------------*/
102  const mrpt::utils::CConfigFileBase& iniFile, const std::string& section)
103 {
104  MRPT_START
105 
107  adaptiveSampleSize, bool, iniFile, section.c_str());
108  MRPT_LOAD_CONFIG_VAR_NO_DEFAULT(BETA, double, iniFile, section.c_str());
109  MRPT_LOAD_CONFIG_VAR_NO_DEFAULT(sampleSize, int, iniFile, section.c_str());
110  MRPT_LOAD_CONFIG_VAR(powFactor, double, iniFile, section.c_str());
112  max_loglikelihood_dyn_range, double, iniFile, section.c_str());
113  ASSERT_(max_loglikelihood_dyn_range >= 0);
114 
115  PF_algorithm = iniFile.read_enum<TParticleFilterAlgorithm>(
116  section, "PF_algorithm", PF_algorithm, true);
117  resamplingMethod = iniFile.read_enum<TParticleResamplingAlgorithm>(
118  section, "resamplingMethod", resamplingMethod, true);
119 
120  if (PF_algorithm == pfAuxiliaryPFOptimal)
121  {
123  pfAuxFilterOptimal_MaximumSearchSamples, int, iniFile,
124  section.c_str());
125  }
126  else
127  {
129  pfAuxFilterOptimal_MaximumSearchSamples, int, iniFile,
130  section.c_str());
131  }
132 
134  pfAuxFilterStandard_FirstStageWeightsMonteCarlo, bool, iniFile,
135  section.c_str());
137  pfAuxFilterOptimal_MLE, bool, iniFile, section.c_str());
138 
139  MRPT_END
140 }
void loadFromConfigFile(const mrpt::utils::CConfigFileBase &source, const std::string &section) override
This method load the options from a ".ini"-like file or memory-stored string list.
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
The namespace for Bayesian filtering algorithm: different particle filters and Kalman filter algorith...
GLdouble s
Definition: glext.h:3676
This class allows loading and storing values and vectors of different types from a configuration text...
TParticleResamplingAlgorithm
Defines the different resampling algorithms.
#define MRPT_SAVE_CONFIG_VAR_COMMENT(variableName, __comment)
#define MRPT_END
TParticleFilterOptions()
Initilization of default parameters.
const GLubyte * c
Definition: glext.h:6313
virtual void saveToConfigFile(mrpt::utils::CConfigFileBase &target, const std::string &section) const override
This method saves the options to a ".ini"-like file or memory-stored string list. ...
GLsizei const GLchar ** string
Definition: glext.h:4101
ENUMTYPE read_enum(const std::string &section, const std::string &name, const ENUMTYPE &defaultValue, bool failIfNotFound=false) const
Reads an "enum" value, where the value in the config file can be either a numerical value or the symb...
#define MRPT_START
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
TParticleFilterAlgorithm
Defines different types of particle filter algorithms.
CParticleFilter()
Default constructor.
#define ASSERT_(f)
#define MRPT_LOAD_CONFIG_VAR_NO_DEFAULT( variableName, variableType, configFileObject, sectionNameStr)
#define MRPT_LOAD_CONFIG_VAR( variableName, variableType, configFileObject, sectionNameStr)
An useful macro for loading variables stored in a INI-like file under a key with the same name that t...



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