Main MRPT website > C++ reference
MRPT logo
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-2014, 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 #include <mrpt/maps/link_pragmas.h>
22 
23 
24 namespace mrpt
25 {
26  namespace utils { class CStringList; }
27 
28 namespace slam
29 {
30  using namespace mrpt::poses;
31  using namespace mrpt::utils;
32 
33  class CBeaconMap;
35 
36  /** The class for storing individual "beacon landmarks" under a variety of 3D position PDF distributions.
37  * This class is used for storage within the class CBeaconMap.
38  * The class implements the same methods than the interface "CPointPDF", and invoking them actually becomes
39  * a mapping into the methods of the current PDF representation of the beacon, selectable by means of "m_typePDF"
40  * \sa CBeaconMap, CPointPDFSOG
41  * \ingroup mrpt_maps_grp
42  */
43  class MAPS_IMPEXP CBeacon : public CPointPDF
44  {
45  // This must be added to any CSerializable derived class:
47 
48  public:
49  /** The type for the IDs of landmarks.
50  */
51  typedef int64_t TBeaconID;
52 
53  /** See m_typePDF
54  */
55  enum TTypePDF { pdfMonteCarlo = 0, pdfGauss, pdfSOG };
56 
57  /** Which one of the different 3D point PDF is currently used in this object: montecarlo, gaussian, or a sum of gaussians.
58  * \sa m_location
59  */
61 
62  /** The individual PDF, if m_typePDF=pdfMonteCarlo (publicly accesible for ease of use, but the CPointPDF interface is also implemented in CBeacon).
63  */
65 
66  /** The individual PDF, if m_typePDF=pdfGauss (publicly accesible for ease of use, but the CPointPDF interface is also implemented in CBeacon).
67  */
69 
70  /** The individual PDF, if m_typePDF=pdfSOG (publicly accesible for ease of use, but the CPointPDF interface is also implemented in CBeacon).
71  */
73 
74  /** An ID for the landmark (see details next...)
75  * This ID was introduced in the version 3 of this class (21/NOV/2006), and its aim is
76  * to provide a way for easily establishing correspondences between landmarks detected
77  * in sequential image frames. Thus, the management of this field should be:
78  * - In 'servers' (classes/modules/... that detect landmarks from images): A different ID must be assigned to every landmark (e.g. a sequential counter), BUT only in the case of being sure of the correspondence of one landmark with another one in the past (e.g. tracking).
79  * - In 'clients': This field can be ignored, but if it is used, the advantage is solving the correspondence between landmarks detected in consequentive instants of time: Two landmarks with the same ID <b>correspond</b> to the same physical feature, BUT it should not be expected the inverse to be always true.
80  *
81  * Note that this field is never fill out automatically, it must be set by the programmer if used.
82  */
84 
85  /** Default constructor
86  */
87  CBeacon();
88 
89  /** Virtual destructor
90  */
91  virtual ~CBeacon();
92 
93  /** Returns an estimate of the point, (the mean, or mathematical expectation of the PDF).
94  * \sa getCovariance
95  */
96  void getMean(CPoint3D &mean_point) const;
97 
98  /** Returns an estimate of the point covariance matrix (3x3 cov matrix) and the mean, both at once.
99  * \sa getMean
100  */
101  void getCovarianceAndMean(mrpt::math::CMatrixDouble33 &cov,CPoint3D &mean_point) const;
102 
103  /** Copy operator, translating if necesary (for example, between particles and gaussian representations)
104  */
105  void copyFrom(const CPointPDF &o);
106 
107  /** Save PDF's particles to a text file. See derived classes for more information about the format of generated files.
108  */
109  void saveToTextFile(const std::string &file) const;
110 
111  /** this = p (+) this. This can be used to convert a PDF from local coordinates to global, providing the point (newReferenceBase) from which
112  * "to project" the current pdf. Result PDF substituted the currently stored one in the object.
113  */
114  void changeCoordinatesReference( const CPose3D &newReferenceBase );
115 
116  /** Saves a 3D representation of the beacon into a given OpenGL scene
117  */
118  void getAs3DObject( mrpt::opengl::CSetOfObjectsPtr &outObj ) const;
119 
120  /** Gets a set of MATLAB commands which draw the current state of the beacon:
121  */
122  void getAsMatlabDrawCommands( utils::CStringList &out_Str ) const;
123 
124  /** Draw a sample from the pdf.
125  */
126  void drawSingleSample(CPoint3D &outSample) const;
127 
128  /** 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!)
129  * \param p1 The first distribution to fuse
130  * \param p2 The second distribution to fuse
131  * \param minMahalanobisDistToDrop If set to different of 0, the result of very separate Gaussian modes (that will result in negligible components) in SOGs will be dropped to reduce the number of modes in the output.
132  */
133  void bayesianFusion(const CPointPDF &p1,const CPointPDF &p2, const double &minMahalanobisDistToDrop = 0);
134 
135 
136  /** Compute the observation model p(z_t|x_t) for a given observation (range value), and return it as an approximate SOG.
137  * Note that if the beacon is a SOG itself, the number of gaussian modes will be square.
138  * As a speed-up, if a "center point"+"maxDistanceFromCenter" is supplied (maxDistanceFromCenter!=0), those modes farther than this sphere will be discarded.
139  * Parameters such as the stdSigma of the sensor are gathered from "myBeaconMap"
140  * The result is one "ring" for each Gaussian mode that represent the beacon position in this object.
141  * The position of the sensor on the robot is used to shift the resulting densities such as they represent the position of the robot, not the sensor.
142  * \sa CBeaconMap::insertionOptions, generateRingSOG
143  */
144  void generateObservationModelDistribution(
145  const float &sensedRange,
146  CPointPDFSOG &outPDF,
147  const CBeaconMap *myBeaconMap,
148  const CPoint3D &sensorPntOnRobot,
149  const CPoint3D &centerPoint = CPoint3D(0,0,0),
150  const float &maxDistanceFromCenter = 0
151  ) const;
152 
153  /** This static method returns a SOG with ring-shape (or as a 3D sphere) that can be used to initialize a beacon if observed the first time.
154  * sensorPnt is the center of the ring/sphere, i.e. the absolute position of the range sensor.
155  * If clearPreviousContentsOutPDF=false, the SOG modes will be added to the current contents of outPDF
156  * If the 3x3 matrix covarianceCompositionToAdd is provided, it will be add to every Gaussian (to model the composition of uncertainty).
157  * \sa generateObservationModelDistribution
158  */
159  static void generateRingSOG(
160  const float &sensedRange,
161  CPointPDFSOG &outPDF,
162  const CBeaconMap *myBeaconMap,
163  const CPoint3D &sensorPnt,
164  const mrpt::math::CMatrixDouble33 *covarianceCompositionToAdd = NULL,
165  bool clearPreviousContentsOutPDF = true,
166  const CPoint3D &centerPoint = CPoint3D(0,0,0),
167  const float &maxDistanceFromCenter = 0
168  );
169 
170 
171  }; // End of class definition
173 
174 
175  } // End of namespace
176 } // End of namespace
177 
178 #endif
TTypePDF
See m_typePDF.
Definition: CBeacon.h:55
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:83
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
Definition: zip.h:16
The virtual base class which provides a unified interface for all persistent objects in MRPT...
Definition: CSerializable.h:35
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:50
void saveToTextFile(const std::string &file, mrpt::math::TMatrixTextFileFormat fileFormat=mrpt::math::MATRIX_FORMAT_ENG, bool appendMRPTHeader=false, const std::string &userHeader=std::string()) const
Save matrix to a text file, compatible with MATLAB text format (see also the methods of matrix classe...
Declares a class that represents a Probability Density function (PDF) of a 3D point ...
Definition: CPointPDFSOG.h:35
CPointPDFSOG m_locationSOG
The individual PDF, if m_typePDF=pdfSOG (publicly accesible for ease of use, but the CPointPDF interf...
Definition: CBeacon.h:72
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:60
The class for storing individual "beacon landmarks" under a variety of 3D position PDF distributions...
Definition: CBeacon.h:43
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:64
A class for storing a list of text lines.
Definition: CStringList.h:32
A numeric matrix of compile-time fixed size.
#define DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
This declaration must be inserted in all CSerializable classes definition, before the class declarati...
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:135
CPointPDFGaussian m_locationGauss
The individual PDF, if m_typePDF=pdfGauss (publicly accesible for ease of use, but the CPointPDF inte...
Definition: CBeacon.h:68
A class used to store a 3D point.
Definition: CPoint3D.h:32
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
Definition: CPoint.h:17
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:69
int64_t TBeaconID
The type for the IDs of landmarks.
Definition: CBeacon.h:51
#define DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
Declares a class that represents a Probability Distribution function (PDF) of a 3D point (x...
Definition: CPointPDF.h:38
A probability distribution of a 2D/3D point, represented as a set of random samples (particles)...
A gaussian distribution for 3D points.



Page generated by Doxygen 1.8.8 for MRPT 1.2.2 SVN:Unversioned directory at Tue Oct 14 02:14:08 UTC 2014