Main MRPT website > C++ reference for MRPT 1.9.9
CMultiMetricMapPDF.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-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 #ifndef CMultiMetricMapPDF_H
10 #define CMultiMetricMapPDF_H
11 
13 #include <mrpt/maps/CSimpleMap.h>
16 
18 
20 #include <mrpt/slam/CICP.h>
21 
23 
25 
26 namespace mrpt
27 {
28 namespace slam
29 {
31 }
32 namespace maps
33 {
34 /** Auxiliary class used in mrpt::maps::CMultiMetricMapPDF
35  * \ingroup mrpt_slam_grp
36  */
38 {
40  public:
42  const TSetOfMetricMapInitializers* mapsInitializers = nullptr)
43  : mapTillNow(mapsInitializers), robotPath()
44  {
45  }
46 
48  std::deque<mrpt::math::TPose3D> robotPath;
49 };
50 
52  : public mrpt::bayes::CParticleFilterData<CRBPFParticleData>,
54  mrpt::bayes::CParticleFilterData<CRBPFParticleData>,
55  mrpt::bayes::CParticleFilterData<CRBPFParticleData>::CParticleList>
56 {
57 };
58 
59 /** Declares a class that represents a Rao-Blackwellized set of particles for
60  * solving the SLAM problem (This class is the base of RBPF-SLAM applications).
61  * This class is used internally by the map building algorithm in
62  * "mrpt::slam::CMetricMapBuilderRBPF"
63  *
64  * \sa mrpt::slam::CMetricMapBuilderRBPF
65  * \ingroup metric_slam_grp
66  */
69  CRBPFParticleData, CMultiMetricMapPDFParticles>
70 {
71  public:
76 
77  private:
79 
81 
82  public:
83  // PF algorithm implementations:
84  template <class PF_ALGORITHM>
86  const mrpt::obs::CActionCollection* actions,
87  const mrpt::obs::CSensoryFrame* observation,
89  {
91 
92  PF_ALGORITHM::template PF_SLAM_implementation<
95  actions, observation, PF_options, options.KLD_params, *this);
96 
97  MRPT_END
98  }
99 
100  private:
101  /** Internal buffer for the averaged map. */
104 
105  /** The SFs and their corresponding pose estimations */
107  /** A mapping between indexes in the SFs to indexes in the robot paths from
108  * particles. */
109  std::vector<uint32_t> SF2robotPath;
110 
111  public:
112  /** The struct for passing extra simulation parameters to the
113  * prediction/update stage
114  * when running a particle filter.
115  * \sa prediction_and_update
116  */
118  {
119  /** Default settings method */
121 
122  void loadFromConfigFile(
124  const std::string& section) override; // See base docs
125  void dumpToTextStream(
126  mrpt::utils::CStream& out) const override; // See base docs
127 
128  /** [pf optimal proposal only] Only for PF algorithm=2 (Exact
129  * "pfOptimalProposal")
130  * Select the map on which to calculate the optimal
131  * proposal distribution. Values:
132  * 0: Gridmap -> Uses Scan matching-based approximation (based on
133  * Stachniss' work)
134  * 1: Landmarks -> Uses matching to approximate optimal
135  * 2: Beacons -> Used for exact optimal proposal in RO-SLAM
136  * 3: Pointsmap -> Uses Scan matching-based approximation with a map
137  * of points (based on Stachniss' work)
138  * Default = 0
139  */
141 
142  /** [prediction stage][pf optimal proposal only] If
143  * useICPGlobalAlign_withGrid=true, this is the minimum quality ratio
144  * [0,1] of the alignment such as it will be accepted. Otherwise, raw
145  * odometry is used for those bad cases (default=0.7).
146  */
148 
149  /** [update stage] If the likelihood is computed through the occupancy
150  * grid map, then this structure is passed to the map when updating the
151  * particles weights in the update stage.
152  */
154 
156 
157  /** ICP parameters, used only when "PF_algorithm=2" in the particle
158  * filter. */
160 
161  } options;
162 
163  /** Constructor
164  */
168  const mrpt::maps::TSetOfMetricMapInitializers* mapsInitializers =
169  nullptr,
170  const TPredictionParams* predictionOptions = nullptr);
171 
172  /** Clear all elements of the maps, and restore all paths to a single
173  * starting pose */
174  void clear(const mrpt::poses::CPose2D& initialPose);
175  /** \overload */
176  void clear(const mrpt::poses::CPose3D& initialPose);
177  /** Resets the map by loading an already-mapped map for past poses.
178  * Current robot pose should be normally set to the last keyframe
179  * in the simplemap. */
180  void clear(
181  const mrpt::maps::CSimpleMap& prevMap,
182  const mrpt::poses::CPose3D& currentPose);
183 
184  /** Returns the estimate of the robot pose as a particles PDF for the
185  * instant of time "timeStep", from 0 to N-1.
186  * \sa getEstimatedPosePDF
187  */
189  size_t timeStep,
190  mrpt::poses::CPose3DPDFParticles& out_estimation) const;
191 
192  /** Returns the current estimate of the robot pose, as a particles PDF.
193  * \sa getEstimatedPosePDFAtTime
194  */
195  void getEstimatedPosePDF(
196  mrpt::poses::CPose3DPDFParticles& out_estimation) const;
197 
198  /** Returns the weighted averaged map based on the current best estimation.
199  * If you need a persistent copy of this object, please use
200  * "CSerializable::duplicate" and use the copy.
201  * \sa Almost 100% sure you would prefer the best current map, given by
202  * getCurrentMostLikelyMetricMap()
203  */
205 
206  /** Returns a pointer to the current most likely map (associated to the most
207  * likely particle) */
209 
210  /** Get the number of CSensoryFrame inserted into the internal member SFs */
211  size_t getNumberOfObservationsInSimplemap() const { return SFs.size(); }
212  /** Insert an observation to the map, at each particle's pose and to each
213  * particle's metric map.
214  * \param sf The SF to be inserted
215  * \return true if any may was updated, false otherwise
216  */
218 
219  /** Return the path (in absolute coordinate poses) for the i'th particle.
220  * \exception On index out of bounds
221  */
222  void getPath(size_t i, std::deque<math::TPose3D>& out_path) const;
223 
224  /** Returns the current entropy of paths, computed as the average entropy of
225  * poses along the path, where entropy of each pose estimation is computed
226  * as the entropy of the gaussian approximation covariance.
227  */
228  double getCurrentEntropyOfPaths();
229 
230  /** Returns the joint entropy estimation over paths and maps, acording to
231  * "Information Gain-based Exploration Using" by C. Stachniss, G. Grissetti
232  * and W.Burgard.
233  */
234  double getCurrentJointEntropy();
235 
236  /** Update the poses estimation of the member "SFs" according to the current
237  * path belief.
238  */
240 
241  /** A logging utility: saves the current path estimation for each particle
242  * in a text file (a row per particle, each 3-column-entry is a set
243  * [x,y,phi], respectively).
244  */
246 
247  private:
248  /** Rebuild the "expected" grid map. Used internally, do not call */
249  void rebuildAverageMap();
250 
251  /** An index [0,1] measuring how much information an observation aports to
252  * the map (Typ. threshold=0.07) */
254 
255  public:
256  /** \name Virtual methods that the PF_implementations assume exist.
257  @{ */
258 
259  // see docs in base
261  const size_t i, bool& pose_is_valid) const override;
262 
264  CParticleDataContent* particleData,
265  const mrpt::math::TPose3D& newPose) const override;
266 
267  // The base implementation is fine for this class.
268  // void PF_SLAM_implementation_replaceByNewParticleSet( ...
269 
271  const CParticleList& particles,
272  const mrpt::obs::CSensoryFrame* sf) const override;
273 
274  bool PF_SLAM_implementation_skipRobotMovement() const override;
275 
276  /** Evaluate the observation likelihood for one particle at a given location
277  */
280  const size_t particleIndexForMap,
281  const mrpt::obs::CSensoryFrame& observation,
282  const mrpt::poses::CPose3D& x) const override;
283  /** @} */
284 
285  void executeOn(
287  const mrpt::obs::CActionCollection* action,
288  const mrpt::obs::CSensoryFrame* observation,
291 
292 }; // End of class def.
293 
294 } // namespace maps
295 } // namespace mrpt
296 
297 #endif
bool PF_SLAM_implementation_skipRobotMovement() const override
Do not move the particles until the map is populated.
void clear(const mrpt::poses::CPose2D &initialPose)
Clear all elements of the maps, and restore all paths to a single starting pose.
mrpt::maps::CMultiMetricMap averageMap
Internal buffer for the averaged map.
The ICP algorithm configuration data.
Definition: CICP.h:72
ParticleData::CParticleList CParticleList
const CMultiMetricMap * getCurrentMostLikelyMetricMap() const
Returns a pointer to the current most likely map (associated to the most likely particle) ...
This class stores a sequence of <Probabilistic Pose,SensoryFrame> pairs, thus a "metric map" can be t...
Definition: CSimpleMap.h:35
The virtual base class which provides a unified interface for all persistent objects in MRPT...
Definition: CSerializable.h:44
mrpt::slam::CICP::TConfigParams icp_params
ICP parameters, used only when "PF_algorithm=2" in the particle filter.
float newInfoIndex
An index [0,1] measuring how much information an observation aports to the map (Typ.
CMultiMetricMapPDF(const bayes::CParticleFilter::TParticleFilterOptions &opts=bayes::CParticleFilter::TParticleFilterOptions(), const mrpt::maps::TSetOfMetricMapInitializers *mapsInitializers=nullptr, const TPredictionParams *predictionOptions=nullptr)
Constructor.
float ICPGlobalAlign_MinQuality
[prediction stage][pf optimal proposal only] If useICPGlobalAlign_withGrid=true, this is the minimum ...
bool PF_SLAM_implementation_doWeHaveValidObservations(const CParticleList &particles, const mrpt::obs::CSensoryFrame *sf) const override
Option set for KLD algorithm.
Definition: TKLDParams.h:20
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.
Statistics for being returned from the "execute" method.
A set of TMetricMapInitializer structures, passed to the constructor CMultiMetricMap::CMultiMetricMap...
Declares a class for storing a collection of robot actions.
void getEstimatedPosePDF(mrpt::poses::CPose3DPDFParticles &out_estimation) const
Returns the current estimate of the robot pose, as a particles PDF.
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.
This class allows loading and storing values and vectors of different types from a configuration text...
void PF_SLAM_implementation_custom_update_particle_with_new_pose(CParticleDataContent *particleData, const mrpt::math::TPose3D &newPose) const override
A set of common data shared by PF implementations for both SLAM and localization. ...
CRBPFParticleData CParticleDataContent
This is the type inside the corresponding CParticleData class.
void saveCurrentPathEstimationToTextFile(const std::string &fil)
A logging utility: saves the current path estimation for each particle in a text file (a row per part...
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:41
COccupancyGridMap2D::TLikelihoodOptions update_gridMapLikelihoodOptions
[update stage] If the likelihood is computed through the occupancy grid map, then this structure is p...
#define MRPT_END
With this struct options are provided to the observation likelihood computation process.
Declares a class for storing a "sensory frame", a set of "observations" taken by the robot approximat...
Definition: CSensoryFrame.h:54
size_t size() const
Returns the count of pairs (pose,sensory data)
Definition: CSimpleMap.cpp:65
This class acts as a common interface to the different interfaces (see CParticleFilter::TParticleFilt...
GLsizei const GLchar ** string
Definition: glext.h:4101
This template class declares the array of particles and its internal data, managing some memory-relat...
double getCurrentEntropyOfPaths()
Returns the current entropy of paths, computed as the average entropy of poses along the path...
Auxiliary class used in mrpt::maps::CMultiMetricMapPDF.
void getEstimatedPosePDFAtTime(size_t timeStep, mrpt::poses::CPose3DPDFParticles &out_estimation) const
Returns the estimate of the robot pose as a particles PDF for the instant of time "timeStep"...
Auxiliary structure used in KLD-sampling in particle filters.
#define MRPT_START
void updateSensoryFrameSequence()
Update the poses estimation of the member "SFs" according to the current path belief.
CRBPFParticleData(const TSetOfMetricMapInitializers *mapsInitializers=nullptr)
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
void executeOn(mrpt::bayes::CParticleFilter &pf, const mrpt::obs::CActionCollection *action, const mrpt::obs::CSensoryFrame *observation, mrpt::bayes::CParticleFilter::TParticleFilterStats *stats, mrpt::bayes::CParticleFilter::TParticleFilterAlgorithm PF_algorithm)
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
mrpt::maps::CSimpleMap SFs
The SFs and their corresponding pose estimations.
std::deque< CParticleData > CParticleList
Use this type to refer to the list of particles m_particles.
TParticleFilterAlgorithm
Defines different types of particle filter algorithms.
size_t getNumberOfObservationsInSimplemap() const
Get the number of CSensoryFrame inserted into the internal member SFs.
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle...
Definition: CPose2D.h:40
This class implements a Rao-Blackwelized Particle Filter (RBPF) approach to map building (SLAM)...
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:88
The configuration of a particle filter.
double getCurrentJointEntropy()
Returns the joint entropy estimation over paths and maps, acording to "Information Gain-based Explora...
std::deque< mrpt::math::TPose3D > robotPath
The struct for passing extra simulation parameters to the prediction/update stage when running a part...
Lightweight 3D pose (three spatial coordinates, plus three angular coordinates).
void rebuildAverageMap()
Rebuild the "expected" grid map.
GLsizei GLsizei GLchar * source
Definition: glext.h:4082
ParticleData::CParticleDataContent CParticleDataContent
std::vector< uint32_t > SF2robotPath
A mapping between indexes in the SFs to indexes in the robot paths from particles.
void dumpToTextStream(mrpt::utils::CStream &out) const override
This method should clearly display all the contents of the structure in textual form, sending it to a CStream.
int pfOptimalProposal_mapSelection
[pf optimal proposal only] Only for PF algorithm=2 (Exact "pfOptimalProposal") Select the map on whic...
bool insertObservation(mrpt::obs::CSensoryFrame &sf)
Insert an observation to the map, at each particle&#39;s pose and to each particle&#39;s metric map...
const CMultiMetricMap * getAveragedMetricMapEstimation()
Returns the weighted averaged map based on the current best estimation.
GLenum GLint x
Definition: glext.h:3538
This class stores any customizable set of metric maps.
Declares a class that represents a Rao-Blackwellized set of particles for solving the SLAM problem (T...
mrpt::maps::CMultiMetricMapPDF::TPredictionParams options
void prediction_and_update(const mrpt::obs::CActionCollection *actions, const mrpt::obs::CSensoryFrame *observation, const bayes::CParticleFilter::TParticleFilterOptions &PF_options)
This is a virtual base class for sets of options than can be loaded from and/or saved to configuratio...
Declares a class that represents a Probability Density function (PDF) of a 3D pose.
mrpt::math::TPose3D getLastPose(const size_t i, bool &pose_is_valid) const override
Return the last robot pose in the i&#39;th particle; is_valid_pose will be false if there is no such last...
A curiously recurring template pattern (CRTP) approach to providing the basic functionality of any CP...
void getPath(size_t i, std::deque< math::TPose3D > &out_path) const
Return the path (in absolute coordinate poses) for the i&#39;th particle.



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