Main MRPT website > C++ reference for MRPT 1.9.9
CMetricMapBuilderICP.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-2017, 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 CMetricMapBuilderICP_H
10 #define CMetricMapBuilderICP_H
11 
13 #include <mrpt/slam/CICP.h>
15 
16 namespace mrpt
17 {
18 namespace slam
19 {
20 /** A class for very simple 2D SLAM based on ICP. This is a non-probabilistic
21  *pose tracking algorithm.
22  * Map are stored as in files as binary dumps of "mrpt::maps::CSimpleMap"
23  *objects. The methods are
24  * thread-safe.
25  * \ingroup metric_slam_grp
26  */
28 {
29  public:
30  /** Default constructor - Upon construction, you can set the parameters in
31  * ICP_options, then call "initialize".
32  */
34 
35  /** Destructor:
36  */
37  virtual ~CMetricMapBuilderICP();
38 
39  /** Algorithm configuration params
40  */
42  {
43  /** Initializer */
44  TConfigParams(mrpt::utils::VerbosityLevel& parent_verbosity_level);
45  TConfigParams& operator=(const TConfigParams& other); // Copy
46  // assignment
47 
48  void loadFromConfigFile(
50  const std::string& section) override; // See base docs
51  void dumpToTextStream(
52  mrpt::utils::CStream& out) const override; // See base docs
53  /** (default:false) Match against the occupancy grid or the points map?
54  * The former is quicker but less precise. */
56 
57  /** Minimum robot linear (m) displacement for a new observation to be
58  * inserted in the map. */
60  /** Minimum robot angular (rad, deg when loaded from the .ini)
61  * displacement for a new observation to be inserted in the map. */
63  /** Minimum robot linear (m) displacement for a new observation to be
64  * used to do ICP-based localization (otherwise, dead-reckon with
65  * odometry). */
67  /** Minimum robot angular (rad, deg when loaded from the .ini)
68  * displacement for a new observation to be used to do ICP-based
69  * localization (otherwise, dead-reckon with odometry). */
71 
72  /** Minimum ICP goodness (0,1) to accept the resulting corrected
73  * position (default: 0.40) */
75 
76  mrpt::utils::VerbosityLevel& verbosity_level;
77 
78  /** What maps to create (at least one points map and/or a grid map are
79  * needed).
80  * For the expected format in the .ini file when loaded with
81  * loadFromConfigFile(), see documentation of
82  * TSetOfMetricMapInitializers.
83  */
85  };
86 
87  /** Options for the ICP-SLAM application \sa ICP_params */
89  /** Options for the ICP algorithm itself \sa ICP_options */
91 
92  /** Initialize the method, starting with a known location PDF "x0"(if
93  * supplied, set to nullptr to left unmodified) and a given fixed, past map.
94  * This method MUST be called if using the default constructor, after
95  * loading the configuration into ICP_options. In particular,
96  * TConfigParams::mapInitializers
97  */
98  void initialize(
99  const mrpt::maps::CSimpleMap& initialMap = mrpt::maps::CSimpleMap(),
100  const mrpt::poses::CPosePDF* x0 = nullptr) override;
101 
102  /** Returns a copy of the current best pose estimation as a pose PDF.
103  */
105 
106  /** Sets the "current map file", thus that map will be loaded if it exists
107  * or a new one will be created if it does not, and the updated map will be
108  * save to that file when destroying the object.
109  */
110  void setCurrentMapFile(const char* mapFile);
111 
112  /** Appends a new action and observations to update this map: See the
113  *description of the class at the top of this page to see a more complete
114  *description.
115  * \param action The estimation of the incremental pose change in the robot
116  *pose.
117  * \param in_SF The set of observations that robot senses at the new pose.
118  * See params in CMetricMapBuilder::options and
119  *CMetricMapBuilderICP::ICP_options
120  * \sa processObservation
121  */
124  mrpt::obs::CSensoryFrame& in_SF) override;
125 
126  /** The main method of this class: Process one odometry or sensor
127  observation.
128  The new entry point of the algorithm (the old one was
129  processActionObservation, which now is a wrapper to
130  this method).
131  * See params in CMetricMapBuilder::options and
132  CMetricMapBuilderICP::ICP_options
133  */
135 
136  /** Fills "out_map" with the set of "poses"-"sensory-frames", thus the so
137  * far built map */
138  void getCurrentlyBuiltMap(mrpt::maps::CSimpleMap& out_map) const override;
139 
140  /** Returns the 2D points of current local map */
141  void getCurrentMapPoints(std::vector<float>& x, std::vector<float>& y);
142 
144  const override;
145 
146  /** Returns just how many sensory-frames are stored in the currently build
147  * map */
148  unsigned int getCurrentlyBuiltMapSize() override;
149 
150  /** A useful method for debugging: the current map (and/or poses) estimation
151  * is dumped to an image file.
152  * \param file The output file name
153  * \param formatEMF_BMP Output format = true:EMF, false:BMP
154  */
156  const std::string& file, bool formatEMF_BMP = true) override;
157 
158  private:
159  /** The set of observations that leads to current map: */
161 
162  /** The metric map representation as a points map: */
164 
165  /** Current map file. */
167 
168  /** The pose estimation by the alignment algorithm (ICP). */
169  /** Last pose estimation (Mean) */
171  /** Last pose estimation (covariance) */
173 
174  /** The estimated robot path:
175  */
176  std::deque<mrpt::math::TPose2D> m_estRobotPath;
178 
179  /** Traveled distances from last map update / ICP-based localization. */
180  struct TDist
181  {
182  TDist() : lin(0), ang(0) {}
183  double lin; // meters
184  double ang; // degrees
186 
188  void updatePose(const mrpt::poses::CPose2D& p);
189  };
191  /** Indexed by sensor label. */
195 
197  const mrpt::poses::CPose2D& new_pose);
199 };
200 
201 } // End of namespace
202 } // End of namespace
203 
204 #endif
double localizationAngDistance
Minimum robot angular (rad, deg when loaded from the .ini) displacement for a new observation to be u...
void updatePose(const mrpt::poses::CPose2D &p)
mrpt::maps::TSetOfMetricMapInitializers mapInitializers
What maps to create (at least one points map and/or a grid map are needed).
The ICP algorithm configuration data.
Definition: CICP.h:72
mrpt::maps::CMultiMetricMap metricMap
The metric map representation as a points map:
void dumpToTextStream(mrpt::utils::CStream &out) const override
This method should clearly display all the contents of the structure in textual form, sending it to a CStream.
CMetricMapBuilderICP()
Default constructor - Upon construction, you can set the parameters in ICP_options, then call "initialize".
double minICPgoodnessToAccept
Minimum ICP goodness (0,1) to accept the resulting corrected position (default: 0.40)
void getCurrentMapPoints(std::vector< float > &x, std::vector< float > &y)
Returns the 2D points of current local map.
This class stores a sequence of <Probabilistic Pose,SensoryFrame> pairs, thus a "metric map" can be t...
Definition: CSimpleMap.h:35
std::deque< mrpt::math::TPose2D > m_estRobotPath
The estimated robot path:
virtual ~CMetricMapBuilderICP()
Destructor:
A simple filter to estimate and extrapolate the robot 2D (x,y,phi) pose from asynchronous odometry an...
mrpt::maps::CSimpleMap SF_Poses_seq
The set of observations that leads to current map:
TConfigParams ICP_options
Options for the ICP-SLAM application.
A set of TMetricMapInitializer structures, passed to the constructor CMultiMetricMap::CMultiMetricMap...
double insertionAngDistance
Minimum robot angular (rad, deg when loaded from the .ini) displacement for a new observation to be i...
void initialize(const mrpt::maps::CSimpleMap &initialMap=mrpt::maps::CSimpleMap(), const mrpt::poses::CPosePDF *x0=nullptr) override
Initialize the method, starting with a known location PDF "x0"(if supplied, set to nullptr to left un...
Declares a class for storing a collection of robot actions.
bool matchAgainstTheGrid
(default:false) Match against the occupancy grid or the points map? The former is quicker but less pr...
void updateDistances(const mrpt::poses::CPose2D &p)
This class allows loading and storing values and vectors of different types from a configuration text...
CICP::TConfigParams ICP_params
Options for the ICP algorithm itself.
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:41
TConfigParams & operator=(const TConfigParams &other)
std::string currentMapFile
Current map file.
TConfigParams(mrpt::utils::VerbosityLevel &parent_verbosity_level)
Initializer.
const mrpt::maps::CMultiMetricMap * getCurrentlyBuiltMetricMap() const override
Returns the map built so far.
std::shared_ptr< CPose3DPDF > Ptr
Definition: CPose3DPDF.h:45
Declares a class for storing a "sensory frame", a set of "observations" taken by the robot approximat...
Definition: CSensoryFrame.h:54
void resetRobotDisplacementCounters(const mrpt::poses::CPose2D &new_pose)
std::shared_ptr< CObservation > Ptr
Definition: CObservation.h:43
This virtual class is the base for SLAM implementations.
GLsizei const GLchar ** string
Definition: glext.h:4101
Declares a class that represents a probability density function (pdf) of a 2D pose (x...
Definition: CPosePDF.h:41
void setCurrentMapFile(const char *mapFile)
Sets the "current map file", thus that map will be loaded if it exists or a new one will be created i...
mrpt::aligned_containers< std::string, TDist >::map_t m_distSinceLastInsertion
Indexed by sensor label.
mrpt::poses::CRobot2DPoseEstimator m_lastPoseEst
The pose estimation by the alignment algorithm (ICP).
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle...
Definition: CPose2D.h:40
GLsizei GLsizei GLchar * source
Definition: glext.h:4082
void processObservation(const mrpt::obs::CObservation::Ptr &obs)
The main method of this class: Process one odometry or sensor observation.
void getCurrentlyBuiltMap(mrpt::maps::CSimpleMap &out_map) const override
Fills "out_map" with the set of "poses"-"sensory-frames", thus the so far built map.
mrpt::math::CMatrixDouble33 m_lastPoseEst_cov
Last pose estimation (covariance)
double localizationLinDistance
Minimum robot linear (m) displacement for a new observation to be used to do ICP-based localization (...
GLenum GLint GLint y
Definition: glext.h:3538
std::map< TYPE1, TYPE2, std::less< TYPE1 >, Eigen::aligned_allocator< std::pair< const TYPE1, TYPE2 > > > map_t
mrpt::poses::CPose3DPDF::Ptr getCurrentPoseEstimation() const override
Returns a copy of the current best pose estimation as a pose PDF.
A class for very simple 2D SLAM based on ICP.
GLenum GLint x
Definition: glext.h:3538
This class stores any customizable set of metric maps.
void loadFromConfigFile(const mrpt::utils::CConfigFileBase &source, const std::string &section) override
This method load the options from a ".ini"-like file or memory-stored string list.
GLfloat GLfloat p
Definition: glext.h:6305
unsigned int getCurrentlyBuiltMapSize() override
Returns just how many sensory-frames are stored in the currently build map.
void processActionObservation(mrpt::obs::CActionCollection &action, mrpt::obs::CSensoryFrame &in_SF) override
Appends a new action and observations to update this map: See the description of the class at the top...
This is a virtual base class for sets of options than can be loaded from and/or saved to configuratio...
double insertionLinDistance
Minimum robot linear (m) displacement for a new observation to be inserted in the map...
void saveCurrentEstimationToImage(const std::string &file, bool formatEMF_BMP=true) override
A useful method for debugging: the current map (and/or poses) estimation is dumped to an image file...
void accumulateRobotDisplacementCounters(const mrpt::poses::CPose2D &new_pose)
Traveled distances from last map update / ICP-based localization.



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019