MRPT  1.9.9
CMonteCarloLocalization2D.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-2018, 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 CMonteCarloLocalization2D_H
10 #define CMonteCarloLocalization2D_H
11 
15 #include <mrpt/obs/obs_frwds.h>
16 
17 namespace mrpt
18 {
19 namespace maps
20 {
21 class COccupancyGridMap2D;
22 }
23 
24 /** \ingroup mrpt_slam_grp */
25 namespace slam
26 {
27 /** Declares a class that represents a Probability Density Function (PDF) over a
28  * 2D pose (x,y,phi), using a set of weighted samples.
29  *
30  * This class also implements particle filtering for robot localization. See
31  * the MRPT
32  * application "app/pf-localization" for an example of usage.
33  *
34  * \sa CMonteCarloLocalization3D, CPose2D, CPosePDF, CPoseGaussianPDF,
35  * CParticleFilterCapable
36  * \ingroup mrpt_slam_grp
37  */
40  public PF_implementation<
41  mrpt::math::TPose2D, CMonteCarloLocalization2D,
42  mrpt::poses::CPosePDFParticles::PARTICLE_STORAGE>
43 {
44  public:
45  /** MCL parameters */
47 
48  /** Constructor
49  * \param M The number of m_particles.
50  */
51  CMonteCarloLocalization2D(size_t M = 1);
52 
53  /** Destructor */
55 
56  /** Reset the PDF to an uniformly distributed one, but only in the
57  * free-space
58  * of a given 2D occupancy-grid-map. Orientation is randomly generated in
59  * the whole 2*PI range.
60  * \param theMap The occupancy grid map
61  * \param freeCellsThreshold The minimum free-probability to consider a
62  * cell as empty (default is 0.7)
63  * \param particlesCount If set to -1 the number of m_particles remains
64  * unchanged.
65  * \param x_min The limits of the area to look for free cells.
66  * \param x_max The limits of the area to look for free cells.
67  * \param y_min The limits of the area to look for free cells.
68  * \param y_max The limits of the area to look for free cells.
69  * \param phi_min The limits of the area to look for free cells.
70  * \param phi_max The limits of the area to look for free cells.
71  * \sa resetDeterm32inistic
72  * \exception std::exception On any error (no free cell found in map,
73  * map=nullptr, etc...)
74  */
77  const double freeCellsThreshold = 0.7, const int particlesCount = -1,
78  const double x_min = -1e10f, const double x_max = 1e10f,
79  const double y_min = -1e10f, const double y_max = 1e10f,
80  const double phi_min = -M_PI, const double phi_max = M_PI);
81 
82  /** Update the m_particles, predicting the posterior of robot pose and map
83  * after a movement command.
84  * This method has additional configuration parameters in "options".
85  * Performs the update stage of the RBPF, using the sensed CSensoryFrame:
86  *
87  * \param action This is a pointer to CActionCollection, containing the
88  * pose change the robot has been commanded.
89  * \param observation This must be a pointer to a CSensoryFrame object,
90  * with robot sensed observations.
91  *
92  * \sa options
93  */
95  const mrpt::obs::CActionCollection* action,
96  const mrpt::obs::CSensoryFrame* observation,
98  override;
99 
100  /** Update the m_particles, predicting the posterior of robot pose and map
101  * after a movement command.
102  * This method has additional configuration parameters in "options".
103  * Performs the update stage of the RBPF, using the sensed CSensoryFrame:
104  *
105  * \param Action This is a pointer to CActionCollection, containing the
106  * pose change the robot has been commanded.
107  * \param observation This must be a pointer to a CSensoryFrame object,
108  * with robot sensed observations.
109  *
110  * \sa options
111  */
113  const mrpt::obs::CActionCollection* action,
114  const mrpt::obs::CSensoryFrame* observation,
116  override;
117 
118  /** Update the m_particles, predicting the posterior of robot pose and map
119  * after a movement command.
120  * This method has additional configuration parameters in "options".
121  * Performs the update stage of the RBPF, using the sensed CSensoryFrame:
122  *
123  * \param Action This is a pointer to CActionCollection, containing the
124  * pose change the robot has been commanded.
125  * \param observation This must be a pointer to a CSensoryFrame object,
126  * with robot sensed observations.
127  *
128  * \sa options
129  */
131  const mrpt::obs::CActionCollection* action,
132  const mrpt::obs::CSensoryFrame* observation,
134  override;
135 
136  // protected:
137  /** \name Virtual methods that the PF_implementations assume exist.
138  @{ */
139  /** Return the robot pose for the i'th particle. is_valid is
140  * always true in this class. */
142  const size_t i, bool& is_valid_pose) const override;
143 
145  mrpt::math::TPose2D* particleData,
146  const mrpt::math::TPose3D& newPose) const override;
147 
148  // We'll redefine this one:
150  CParticleList& old_particles,
151  const std::vector<mrpt::math::TPose3D>& newParticles,
152  const std::vector<double>& newParticlesWeight,
153  const std::vector<size_t>& newParticlesDerivedFromIdx) const override;
154 
155  /** Evaluate the observation likelihood for one particle at a given location
156  */
159  const size_t particleIndexForMap,
160  const mrpt::obs::CSensoryFrame& observation,
161  const mrpt::poses::CPose3D& x) const override;
162  /** @} */
163 
164 }; // End of class def.
165 
166 } // End of namespace
167 } // End of namespace
168 
169 #endif
void prediction_and_update_pfStandardProposal(const mrpt::obs::CActionCollection *action, const mrpt::obs::CSensoryFrame *observation, const bayes::CParticleFilter::TParticleFilterOptions &PF_options) override
Update the m_particles, predicting the posterior of robot pose and map after a movement command...
The struct for passing extra simulation parameters to the prediction stage when running a particle fi...
void resetUniformFreeSpace(mrpt::maps::COccupancyGridMap2D *theMap, const double freeCellsThreshold=0.7, const int particlesCount=-1, const double x_min=-1e10f, const double x_max=1e10f, const double y_min=-1e10f, const double y_max=1e10f, const double phi_min=-M_PI, const double phi_max=M_PI)
Reset the PDF to an uniformly distributed one, but only in the free-space of a given 2D occupancy-gri...
TMonteCarloLocalizationParams options
MCL parameters.
void PF_SLAM_implementation_replaceByNewParticleSet(CParticleList &old_particles, const std::vector< mrpt::math::TPose3D > &newParticles, const std::vector< double > &newParticlesWeight, const std::vector< size_t > &newParticlesDerivedFromIdx) const override
Declares a class for storing a collection of robot actions.
A set of common data shared by PF implementations for both SLAM and localization. ...
void PF_SLAM_implementation_custom_update_particle_with_new_pose(mrpt::math::TPose2D *particleData, const mrpt::math::TPose3D &newPose) const override
void prediction_and_update_pfAuxiliaryPFOptimal(const mrpt::obs::CActionCollection *action, const mrpt::obs::CSensoryFrame *observation, const bayes::CParticleFilter::TParticleFilterOptions &PF_options) override
Update the m_particles, predicting the posterior of robot pose and map after a movement command...
Declares a class for storing a "sensory frame", a set of "observations" taken by the robot approximat...
Definition: CSensoryFrame.h:52
std::deque< CParticleData > CParticleList
Use this type to refer to the list of particles m_particles.
Declares a class that represents a Probability Density Function (PDF) over a 2D pose (x...
Declares a class that represents a Probability Density Function (PDF) over a 2D pose (x...
A class for storing an occupancy grid map.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
double PF_SLAM_computeObservationLikelihoodForParticle(const mrpt::bayes::CParticleFilter::TParticleFilterOptions &PF_options, const size_t particleIndexForMap, const mrpt::obs::CSensoryFrame &observation, const mrpt::poses::CPose3D &x) const override
Evaluate the observation likelihood for one particle at a given location.
mrpt::math::TPose3D getLastPose(const size_t i, bool &is_valid_pose) const override
Return the robot pose for the i&#39;th particle.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:86
The configuration of a particle filter.
Lightweight 3D pose (three spatial coordinates, plus three angular coordinates).
Lightweight 2D pose.
GLenum GLint x
Definition: glext.h:3538
void prediction_and_update_pfAuxiliaryPFStandard(const mrpt::obs::CActionCollection *action, const mrpt::obs::CSensoryFrame *observation, const bayes::CParticleFilter::TParticleFilterOptions &PF_options) override
Update the m_particles, predicting the posterior of robot pose and map after a movement command...



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020