MRPT  2.0.3
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
mrpt::slam::CMetricMapBuilder::options
TOptions options
Definition: CMetricMapBuilder.h:141
mrpt::slam::CMetricMapBuilder::getCurrentlyBuiltMetricMap
virtual const mrpt::maps::CMultiMetricMap * getCurrentlyBuiltMetricMap() const =0
Returns the map built so far.
CMultiMetricMap.h
mrpt::slam::CMetricMapBuilder::loadCurrentMapFromFile
void loadCurrentMapFromFile(const std::string &fileName)
Load map (mrpt::maps::CSimpleMap) from a ".simplemap" file.
Definition: CMetricMapBuilder.cpp:56
mrpt::slam::CMetricMapBuilder::saveCurrentEstimationToImage
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.
mrpt::slam::CMetricMapBuilder::TOptions::debugForceInsertion
bool debugForceInsertion
Always insert into map.
Definition: CMetricMapBuilder.h:127
mrpt::slam::CMetricMapBuilder::leaveCriticalSection
void leaveCriticalSection()
Leave critical section for map updating.
Definition: CMetricMapBuilder.h:40
mrpt::obs::CActionCollection
Declares a class for storing a collection of robot actions.
Definition: CActionCollection.h:26
mrpt::slam::CMetricMapBuilder::TOptions::enableMapUpdating
bool enableMapUpdating
Enable map updating, default is true.
Definition: CMetricMapBuilder.h:125
mrpt::slam::CMetricMapBuilder::TOptions::TOptions
TOptions(mrpt::system::VerbosityLevel &verb_level_ref)
Definition: CMetricMapBuilder.h:115
mrpt::slam::CMetricMapBuilder::enableMapUpdating
void enableMapUpdating(bool enable)
Enables or disables the map updating (default state is enabled)
Definition: CMetricMapBuilder.h:104
CActionCollection.h
mrpt::slam::CMetricMapBuilder::enterCriticalSection
void enterCriticalSection()
Enter critical section for map updating.
Definition: CMetricMapBuilder.h:38
mrpt::obs::CSensoryFrame
Declares a class for storing a "sensory frame", a set of "observations" taken by the robot approximat...
Definition: CSensoryFrame.h:51
mrpt::slam::CMetricMapBuilder::~CMetricMapBuilder
~CMetricMapBuilder() override
Destructor.
Definition: CMetricMapBuilder.cpp:34
mrpt::system::VerbosityLevel
VerbosityLevel
Enumeration of available verbosity levels.
Definition: system/COutputLogger.h:28
COutputLogger.h
mrpt::slam::CMetricMapBuilder::clear
void clear()
Clear all elements of the maps, and reset localization to (0,0,0deg).
Definition: CMetricMapBuilder.cpp:43
mrpt::maps::CMultiMetricMap
This class stores any customizable set of metric maps.
Definition: CMultiMetricMap.h:120
mrpt::slam::CMetricMapBuilder::getCurrentPoseEstimation
virtual mrpt::poses::CPose3DPDF::Ptr getCurrentPoseEstimation() const =0
Returns a copy of the current best pose estimation as a pose PDF.
mrpt::slam::CMetricMapBuilder::initialize
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...
mrpt::slam::CMetricMapBuilder::getCurrentlyBuiltMap
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.
mrpt::slam::CMetricMapBuilder::CMetricMapBuilder
CMetricMapBuilder()
Constructor.
Definition: CMetricMapBuilder.cpp:27
mrpt::rtti::CListOfClasses
A list (actually based on a std::set) of MRPT classes, capable of keeping any class registered by the...
Definition: CListOfClasses.h:22
mrpt::system::COutputLogger
Versatile class for consistent logging and management of output messages.
Definition: system/COutputLogger.h:117
CSensoryFrame.h
mrpt::poses::CPosePDF
Declares a class that represents a probability density function (pdf) of a 2D pose (x,...
Definition: CPosePDF.h:38
mrpt::slam::CMetricMapBuilder::critZoneChangingMap
std::mutex critZoneChangingMap
Critical zones.
Definition: CMetricMapBuilder.h:36
mrpt::maps::CSimpleMap
This class stores a sequence of <Probabilistic Pose,SensoryFrame> pairs, thus a "metric map" can be t...
Definition: CSimpleMap.h:32
mrpt::poses::CPose3DPDF::Ptr
std::shared_ptr< CPose3DPDF > Ptr
Definition: CPose3DPDF.h:42
CListOfClasses.h
CPose3DPDF.h
CSerializable.h
CSimpleMap.h
mrpt::slam::CMetricMapBuilder::processActionObservation
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::slam::CMetricMapBuilder
This virtual class is the base for SLAM implementations.
Definition: CMetricMapBuilder.h:32
mrpt::slam
Definition: CMultiMetricMapPDF.h:26
mrpt::slam::CMetricMapBuilder::getCurrentlyBuiltMapSize
virtual unsigned int getCurrentlyBuiltMapSize()=0
Returns just how many sensory-frames are stored in the currently build map.
mrpt::slam::CMetricMapBuilder::saveCurrentMapToFile
void saveCurrentMapToFile(const std::string &fileName, bool compressGZ=true) const
Save map (mrpt::maps::CSimpleMap) to a ".simplemap" file.
Definition: CMetricMapBuilder.cpp:88
mrpt::slam::CMetricMapBuilder::TOptions
Options for the algorithm.
Definition: CMetricMapBuilder.h:113
mrpt::slam::CMetricMapBuilder::TOptions::alwaysInsertByClass
mrpt::rtti::CListOfClasses alwaysInsertByClass
A list of observation classes (derived from mrpt::obs::CObservation) which will be always inserted in...
Definition: CMetricMapBuilder.h:138
mrpt::slam::CMetricMapBuilder::TOptions::verbosity_level
mrpt::system::VerbosityLevel & verbosity_level
Definition: CMetricMapBuilder.h:123



Page generated by Doxygen 1.8.17 for MRPT 2.0.3 at Thu May 21 21:53:32 UTC 2020