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



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