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



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