Main MRPT website > C++ reference for MRPT 1.9.9
CBeaconMap.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 CBeaconMap_H
10 #define CBeaconMap_H
11 
12 #include <mrpt/maps/CMetricMap.h>
13 #include <mrpt/maps/CBeacon.h>
15 #include <mrpt/math/CMatrix.h>
17 #include <mrpt/obs/obs_frwds.h>
18 
19 namespace mrpt
20 {
21 namespace maps
22 {
23 /** A class for storing a map of 3D probabilistic beacons, using a Montecarlo,
24  *Gaussian, or Sum of Gaussians (SOG) representation (for range-only SLAM).
25  * <br>
26  * The individual beacons are defined as mrpt::maps::CBeacon objects.
27  * <br>
28  * When invoking CBeaconMap::insertObservation(), landmarks will be extracted
29  *and fused into the map.
30  * The only currently supported observation type is
31  *mrpt::obs::CObservationBeaconRanges.
32  * See insertionOptions and likelihoodOptions for parameters used when
33  *creating and fusing beacon landmarks.
34  * <br>
35  * Use "TInsertionOptions::insertAsMonteCarlo" to select between 2 different
36  *behaviors:
37  * - Initial PDF of beacons: MonteCarlo, after convergence, pass to
38  *Gaussians; or
39  * - Initial PDF of beacons: SOG, after convergence, a single Gaussian.
40  *
41  * Refer to the papers: []
42  *
43  * \ingroup mrpt_maps_grp
44  * \sa CMetricMap
45  */
47 {
49 
50  public:
51  typedef std::deque<CBeacon> TSequenceBeacons;
54 
55  protected:
56  /** The individual beacons */
58 
59  // See docs in base class
60  virtual void internal_clear() override;
61  virtual bool internal_insertObservation(
62  const mrpt::obs::CObservation* obs,
63  const mrpt::poses::CPose3D* robotPose = nullptr) override;
65  const mrpt::obs::CObservation* obs,
66  const mrpt::poses::CPose3D& takenFrom) override;
67 
68  public:
69  /** Constructor */
70  CBeaconMap();
71 
72  /** Resize the number of SOG modes */
73  void resize(const size_t N);
74 
75  /** Access to individual beacons */
76  const CBeacon& operator[](size_t i) const
77  {
78  ASSERT_(i < m_beacons.size())
79  return m_beacons[i];
80  }
81  /** Access to individual beacons */
82  const CBeacon& get(size_t i) const
83  {
84  ASSERT_(i < m_beacons.size())
85  return m_beacons[i];
86  }
87  /** Access to individual beacons */
88  CBeacon& operator[](size_t i)
89  {
90  ASSERT_(i < m_beacons.size())
91  return m_beacons[i];
92  }
93  /** Access to individual beacons */
94  CBeacon& get(size_t i)
95  {
96  ASSERT_(i < m_beacons.size())
97  return m_beacons[i];
98  }
99 
100  iterator begin() { return m_beacons.begin(); }
101  const_iterator begin() const { return m_beacons.begin(); }
102  iterator end() { return m_beacons.end(); }
103  const_iterator end() const { return m_beacons.end(); }
104  /** Inserts a copy of the given mode into the SOG */
105  void push_back(const CBeacon& m) { m_beacons.push_back(m); }
106  // See docs in base class
108  const mrpt::maps::CMetricMap* otherMap,
109  const mrpt::poses::CPose3D& otherMapPose,
110  const TMatchingRatioParams& params) const override;
111 
112  /** With this struct options are provided to the likelihood computations */
114  {
115  public:
116  /** Initilization of default parameters
117  */
119 
120  void loadFromConfigFile(
122  const std::string& section) override; // See base docs
123  void dumpToTextStream(
124  mrpt::utils::CStream& out) const override; // See base docs
125 
126  /** The standard deviation used for Beacon ranges likelihood
127  * (default=0.08m).
128  */
129  float rangeStd;
131 
132  /** This struct contains data for choosing the method by which new beacons
133  * are inserted in the map.
134  */
136  {
137  public:
138  /** Initilization of default parameters */
140  void loadFromConfigFile(
142  const std::string& section) override; // See base docs
143  void dumpToTextStream(
144  mrpt::utils::CStream& out) const override; // See base docs
145 
146  /** Insert a new beacon as a set of montecarlo samples (default=true),
147  * or, if false, as a sum of gaussians (see mrpt::maps::CBeacon).
148  * \sa MC_performResampling
149  */
151 
152  /** Minimum and maximum elevation angles (in degrees) for inserting new
153  * beacons at the first observation: the default values (both 0), makes
154  * the beacons to be in the same horizontal plane that the sensors, that
155  * is, 2D SLAM - the min/max values are -90/90.
156  */
158 
159  /** Number of particles per meter of range, i.e. per meter of the
160  * "radius of the ring".
161  */
162  unsigned int MC_numSamplesPerMeter;
163 
164  /** The threshold for the maximum std (X,Y,and Z) before colapsing the
165  * particles into a Gaussian PDF (default=0,4).
166  */
168 
169  /** Threshold for the maximum difference from the maximun (log) weight
170  * in the set of samples for erasing a given sample (default=5).
171  */
173 
174  /** If set to false (default), the samples will be generated the first
175  * time a beacon is observed, and their weights just updated
176  * subsequently - if set to "true", fewer samples will be required since
177  * the particles will be resamples when necessary, and a small "noise"
178  * will be added to avoid depletion.
179  */
181 
182  /** The std.dev. of the Gaussian noise to be added to each sample after
183  * resampling, only if MC_performResampling=true.
184  */
186 
187  /** Threshold for the maximum difference from the maximun (log) weight
188  * in the SOG for erasing a given mode (default=20).
189  */
191 
192  /** A parameter for initializing 2D/3D SOGs
193  */
195 
196  /** Constant used to compute the std. dev. int the tangent direction
197  * when creating the Gaussians.
198  */
200 
202 
203  /** Save to a MATLAB script which displays 3D error ellipses for the map.
204  * \param file The name of the file to save the script to.
205  * \param style The MATLAB-like string for the style of the lines (see
206  *'help plot' in MATLAB for posibilities)
207  * \param stdCount The ellipsoids will be drawn from the center to a given
208  *confidence interval in [0,1], e.g. 2 sigmas=0.95 (default is 2std = 0.95
209  *confidence intervals)
210  *
211  * \return Returns false if any error occured, true elsewere.
212  */
214  const std::string& file, const char* style = "b",
215  float confInterval = 0.95f) const;
216 
217  /** Returns the stored landmarks count.
218  */
219  size_t size() const;
220 
221  // See docs in base class
222  virtual void determineMatching2D(
223  const mrpt::maps::CMetricMap* otherMap,
224  const mrpt::poses::CPose2D& otherMapPose,
225  mrpt::utils::TMatchingPairList& correspondences,
226  const TMatchingParams& params,
227  TMatchingExtraResults& extraResults) const override;
228 
229  /** Perform a search for correspondences between "this" and another
230  * lansmarks map:
231  * Firsly, the landmarks' descriptor is used to find correspondences, then
232  * inconsistent ones removed by
233  * looking at their 3D poses.
234  * \param otherMap [IN] The other map.
235  * \param correspondences [OUT] The matched pairs between maps.
236  * \param correspondencesRatio [OUT] This is NumberOfMatchings /
237  * NumberOfLandmarksInTheAnotherMap
238  * \param otherCorrespondences [OUT] Will be returned with a vector
239  * containing "true" for the indexes of the other map's landmarks with a
240  * correspondence.
241  */
243  const mrpt::maps::CBeaconMap* otherMap,
244  mrpt::utils::TMatchingPairList& correspondences,
245  float& correspondencesRatio,
246  std::vector<bool>& otherCorrespondences) const;
247 
248  /** Changes the reference system of the map to a given 3D pose.
249  */
251 
252  /** Changes the reference system of the map "otherMap" and save the result
253  * in "this" map.
254  */
256  const mrpt::poses::CPose3D& newOrg,
257  const mrpt::maps::CBeaconMap* otherMap);
258 
259  /** Returns true if the map is empty/no observation has been inserted.
260  */
261  bool isEmpty() const override;
262 
263  /** Simulates a reading toward each of the beacons in the landmarks map, if
264  * any.
265  * \param in_robotPose This robot pose is used to simulate the ranges to
266  * each beacon.
267  * \param in_sensorLocationOnRobot The 3D position of the sensor on the
268  * robot
269  * \param out_Observations The results will be stored here. NOTICE that the
270  * fields
271  * "CObservationBeaconRanges::minSensorDistance","CObservationBeaconRanges::maxSensorDistance"
272  * and "CObservationBeaconRanges::stdError" MUST BE FILLED OUT before
273  * calling this function.
274  * An observation will be generated for each beacon in the map, but notice
275  * that some of them may be missed if out of the sensor maximum range.
276  */
278  const mrpt::poses::CPose3D& in_robotPose,
279  const mrpt::poses::CPoint3D& in_sensorLocationOnRobot,
280  mrpt::obs::CObservationBeaconRanges& out_Observations) const;
281 
282  /** This virtual method saves the map to a file "filNamePrefix"+<
283  *some_file_extension >, as an image or in any other applicable way (Notice
284  *that other methods to save the map may be implemented in classes
285  *implementing this virtual interface).
286  * In the case of this class, these files are generated:
287  * - "filNamePrefix"+"_3D.m": A script for MATLAB for drawing landmarks
288  *as
289  *3D ellipses.
290  * - "filNamePrefix"+"_3D.3DScene": A 3D scene with a "ground plane
291  *grid"
292  *and the set of ellipsoids in 3D.
293  * - "filNamePrefix"+"_covs.m": A textual representation (see
294  *saveToTextFile)
295  */
297  const std::string& filNamePrefix) const override;
298 
299  /** Save a text file with a row per beacon, containing this 11 elements:
300  * - X Y Z: Mean values
301  * - VX VY VZ: Variances of each dimension (C11, C22, C33)
302  * - DET2D DET3D: Determinant of the 2D and 3D covariance matrixes.
303  * - C12, C13, C23: Cross covariances
304  */
305  void saveToTextFile(const std::string& fil) const;
306 
307  /** Returns a 3D object representing the map. */
308  void getAs3DObject(mrpt::opengl::CSetOfObjects::Ptr& outObj) const override;
309 
310  /** Returns a pointer to the beacon with the given ID, or nullptr if it does
311  * not exist. */
312  const CBeacon* getBeaconByID(CBeacon::TBeaconID id) const;
313  /** Returns a pointer to the beacon with the given ID, or nullptr if it does
314  * not exist. */
316 
318  /** Observations insertion options */
319  mrpt::maps::CBeaconMap::TInsertionOptions insertionOpts;
320  /** Probabilistic observation likelihood options */
321  mrpt::maps::CBeaconMap::TLikelihoodOptions likelihoodOpts;
323 
324 }; // End of class def.
325 
326 } // End of namespace
327 } // End of namespace
328 
329 #endif
float MC_thresholdNegligible
Threshold for the maximum difference from the maximun (log) weight in the set of samples for erasing ...
Definition: CBeaconMap.h:172
bool isEmpty() const override
Returns true if the map is empty/no observation has been inserted.
Parameters for CMetricMap::compute3DMatchingRatio()
const_iterator end() const
Definition: CBeaconMap.h:103
int64_t TBeaconID
The type for the IDs of landmarks.
Definition: CBeacon.h:49
#define MAP_DEFINITION_END(_CLASS_NAME_, _LINKAGE_)
float compute3DMatchingRatio(const mrpt::maps::CMetricMap *otherMap, const mrpt::poses::CPose3D &otherMapPose, const TMatchingRatioParams &params) const override
Computes the ratio in [0,1] of correspondences between "this" and the "otherMap" map, whose 6D pose relative to "this" is "otherMapPose" In the case of a multi-metric map, this returns the average between the maps.
void getAs3DObject(mrpt::opengl::CSetOfObjects::Ptr &outObj) const override
Returns a 3D object representing the map.
This struct contains data for choosing the method by which new beacons are inserted in the map...
Definition: CBeaconMap.h:135
#define MAP_DEFINITION_START(_CLASS_NAME_)
Add a MAP_DEFINITION_START() ...
void computeMatchingWith3DLandmarks(const mrpt::maps::CBeaconMap *otherMap, mrpt::utils::TMatchingPairList &correspondences, float &correspondencesRatio, std::vector< bool > &otherCorrespondences) const
Perform a search for correspondences between "this" and another lansmarks map: Firsly, the landmarks&#39; descriptor is used to find correspondences, then inconsistent ones removed by looking at their 3D poses.
Definition: CBeaconMap.cpp:879
With this struct options are provided to the likelihood computations.
Definition: CBeaconMap.h:113
Scalar * iterator
Definition: eigen_plugins.h:26
Declares a class derived from "CObservation" that represents one (or more) range measurements to labe...
std::deque< CBeacon >::iterator iterator
Definition: CBeaconMap.h:52
const Scalar * const_iterator
Definition: eigen_plugins.h:27
TInsertionOptions()
Initilization of default parameters.
virtual void internal_clear() override
Internal method called by clear()
Definition: CBeaconMap.cpp:93
bool MC_performResampling
If set to false (default), the samples will be generated the first time a beacon is observed...
Definition: CBeaconMap.h:180
This class allows loading and storing values and vectors of different types from a configuration text...
TSequenceBeacons m_beacons
The individual beacons.
Definition: CBeaconMap.h:57
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:41
void changeCoordinatesReference(const mrpt::poses::CPose3D &newOrg)
Changes the reference system of the map to a given 3D pose.
Definition: CBeaconMap.cpp:857
Additional results from the determination of matchings between point clouds, etc., apart from the pairings themselves.
float SOG_maxDistBetweenGaussians
A parameter for initializing 2D/3D SOGs.
Definition: CBeaconMap.h:194
A list of TMatchingPair.
Definition: TMatchingPair.h:93
float rangeStd
The standard deviation used for Beacon ranges likelihood (default=0.08m).
Definition: CBeaconMap.h:129
CBeaconMap()
Constructor.
Definition: CBeaconMap.cpp:86
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.
std::shared_ptr< CSetOfObjects > Ptr
Definition: CSetOfObjects.h:32
A class for storing a map of 3D probabilistic beacons, using a Montecarlo, Gaussian, or Sum of Gaussians (SOG) representation (for range-only SLAM).
Definition: CBeaconMap.h:46
float SOG_separationConstant
Constant used to compute the std.
Definition: CBeaconMap.h:199
float maxElevation_deg
Minimum and maximum elevation angles (in degrees) for inserting new beacons at the first observation:...
Definition: CBeaconMap.h:157
void saveToTextFile(const std::string &fil) const
Save a text file with a row per beacon, containing this 11 elements:
void push_back(const CBeacon &m)
Inserts a copy of the given mode into the SOG.
Definition: CBeaconMap.h:105
GLsizei const GLchar ** string
Definition: glext.h:4101
A class used to store a 3D point.
Definition: CPoint3D.h:32
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.
std::deque< CBeacon > TSequenceBeacons
Definition: CBeaconMap.h:51
CBeacon & operator[](size_t i)
Access to individual beacons.
Definition: CBeaconMap.h:88
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
const CBeacon & operator[](size_t i) const
Access to individual beacons.
Definition: CBeaconMap.h:76
Declares a virtual base class for all metric maps storage classes.
Definition: CMetricMap.h:55
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle...
Definition: CPose2D.h:40
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:88
Declares a class that represents any robot&#39;s observation.
Definition: CObservation.h:41
bool insertAsMonteCarlo
Insert a new beacon as a set of montecarlo samples (default=true), or, if false, as a sum of gaussian...
Definition: CBeaconMap.h:150
const CBeacon * getBeaconByID(CBeacon::TBeaconID id) const
Returns a pointer to the beacon with the given ID, or nullptr if it does not exist.
virtual void determineMatching2D(const mrpt::maps::CMetricMap *otherMap, const mrpt::poses::CPose2D &otherMapPose, mrpt::utils::TMatchingPairList &correspondences, const TMatchingParams &params, TMatchingExtraResults &extraResults) const override
Computes the matching between this and another 2D point map, which includes finding: ...
Definition: CBeaconMap.cpp:826
GLsizei GLsizei GLchar * source
Definition: glext.h:4082
#define ASSERT_(f)
virtual bool internal_insertObservation(const mrpt::obs::CObservation *obs, const mrpt::poses::CPose3D *robotPose=nullptr) override
Internal method called by insertObservation()
Definition: CBeaconMap.cpp:366
void resize(const size_t N)
Resize the number of SOG modes.
Definition: CBeaconMap.cpp:101
mrpt::maps::CBeaconMap::TLikelihoodOptions likelihoodOptions
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.
double internal_computeObservationLikelihood(const mrpt::obs::CObservation *obs, const mrpt::poses::CPose3D &takenFrom) override
Internal method called by computeObservationLikelihood()
Definition: CBeaconMap.cpp:157
const_iterator begin() const
Definition: CBeaconMap.h:101
std::deque< CBeacon >::const_iterator const_iterator
Definition: CBeaconMap.h:53
bool saveToMATLABScript3D(const std::string &file, const char *style="b", float confInterval=0.95f) const
Save to a MATLAB script which displays 3D error ellipses for the map.
Definition: CBeaconMap.cpp:956
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.
unsigned int MC_numSamplesPerMeter
Number of particles per meter of range, i.e.
Definition: CBeaconMap.h:162
void saveMetricMapRepresentationToFile(const std::string &filNamePrefix) const override
This virtual method saves the map to a file "filNamePrefix"+< some_file_extension >...
mrpt::maps::CBeaconMap::TInsertionOptions insertionOptions
float MC_maxStdToGauss
The threshold for the maximum std (X,Y,and Z) before colapsing the particles into a Gaussian PDF (def...
Definition: CBeaconMap.h:167
Parameters for the determination of matchings between point clouds, etc.
void simulateBeaconReadings(const mrpt::poses::CPose3D &in_robotPose, const mrpt::poses::CPoint3D &in_sensorLocationOnRobot, mrpt::obs::CObservationBeaconRanges &out_Observations) const
Simulates a reading toward each of the beacons in the landmarks map, if any.
GLenum const GLfloat * params
Definition: glext.h:3534
The class for storing individual "beacon landmarks" under a variety of 3D position PDF distributions...
Definition: CBeacon.h:42
float SOG_thresholdNegligible
Threshold for the maximum difference from the maximun (log) weight in the SOG for erasing a given mod...
Definition: CBeaconMap.h:190
This is a virtual base class for sets of options than can be loaded from and/or saved to configuratio...
size_t size() const
Returns the stored landmarks count.
Definition: CBeaconMap.cpp:97
TLikelihoodOptions()
Initilization of default parameters.
Definition: CBeaconMap.cpp:999



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