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-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 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::slam
24 {
25 /** @defgroup metric_slam_grp Metric SLAM algorithms
26  * \ingroup mrpt_slam_grp */
27 
28 /** This virtual class is the base for SLAM implementations. See derived classes
29  * for more information.
30  *
31  * \sa CMetricMap \ingroup metric_slam_grp
32  */
34 {
35  protected:
36  /** Critical zones */
37  std::mutex critZoneChangingMap;
38  /** Enter critical section for map updating */
39  inline void enterCriticalSection() { critZoneChangingMap.lock(); }
40  /** Leave critical section for map updating */
41  inline void leaveCriticalSection() { critZoneChangingMap.unlock(); }
42  public:
43  /** Constructor */
45  /** Destructor. */
46  virtual ~CMetricMapBuilder();
47 
48  // ---------------------------------------------------------------------
49  /** @name Pure virtual methods to implement in any particular SLAM algorithm
50  @{ */
51 
52  /** Initialize the method, starting with a known location PDF "x0"(if
53  * supplied, set to nullptr to left unmodified) and a given fixed, past map.
54  */
55  virtual void initialize(
56  const mrpt::maps::CSimpleMap& initialMap = mrpt::maps::CSimpleMap(),
57  const mrpt::poses::CPosePDF* x0 = nullptr) = 0;
58 
59  /** Returns a copy of the current best pose estimation as a pose PDF. */
61 
62  /** Process a new action and observations pair to update this map: See the
63  *description of the class at the top of this page to see a more complete
64  *description.
65  * \param action The estimation of the incremental pose change in the robot
66  *pose.
67  * \param observations The set of observations that robot senses at the new
68  *pose.
69  */
70  virtual void processActionObservation(
72  mrpt::obs::CSensoryFrame& observations) = 0;
73 
74  /** Fills "out_map" with the set of "poses"-"sensory-frames", thus the so
75  * far built map. */
76  virtual void getCurrentlyBuiltMap(
77  mrpt::maps::CSimpleMap& out_map) const = 0;
78 
79  /** Returns just how many sensory-frames are stored in the currently build
80  * map. */
81  virtual unsigned int getCurrentlyBuiltMapSize() = 0;
82 
83  /** Returns the map built so far. NOTE that for efficiency a pointer to the
84  * internal object is passed, DO NOT delete nor modify the object in any
85  * way, if desired, make a copy of ir with "clone()". */
87  const = 0;
88 
89  /** A useful method for debugging: the current map (and/or poses) estimation
90  * is dumped to an image file.
91  * \param file The output file name
92  * \param formatEMF_BMP Output format = true:EMF, false:BMP
93  */
94  virtual void saveCurrentEstimationToImage(
95  const std::string& file, bool formatEMF_BMP = true) = 0;
96 
97  /** @} */
98  // ---------------------------------------------------------------------
99 
100  /** Clear all elements of the maps, and reset localization to (0,0,0deg). */
101  void clear();
102 
103  /** Enables or disables the map updating (default state is enabled) */
104  void enableMapUpdating(bool enable) { options.enableMapUpdating = enable; }
105  /** Load map (mrpt::maps::CSimpleMap) from a ".simplemap" file */
106  void loadCurrentMapFromFile(const std::string& fileName);
107 
108  /** Save map (mrpt::maps::CSimpleMap) to a ".simplemap" file. */
110  const std::string& fileName, bool compressGZ = true) const;
111 
112  /** Options for the algorithm */
113  struct TOptions
114  {
116  : verbosity_level(verb_level_ref),
117  enableMapUpdating(true),
118  debugForceInsertion(false),
120  {
121  }
122 
124  /** Enable map updating, default is true. */
126  /** Always insert into map. Default is false: detect if necesary. */
128 
129  /** A list of observation classes (derived from mrpt::obs::CObservation)
130  * which will be always inserted in the map, disregarding the minimum
131  * insertion distances).
132  * Default: Empty. How to insert classes:
133  * \code
134  * alwaysInserByClass.insert(CLASS_ID(CObservationImage));
135  * \endcode
136  * \sa mrpt::rtti::CListOfClasses
137  */
139  };
140 
142 
143  public:
145 }; // End of class def.
146 
147 }
148 #endif
149 
150 
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)
VerbosityLevel
Enumeration of available verbosity levels.
mrpt::system::VerbosityLevel & verbosity_level
This class stores a sequence of <Probabilistic Pose,SensoryFrame> pairs, thus a "metric map" can be t...
Definition: CSimpleMap.h:33
mrpt::rtti::CListOfClasses alwaysInsertByClass
A list of observation classes (derived from mrpt::obs::CObservation) which will be always inserted in...
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.
#define MRPT_MAKE_ALIGNED_OPERATOR_NEW
Put this macro inside any class with members that require {16,32,64}-byte memory alignment (e...
Declares a class for storing a collection of robot actions.
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.
TOptions(mrpt::system::VerbosityLevel &verb_level_ref)
Versatile class for consistent logging and management of output messages.
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...
Declares a class for storing a "sensory frame", a set of "observations" taken by the robot approximat...
Definition: CSensoryFrame.h:52
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:39
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.
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.
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...
A list (actually based on a std::set) of MRPT classes, capable of keeping any class registered by the...



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