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-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
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  */
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  {
118  : verbosity_level(verb_level_ref),
119  enableMapUpdating(true),
120  debugForceInsertion(false),
122  {
123  }
124 
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::rtti::CListOfClasses
139  */
141  };
142 
144 
145  public:
147 }; // End of class def.
148 
149 } // End of namespace
150 } // End of namespace
151 
152 #endif
mrpt::slam::CMetricMapBuilder::options
TOptions options
Definition: CMetricMapBuilder.h:143
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:129
mrpt::slam::CMetricMapBuilder::leaveCriticalSection
void leaveCriticalSection()
Leave critical section for map updating.
Definition: CMetricMapBuilder.h:43
mrpt::obs::CActionCollection
Declares a class for storing a collection of robot actions.
Definition: CActionCollection.h:28
mrpt::slam::CMetricMapBuilder::TOptions::enableMapUpdating
bool enableMapUpdating
Enable map updating, default is true.
Definition: CMetricMapBuilder.h:127
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
mrpt::slam::CMetricMapBuilder::TOptions::TOptions
TOptions(mrpt::system::VerbosityLevel &verb_level_ref)
Definition: CMetricMapBuilder.h:117
mrpt::slam::CMetricMapBuilder::enableMapUpdating
void enableMapUpdating(bool enable)
Enables or disables the map updating (default state is enabled)
Definition: CMetricMapBuilder.h:106
CActionCollection.h
mrpt::slam::CMetricMapBuilder::~CMetricMapBuilder
virtual ~CMetricMapBuilder()
Destructor.
Definition: CMetricMapBuilder.cpp:34
mrpt::slam::CMetricMapBuilder::enterCriticalSection
void enterCriticalSection()
Enter critical section for map updating.
Definition: CMetricMapBuilder.h:41
mrpt::obs::CSensoryFrame
Declares a class for storing a "sensory frame", a set of "observations" taken by the robot approximat...
Definition: CSensoryFrame.h:54
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:141
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:24
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:41
mrpt::slam::CMetricMapBuilder::critZoneChangingMap
std::mutex critZoneChangingMap
Critical zones.
Definition: CMetricMapBuilder.h:39
mrpt::maps::CSimpleMap
This class stores a sequence of <Probabilistic Pose,SensoryFrame> pairs, thus a "metric map" can be t...
Definition: CSimpleMap.h:35
MRPT_MAKE_ALIGNED_OPERATOR_NEW
#define MRPT_MAKE_ALIGNED_OPERATOR_NEW
Put this macro inside any class with members that require {16,32,64}-byte memory alignment (e....
Definition: aligned_allocator.h:90
mrpt::poses::CPose3DPDF::Ptr
std::shared_ptr< CPose3DPDF > Ptr
Definition: CPose3DPDF.h:45
CListOfClasses.h
CPose3DPDF.h
string
GLsizei const GLchar ** string
Definition: glext.h:4101
CSimpleMap.h
CSerializable.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:35
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:115
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:140
mrpt::slam::CMetricMapBuilder::TOptions::verbosity_level
mrpt::system::VerbosityLevel & verbosity_level
Definition: CMetricMapBuilder.h:125



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST