Main MRPT website > C++ reference for MRPT 1.3.2
maps/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-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 CMultiMetricMapPDF_H
10 #define CMultiMetricMapPDF_H
11 
13 #include <mrpt/maps/CSimpleMap.h>
16 
18 
21 #include <mrpt/slam/CICP.h>
22 
24 
25 #include <mrpt/slam/link_pragmas.h>
26 
27 namespace mrpt
28 {
29 namespace slam { class CMetricMapBuilderRBPF; }
30 namespace maps
31 {
33 
34  /** Auxiliary class used in mrpt::maps::CMultiMetricMapPDF
35  * \ingroup mrpt_slam_grp
36  */
38  {
39  // This must be added to any CSerializable derived class:
41  public:
42  CRBPFParticleData( const TSetOfMetricMapInitializers *mapsInitializers = NULL ) :
43  mapTillNow( mapsInitializers ),
44  robotPath()
45  {
46  }
47 
49  std::deque<mrpt::math::TPose3D> robotPath;
50  };
52 
53 
55 
56  /** Declares a class that represents a Rao-Blackwellized set of particles for solving the SLAM problem (This class is the base of RBPF-SLAM applications).
57  * This class is used internally by the map building algorithm in "mrpt::slam::CMetricMapBuilderRBPF"
58  *
59  * \sa mrpt::slam::CMetricMapBuilderRBPF
60  * \ingroup metric_slam_grp
61  */
62  class SLAM_IMPEXP CMultiMetricMapPDF :
63  public mrpt::utils::CSerializable,
64  public mrpt::bayes::CParticleFilterData<CRBPFParticleData>,
65  public mrpt::bayes::CParticleFilterDataImpl<CMultiMetricMapPDF,mrpt::bayes::CParticleFilterData<CRBPFParticleData>::CParticleList>,
66  public mrpt::slam::PF_implementation<CRBPFParticleData,CMultiMetricMapPDF>
67  {
69 
70  // This must be added to any CSerializable derived class:
71  DEFINE_SERIALIZABLE( CMultiMetricMapPDF )
72 
73  protected:
74  /** The PF algorithm implementation.
75  */
76  void prediction_and_update_pfStandardProposal(
77  const mrpt::obs::CActionCollection * action,
78  const mrpt::obs::CSensoryFrame * observation,
79  const bayes::CParticleFilter::TParticleFilterOptions &PF_options );
80 
81  /** The PF algorithm implementation.
82  */
83  void prediction_and_update_pfOptimalProposal(
84  const mrpt::obs::CActionCollection * action,
85  const mrpt::obs::CSensoryFrame * observation,
86  const bayes::CParticleFilter::TParticleFilterOptions &PF_options );
87 
88  /** The PF algorithm implementation.
89  */
90  void prediction_and_update_pfAuxiliaryPFOptimal(
91  const mrpt::obs::CActionCollection * action,
92  const mrpt::obs::CSensoryFrame * observation,
93  const bayes::CParticleFilter::TParticleFilterOptions &PF_options );
94 
95 
96  private:
97  /** Internal buffer for the averaged map. */
98  mrpt::maps::CMultiMetricMap averageMap;
99  bool averageMapIsUpdated;
100 
101  /** The SFs and their corresponding pose estimations:
102  */
103  mrpt::maps::CSimpleMap SFs;
104 
105  /** A mapping between indexes in the SFs to indexes in the robot paths from particles.
106  */
107  std::vector<uint32_t> SF2robotPath;
108 
109 
110  /** Entropy aux. function
111  */
112  float H(float p);
113 
114  public:
115 
116  /** The struct for passing extra simulation parameters to the prediction/update stage
117  * when running a particle filter.
118  * \sa prediction_and_update
119  */
120  struct SLAM_IMPEXP TPredictionParams : public utils::CLoadableOptions
121  {
122  /** Default settings method.
123  */
125 
126  /** See utils::CLoadableOptions
127  */
128  void loadFromConfigFile(
129  const mrpt::utils::CConfigFileBase &source,
130  const std::string &section);
131 
132  /** See utils::CLoadableOptions
133  */
134  void dumpToTextStream(mrpt::utils::CStream &out) const;
135 
136  /** [pf optimal proposal only] Only for PF algorithm=2 (Exact "pfOptimalProposal")
137  * Select the map on which to calculate the optimal
138  * proposal distribution. Values:
139  * 0: Gridmap -> Uses Scan matching-based approximation (based on Stachniss' work)
140  * 1: Landmarks -> Uses matching to approximate optimal
141  * 2: Beacons -> Used for exact optimal proposal in RO-SLAM
142  * 3: Pointsmap -> Uses Scan matching-based approximation with a map of points (based on Stachniss' work)
143  * Default = 0
144  */
146 
147 
148  /** [prediction stage][pf optimal proposal only] If useICPGlobalAlign_withGrid=true, this is the minimum quality ratio [0,1] of the alignment such as it will be accepted. Otherwise, raw odometry is used for those bad cases (default=0.7).
149  */
151 
152  /** [update stage] If the likelihood is computed through the occupancy grid map, then this structure is passed to the map when updating the particles weights in the update stage.
153  */
155 
157 
158  mrpt::slam::CICP::TConfigParams icp_params; //!< ICP parameters, used only when "PF_algorithm=2" in the particle filter.
159 
160  } options;
161 
162  /** Constructor
163  */
166  const mrpt::maps::TSetOfMetricMapInitializers *mapsInitializers = NULL,
167  const TPredictionParams *predictionOptions = NULL );
168 
169  /** Destructor
170  */
171  virtual ~CMultiMetricMapPDF();
172 
173  /** Clear all elements of the maps, and restore all paths to a single starting pose */
174  void clear( const mrpt::poses::CPose2D &initialPose );
175 
176  /** Clear all elements of the maps, and restore all paths to a single starting pose */
177  void clear( const mrpt::poses::CPose3D &initialPose );
178 
179  /** Returns the estimate of the robot pose as a particles PDF for the instant of time "timeStep", from 0 to N-1.
180  * \sa getEstimatedPosePDF
181  */
182  void getEstimatedPosePDFAtTime(
183  size_t timeStep,
184  mrpt::poses::CPose3DPDFParticles &out_estimation ) const;
185 
186  /** Returns the current estimate of the robot pose, as a particles PDF.
187  * \sa getEstimatedPosePDFAtTime
188  */
189  void getEstimatedPosePDF( mrpt::poses::CPose3DPDFParticles &out_estimation ) const;
190 
191  /** Returns the weighted averaged map based on the current best estimation. If you need a persistent copy of this object, please use "CSerializable::duplicate" and use the copy.
192  */
193  CMultiMetricMap * getCurrentMetricMapEstimation( );
194 
195  /** Returns a pointer to the current most likely map (associated to the most likely particle).
196  */
197  CMultiMetricMap * getCurrentMostLikelyMetricMap( );
198 
199  /** Get the number of CSensoryFrame inserted into the internal member SFs */
200  size_t getNumberOfObservationsInSimplemap() const { return SFs.size(); }
201 
202  /** Insert an observation to the map, at each particle's pose and to each particle's metric map.
203  * \param sf The SF to be inserted
204  */
205  void insertObservation(mrpt::obs::CSensoryFrame &sf);
206 
207  /** Return the path (in absolute coordinate poses) for the i'th particle.
208  * \exception On index out of bounds
209  */
210  void getPath(size_t i, std::deque<math::TPose3D> &out_path) const;
211 
212  /** Returns the current entropy of paths, computed as the average entropy of poses along the path, where entropy of each pose estimation is computed as the entropy of the gaussian approximation covariance.
213  */
214  double getCurrentEntropyOfPaths();
215 
216  /** Returns the joint entropy estimation over paths and maps, acording to "Information Gain-based Exploration Using" by C. Stachniss, G. Grissetti and W.Burgard.
217  */
218  double getCurrentJointEntropy();
219 
220  /** Update the poses estimation of the member "SFs" according to the current path belief.
221  */
222  void updateSensoryFrameSequence();
223 
224  /** A logging utility: saves the current path estimation for each particle in a text file (a row per particle, each 3-column-entry is a set [x,y,phi], respectively).
225  */
226  void saveCurrentPathEstimationToTextFile( const std::string &fil );
227 
228  /** An index [0,1] measuring how much information an observation aports to the map (Typ. threshold=0.07)
229  */
231 
232  private:
233  /** Rebuild the "expected" grid map. Used internally, do not call
234  */
235  void rebuildAverageMap();
236 
237 
238 
239  public:
240  /** \name Virtual methods that the PF_implementations assume exist.
241  @{ */
242 
243  /** Return a pointer to the last robot pose in the i'th particle (or NULL if it's a path and it's empty). */
244  const mrpt::math::TPose3D * getLastPose(const size_t i) const;
245 
246  void PF_SLAM_implementation_custom_update_particle_with_new_pose(
247  CParticleDataContent *particleData,
248  const mrpt::math::TPose3D &newPose) const;
249 
250  // The base implementation is fine for this class.
251  // void PF_SLAM_implementation_replaceByNewParticleSet( ...
252 
253  bool PF_SLAM_implementation_doWeHaveValidObservations(
254  const CParticleList &particles,
255  const mrpt::obs::CSensoryFrame *sf) const;
256 
257  bool PF_SLAM_implementation_skipRobotMovement() const;
258 
259  /** Evaluate the observation likelihood for one particle at a given location */
260  double PF_SLAM_computeObservationLikelihoodForParticle(
262  const size_t particleIndexForMap,
263  const mrpt::obs::CSensoryFrame &observation,
264  const mrpt::poses::CPose3D &x ) const;
265  /** @} */
266 
267 
268  }; // End of class def.
270 
271  } // End of namespace
272 } // End of namespace
273 
274 #endif
The ICP algorithm configuration data.
Definition: CICP.h:56
This class stores a sequence of <Probabilistic Pose,SensoryFrame> pairs, thus a "metric map" can be t...
The virtual base class which provides a unified interface for all persistent objects in MRPT...
Definition: CSerializable.h:39
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.
float ICPGlobalAlign_MinQuality
[prediction stage][pf optimal proposal only] If useICPGlobalAlign_withGrid=true, this is the minimum ...
mrpt::maps::CMultiMetricMapPDF CMultiMetricMapPDF
Backward compatible typedef.
Option set for KLD algorithm.
Definition: TKLDParams.h:22
STL namespace.
A set of TMetricMapInitializer structures, passed to the constructor CMultiMetricMap::CMultiMetricMap...
This class allows loading and storing values and vectors of different types from a configuration text...
CRBPFParticleData CParticleDataContent
This is the type inside the corresponding CParticleData class.
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:38
#define DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
This declaration must be inserted in all CSerializable classes definition, before the class declarati...
COccupancyGridMap2D::TLikelihoodOptions update_gridMapLikelihoodOptions
[update stage] If the likelihood is computed through the occupancy grid map, then this structure is p...
With this struct options are provided to the observation likelihood computation process.
class BASE_IMPEXP CSerializable
Definition: CStream.h:23
Declares a class for storing a "sensory frame", a set of "observations" taken by the robot approximat...
void clear()
Clear all elements of the maps.
Auxiliary class used in mrpt::maps::CMultiMetricMapPDF.
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 is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
std::deque< CParticleData > CParticleList
Use this type to refer to the list of particles m_particles.
size_t getNumberOfObservationsInSimplemap() const
Get the number of CSensoryFrame inserted into the internal member SFs.
A class used to store a 2D pose.
Definition: CPose2D.h:36
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:72
The configuration of a particle filter.
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).
int pfOptimalProposal_mapSelection
[pf optimal proposal only] Only for PF algorithm=2 (Exact "pfOptimalProposal") Select the map on whic...
This class stores any customizable set of metric maps.
#define DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
Declares a class that represents a Rao-Blackwellized set of particles for solving the SLAM problem (T...
Declares a class that represents a Probability Density function (PDF) of a 3D pose.



Page generated by Doxygen 1.8.12 for MRPT 1.3.2 SVN: at Thu Nov 10 13:46:27 UTC 2016