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



Page generated by Doxygen 1.8.17 for MRPT 1.4.0 SVN: at Sat Jan 18 22:37:07 UTC 2020