MRPT  1.9.9
CBeacon.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 CBeacon_H
10 #define CBeacon_H
11 
13 #include <mrpt/math/CMatrix.h>
14 #include <mrpt/poses/CPoint3D.h>
18 #include <mrpt/obs/CObservation.h> // INVALID_BEACON_ID
19 
21 
22 namespace mrpt::maps
23 {
24 class CBeaconMap;
25 
26 /** The class for storing individual "beacon landmarks" under a variety of 3D
27  * position PDF distributions.
28  * This class is used for storage within the class CBeaconMap.
29  * The class implements the same methods than the interface "CPointPDF", and
30  * invoking them actually becomes
31  * a mapping into the methods of the current PDF representation of the
32  * beacon, selectable by means of "m_typePDF"
33  * \sa CBeaconMap, CPointPDFSOG
34  * \ingroup mrpt_maps_grp
35  */
37 {
39 
40  public:
41  /** The type for the IDs of landmarks.
42  */
43  using TBeaconID = int64_t;
44 
45  /** See m_typePDF
46  */
47  enum TTypePDF
48  {
52  };
53 
54  /** Which one of the different 3D point PDF is currently used in this
55  * object: montecarlo, gaussian, or a sum of gaussians.
56  * \sa m_location
57  */
59 
60  /** The individual PDF, if m_typePDF=pdfMonteCarlo (publicly accesible for
61  * ease of use, but the CPointPDF interface is also implemented in CBeacon).
62  */
64  /** The individual PDF, if m_typePDF=pdfGauss (publicly accesible for ease
65  * of use, but the CPointPDF interface is also implemented in CBeacon). */
67  /** The individual PDF, if m_typePDF=pdfSOG (publicly accesible for ease of
68  * use, but the CPointPDF interface is also implemented in CBeacon). */
70 
71  /** An ID for the landmark (see details next...)
72  * This ID was introduced in the version 3 of this class (21/NOV/2006),
73  *and its aim is
74  * to provide a way for easily establishing correspondences between
75  *landmarks detected
76  * in sequential image frames. Thus, the management of this field should
77  *be:
78  * - In 'servers' (classes/modules/... that detect landmarks from
79  *images):
80  *A different ID must be assigned to every landmark (e.g. a sequential
81  *counter), BUT only in the case of being sure of the correspondence of one
82  *landmark with another one in the past (e.g. tracking).
83  * - In 'clients': This field can be ignored, but if it is used, the
84  *advantage is solving the correspondence between landmarks detected in
85  *consequentive instants of time: Two landmarks with the same ID
86  *<b>correspond</b> to the same physical feature, BUT it should not be
87  *expected the inverse to be always true.
88  *
89  * Note that this field is never fill out automatically, it must be set by
90  *the programmer if used.
91  */
93 
94  /** Returns an estimate of the point, (the mean, or mathematical expectation
95  * of the PDF).
96  * \sa getCovariance
97  */
98  void getMean(mrpt::poses::CPoint3D& mean_point) const override;
99 
100  /** Returns an estimate of the point covariance matrix (3x3 cov matrix) and
101  * the mean, both at once.
102  * \sa getMean
103  */
106  mrpt::poses::CPoint3D& mean_point) const override;
107 
108  /** Copy operator, translating if necesary (for example, between particles
109  * and gaussian representations) */
110  void copyFrom(const mrpt::poses::CPointPDF& o) override;
111 
112  /** Save PDF's particles to a text file. See derived classes for more
113  * information about the format of generated files */
114  bool saveToTextFile(const std::string& file) const override;
115 
116  /** this = p (+) this. This can be used to convert a PDF from local
117  * coordinates to global, providing the point (newReferenceBase) from which
118  * "to project" the current pdf. Result PDF substituted the currently
119  * stored one in the object.
120  */
122  const mrpt::poses::CPose3D& newReferenceBase) override;
123 
124  /** Saves a 3D representation of the beacon into a given OpenGL scene */
126 
127  /** Gets a set of MATLAB commands which draw the current state of the
128  * beacon: */
129  void getAsMatlabDrawCommands(std::vector<std::string>& out_Str) const;
130 
131  /** Draw a sample from the pdf. */
132  void drawSingleSample(mrpt::poses::CPoint3D& outSample) const override;
133 
134  /** Bayesian fusion of two point distributions (product of two
135  * distributions->new distribution), then save the result in this object
136  * (WARNING: See implementing classes to see classes that can and cannot be
137  * mixtured!)
138  * \param p1 The first distribution to fuse
139  * \param p2 The second distribution to fuse
140  * \param minMahalanobisDistToDrop If set to different of 0, the result of
141  * very separate Gaussian modes (that will result in negligible components)
142  * in SOGs will be dropped to reduce the number of modes in the output.
143  */
144  void bayesianFusion(
145  const CPointPDF& p1, const CPointPDF& p2,
146  const double minMahalanobisDistToDrop = 0) override;
147 
148  /** Compute the observation model p(z_t|x_t) for a given observation (range
149  * value), and return it as an approximate SOG.
150  * Note that if the beacon is a SOG itself, the number of gaussian modes
151  * will be square.
152  * As a speed-up, if a "center point"+"maxDistanceFromCenter" is supplied
153  * (maxDistanceFromCenter!=0), those modes farther than this sphere will be
154  * discarded.
155  * Parameters such as the stdSigma of the sensor are gathered from
156  * "myBeaconMap"
157  * The result is one "ring" for each Gaussian mode that represent the
158  * beacon position in this object.
159  * The position of the sensor on the robot is used to shift the resulting
160  * densities such as they represent the position of the robot, not the
161  * sensor.
162  * \sa CBeaconMap::insertionOptions, generateRingSOG
163  */
165  const float& sensedRange, mrpt::poses::CPointPDFSOG& outPDF,
166  const CBeaconMap* myBeaconMap,
167  const mrpt::poses::CPoint3D& sensorPntOnRobot,
168  const mrpt::poses::CPoint3D& centerPoint =
169  mrpt::poses::CPoint3D(0, 0, 0),
170  const float& maxDistanceFromCenter = 0) const;
171 
172  /** This static method returns a SOG with ring-shape (or as a 3D sphere)
173  * that can be used to initialize a beacon if observed the first time.
174  * sensorPnt is the center of the ring/sphere, i.e. the absolute position
175  * of the range sensor.
176  * If clearPreviousContentsOutPDF=false, the SOG modes will be added to
177  * the current contents of outPDF
178  * If the 3x3 matrix covarianceCompositionToAdd is provided, it will be
179  * add to every Gaussian (to model the composition of uncertainty).
180  * \sa generateObservationModelDistribution
181  */
182  static void generateRingSOG(
183  const float& sensedRange, mrpt::poses::CPointPDFSOG& outPDF,
184  const CBeaconMap* myBeaconMap, const mrpt::poses::CPoint3D& sensorPnt,
185  const mrpt::math::CMatrixDouble33* covarianceCompositionToAdd = nullptr,
186  bool clearPreviousContentsOutPDF = true,
187  const mrpt::poses::CPoint3D& centerPoint =
188  mrpt::poses::CPoint3D(0, 0, 0),
189  const float& maxDistanceFromCenter = 0);
190 
191 }; // End of class definition
192 
193 }
194 #endif
195 
196 
mrpt::poses::CPointPDFParticles m_locationMC
The individual PDF, if m_typePDF=pdfMonteCarlo (publicly accesible for ease of use, but the CPointPDF interface is also implemented in CBeacon).
Definition: CBeacon.h:63
void copyFrom(const mrpt::poses::CPointPDF &o) override
Copy operator, translating if necesary (for example, between particles and gaussian representations) ...
Definition: CBeacon.cpp:156
void getAsMatlabDrawCommands(std::vector< std::string > &out_Str) const
Gets a set of MATLAB commands which draw the current state of the beacon:
Definition: CBeacon.cpp:293
void changeCoordinatesReference(const mrpt::poses::CPose3D &newReferenceBase) override
this = p (+) this.
Definition: CBeacon.cpp:202
Declares a class that represents a Probability Density function (PDF) of a 3D point ...
Definition: CPointPDFSOG.h:34
mrpt::poses::CPointPDFSOG m_locationSOG
The individual PDF, if m_typePDF=pdfSOG (publicly accesible for ease of use, but the CPointPDF interf...
Definition: CBeacon.h:69
int64_t TBeaconID
The type for the IDs of landmarks.
Definition: CBeacon.h:43
__int64 int64_t
Definition: rptypes.h:49
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:44
void getCovarianceAndMean(mrpt::math::CMatrixDouble33 &cov, mrpt::poses::CPoint3D &mean_point) const override
Returns an estimate of the point covariance matrix (3x3 cov matrix) and the mean, both at once...
Definition: CBeacon.cpp:85
TTypePDF m_typePDF
Which one of the different 3D point PDF is currently used in this object: montecarlo, gaussian, or a sum of gaussians.
Definition: CBeacon.h:58
GLsizei const GLchar ** string
Definition: glext.h:4101
A class used to store a 3D point.
Definition: CPoint3D.h:31
#define INVALID_BEACON_ID
Used for CObservationBeaconRange, CBeacon, etc.
Definition: CObservation.h:24
bool saveToTextFile(const std::string &file) const override
Save PDF&#39;s particles to a text file.
Definition: CBeacon.cpp:179
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
void bayesianFusion(const CPointPDF &p1, const CPointPDF &p2, const double minMahalanobisDistToDrop=0) override
Bayesian fusion of two point distributions (product of two distributions->new distribution), then save the result in this object (WARNING: See implementing classes to see classes that can and cannot be mixtured!)
Definition: CBeacon.cpp:108
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:86
OPENGL_SETOFOBJECTSPTR getAs3DObject() const
Returns a 3D representation of this PDF.
Definition: CPointPDF.h:95
TTypePDF
See m_typePDF.
Definition: CBeacon.h:47
void drawSingleSample(mrpt::poses::CPoint3D &outSample) const override
Draw a sample from the pdf.
Definition: CBeacon.cpp:133
Eigen::Matrix< typename MATRIX::Scalar, MATRIX::ColsAtCompileTime, MATRIX::ColsAtCompileTime > cov(const MATRIX &v)
Computes the covariance matrix from a list of samples in an NxM matrix, where each row is a sample...
Definition: ops_matrices.h:148
TBeaconID m_ID
An ID for the landmark (see details next...) This ID was introduced in the version 3 of this class (2...
Definition: CBeacon.h:92
static void generateRingSOG(const float &sensedRange, mrpt::poses::CPointPDFSOG &outPDF, const CBeaconMap *myBeaconMap, const mrpt::poses::CPoint3D &sensorPnt, const mrpt::math::CMatrixDouble33 *covarianceCompositionToAdd=nullptr, bool clearPreviousContentsOutPDF=true, const mrpt::poses::CPoint3D &centerPoint=mrpt::poses::CPoint3D(0, 0, 0), const float &maxDistanceFromCenter=0)
This static method returns a SOG with ring-shape (or as a 3D sphere) that can be used to initialize a...
Definition: CBeacon.cpp:464
Declares a class that represents a Probability Distribution function (PDF) of a 3D point (x...
Definition: CPointPDF.h:37
A probability distribution of a 2D/3D point, represented as a set of random samples (particles)...
The class for storing individual "beacon landmarks" under a variety of 3D position PDF distributions...
Definition: CBeacon.h:36
void generateObservationModelDistribution(const float &sensedRange, mrpt::poses::CPointPDFSOG &outPDF, const CBeaconMap *myBeaconMap, const mrpt::poses::CPoint3D &sensorPntOnRobot, const mrpt::poses::CPoint3D &centerPoint=mrpt::poses::CPoint3D(0, 0, 0), const float &maxDistanceFromCenter=0) const
Compute the observation model p(z_t|x_t) for a given observation (range value), and return it as an a...
Definition: CBeacon.cpp:402
A gaussian distribution for 3D points.
void getMean(mrpt::poses::CPoint3D &mean_point) const override
Returns an estimate of the point, (the mean, or mathematical expectation of the PDF).
Definition: CBeacon.cpp:62
mrpt::poses::CPointPDFGaussian m_locationGauss
The individual PDF, if m_typePDF=pdfGauss (publicly accesible for ease of use, but the CPointPDF inte...
Definition: CBeacon.h:66



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020