MRPT  2.0.4
CMetricMapBuilder.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #pragma once
10 
12 #include <mrpt/maps/CSimpleMap.h>
14 #include <mrpt/obs/CSensoryFrame.h>
15 #include <mrpt/poses/CPose3DPDF.h>
19 
20 #include <mutex>
21 
22 namespace mrpt::slam
23 {
24 /** @defgroup metric_slam_grp Metric SLAM algorithms
25  * \ingroup mrpt_slam_grp */
26 
27 /** This virtual class is the base for SLAM implementations. See derived classes
28  * for more information.
29  *
30  * \sa CMetricMap \ingroup metric_slam_grp
31  */
33 {
34  protected:
35  /** Critical zones */
36  std::mutex critZoneChangingMap;
37  /** Enter critical section for map updating */
38  inline void enterCriticalSection() { critZoneChangingMap.lock(); }
39  /** Leave critical section for map updating */
40  inline void leaveCriticalSection() { critZoneChangingMap.unlock(); }
41 
42  public:
43  /** Constructor */
45  /** Destructor. */
46  ~CMetricMapBuilder() override;
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:
144 }; // End of class def.
145 
146 } // namespace mrpt::slam
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:32
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.
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:51
void loadCurrentMapFromFile(const std::string &fileName)
Load map (mrpt::maps::CSimpleMap) from a ".simplemap" file.
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:38
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.
~CMetricMapBuilder() override
Destructor.
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.
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 2.0.4 Git: 33de1d0ad Sat Jun 20 11:02:42 2020 +0200 at sáb jun 20 17:35:17 CEST 2020