Main MRPT website > C++ reference for MRPT 1.3.2
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-2015, 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
This class provides simple critical sections functionality.
void enableMapUpdating(bool enable)
Enables or disables the map updating (default state is enabled)
This class stores a sequence of pairs, thus a "metric map" can be t...
#define MRPT_MAKE_ALIGNED_OPERATOR_NEW
Definition: memory.h:112
void leaveCriticalSection()
Leave critical section for map updating:
bool enableMapUpdating
Enable map updating, default is true.
Declares a class for storing a collection of robot actions.
void enterCriticalSection()
Enter critical section for map updating:
synch::CCriticalSection critZoneChangingMap
Critical zones.
void leave() const
Leave the calling thread is not the current owener of the critical section.
void enter() const
Enter.
mrpt::utils::CListOfClasses alwaysInsertByClass
A list of observation classes (derived from mrpt::obs::CObservation) which will be always inserted in...
Declares a class for storing a "sensory frame", a set of "observations" taken by the robot approximat...
This virtual class is the base for SLAM implementations.
bool verbose
If true shows debug information in the console, default is true.
Declares a class that represents a probability density function (pdf) of a 2D pose (x...
Definition: CPosePDF.h:39
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
A list (actually based on a std::set) of MRPT classes, capable of keeping any class registered by the...
bool debugForceInsertion
Always insert into map. Default is false: detect if necesary.
This class stores any customizable set of metric maps.
This base class provides a common printf-like method to send debug information to std::cout...



Page generated by Doxygen 1.8.9.1 for MRPT 1.3.2 SVN:Unversioned directory at Thu Dec 10 00:07:55 UTC 2015