Main MRPT website > C++ reference for MRPT 1.5.6
CMetricMapBuilder.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 CMetricMapBuilder_H
10 #define CMetricMapBuilder_H
11 
17 #include <mrpt/obs/CSensoryFrame.h>
18 #include <mrpt/maps/CSimpleMap.h>
19 #include <mrpt/poses/CPose3DPDF.h>
21 
22 #include <mrpt/slam/link_pragmas.h>
23 
24 namespace mrpt
25 {
26 namespace slam
27 {
28  /** @defgroup metric_slam_grp Metric SLAM algorithms
29  * \ingroup mrpt_slam_grp */
30 
31  /** This virtual class is the base for SLAM implementations. See derived classes for more information.
32  *
33  * \sa CMetricMap \ingroup metric_slam_grp
34  */
35  class SLAM_IMPEXP CMetricMapBuilder : public mrpt::utils::COutputLogger
36  {
37  protected:
39  /** Enter critical section for map updating */
40  inline void enterCriticalSection() { critZoneChangingMap.enter(); }
41  /** Leave critical section for map updating */
42  inline void leaveCriticalSection() { critZoneChangingMap.leave(); }
43  public:
44  CMetricMapBuilder(); //!< Constructor
45  virtual ~CMetricMapBuilder( ); //!< Destructor.
46 
47  // ---------------------------------------------------------------------
48  /** @name Pure virtual methods to implement in any particular SLAM algorithm
49  @{ */
50 
51  /** Initialize the method, starting with a known location PDF "x0"(if supplied, set to NULL to left unmodified) and a given fixed, past map. */
52  virtual void initialize(
53  const mrpt::maps::CSimpleMap &initialMap = mrpt::maps::CSimpleMap(),
54  mrpt::poses::CPosePDF *x0 = NULL
55  ) = 0;
56 
57  /** Returns a copy of the current best pose estimation as a pose PDF. */
58  virtual mrpt::poses::CPose3DPDFPtr getCurrentPoseEstimation() const = 0;
59 
60  /** Process a new action and observations pair to update this map: See the description of the class at the top of this page to see a more complete description.
61  * \param action The estimation of the incremental pose change in the robot pose.
62  * \param observations The set of observations that robot senses at the new pose.
63  */
64  virtual void processActionObservation( mrpt::obs::CActionCollection &action,mrpt::obs::CSensoryFrame &observations ) = 0;
65 
66  /** Fills "out_map" with the set of "poses"-"sensory-frames", thus the so far built map. */
67  virtual void getCurrentlyBuiltMap(mrpt::maps::CSimpleMap &out_map) const = 0;
68 
69  /** Returns just how many sensory-frames are stored in the currently build map. */
70  virtual unsigned int getCurrentlyBuiltMapSize() = 0;
71 
72  /** Returns the map built so far. NOTE that for efficiency a pointer to the internal object is passed, DO NOT delete nor modify the object in any way, if desired, make a copy of ir with "duplicate()". */
73  virtual const mrpt::maps::CMultiMetricMap* getCurrentlyBuiltMetricMap() const = 0;
74 
75  /** A useful method for debugging: the current map (and/or poses) estimation is dumped to an image file.
76  * \param file The output file name
77  * \param formatEMF_BMP Output format = true:EMF, false:BMP
78  */
79  virtual void saveCurrentEstimationToImage(const std::string &file, bool formatEMF_BMP = true) = 0;
80 
81  /** @} */
82  // ---------------------------------------------------------------------
83 
84  /** Clear all elements of the maps, and reset localization to (0,0,0deg). */
85  void clear();
86 
87  /** Enables or disables the map updating (default state is enabled) */
88  void enableMapUpdating( bool enable )
89  {
90  options.enableMapUpdating = enable;
91  }
92 
93  /** Load map (mrpt::maps::CSimpleMap) from a ".simplemap" file */
94  void loadCurrentMapFromFile(const std::string &fileName);
95 
96  /** Save map (mrpt::maps::CSimpleMap) to a ".simplemap" file. */
97  void saveCurrentMapToFile(const std::string &fileName, bool compressGZ=true) const;
98 
99  /** Options for the algorithm */
101  {
102  TOptions(mrpt::utils::VerbosityLevel &verb_level_ref ) :
103  verbosity_level (verb_level_ref),
104  enableMapUpdating(true),
105  debugForceInsertion(false),
106  alwaysInsertByClass()
107  {
108  }
109 
110  mrpt::utils::VerbosityLevel & verbosity_level;
111  bool enableMapUpdating; //!< Enable map updating, default is true.
112  bool debugForceInsertion; //!< Always insert into map. Default is false: detect if necesary.
113 
114  /** A list of observation classes (derived from mrpt::obs::CObservation) which will be always inserted in the map, disregarding the minimum insertion distances).
115  * Default: Empty. How to insert classes:
116  * \code
117  * alwaysInserByClass.insert(CLASS_ID(CObservationImage));
118  * \endcode
119  * \sa mrpt::utils::CListOfClasses
120  */
122  };
123 
125 
126  public:
128  }; // End of class def.
129 
130  } // End of namespace
131 } // End of namespace
132 
133 #endif
This class provides simple critical sections functionality.
void enableMapUpdating(bool enable)
Enables or disables the map updating (default state is enabled)
This class stores a sequence of <Probabilistic Pose,SensoryFrame> pairs, thus a "metric map" can be t...
#define MRPT_MAKE_ALIGNED_OPERATOR_NEW
Definition: memory.h:112
void leaveCriticalSection()
Leave critical section for map updating.
bool enableMapUpdating
Enable map updating, default is true.
void clear()
Clear the contents of this container.
Definition: ts_hash_map.h:113
Declares a class for storing a collection of robot actions.
mrpt::utils::VerbosityLevel & verbosity_level
void enterCriticalSection()
Enter critical section for map updating.
mrpt::synch::CCriticalSection critZoneChangingMap
Critical zones.
mrpt::utils::CListOfClasses alwaysInsertByClass
A list of observation classes (derived from mrpt::obs::CObservation) which will be always inserted in...
Declares a class for storing a "sensory frame", a set of "observations" taken by the robot approximat...
This virtual class is the base for SLAM implementations.
Declares a class that represents a probability density function (pdf) of a 2D pose (x...
Definition: CPosePDF.h:39
GLsizei const GLcharARB ** string
Definition: glew.h:3293
A list (actually based on a std::set) of MRPT classes, capable of keeping any class registered by the...
bool debugForceInsertion
Always insert into map. Default is false: detect if necesary.
This class stores any customizable set of metric maps.
TOptions(mrpt::utils::VerbosityLevel &verb_level_ref)



Page generated by Doxygen 1.8.6 for MRPT 1.5.6 Git: 4c65e84 Tue Apr 24 08:18:17 2018 +0200 at mar abr 24 08:26:17 CEST 2018