Main MRPT website > C++ reference for MRPT 1.4.0
CPose3DPDFSOG.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-2016, 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 CPose3DPDFSOG_H
10#define CPose3DPDFSOG_H
11
15
16namespace mrpt
17{
18namespace poses
19{
20 // This must be added to any CSerializable derived class:
22
23 /** Declares a class that represents a Probability Density function (PDF) of a 3D(6D) pose \f$ p(\mathbf{x}) = [x ~ y ~ z ~ yaw ~ pitch ~ roll]^t \f$.
24 * This class implements that PDF as the following multi-modal Gaussian distribution:
25 *
26 * \f$ p(\mathbf{x}) = \sum\limits_{i=1}^N \omega^i \mathcal{N}( \mathbf{x} ; \bar{\mathbf{x}}^i, \mathbf{\Sigma}^i ) \f$
27 *
28 * Where the number of modes N is the size of CPose3DPDFSOG::m_modes. Angles are always in radians.
29 *
30 * See mrpt::poses::CPose3DPDF for more details.
31 * \ingroup poses_pdf_grp
32 * \sa CPose3DPDF
33 */
35 {
36 // This must be added to any CSerializable derived class:
38
39 public:
40 /** The struct for each mode:
41 */
43 {
45 val(),
46 log_w(0)
47 { }
48
50
51 /** The log-weight
52 */
53 double log_w;
54 };
55
57 typedef TModesList::const_iterator const_iterator;
58 typedef TModesList::iterator iterator;
59
60 protected:
61 /** Assures the symmetry of the covariance matrix (eventually certain operations in the math-coprocessor lead to non-symmetric matrixes!)
62 */
64
65 /** Access directly to this array for modify the modes as desired.
66 * Note that no weight can be zero!!
67 * We must use pointers to satisfy the mem-alignment of the matrixes
68 */
70
71 public:
72 /** Default constructor
73 * \param nModes The initial size of CPose3DPDFSOG::m_modes
74 */
75 CPose3DPDFSOG( size_t nModes = 1 );
76
77 void clear(); //!< Clear all the gaussian modes
78 void resize(const size_t N); //!< Set the number of SOG modes
79 size_t size() const { return m_modes.size(); } //!< Return the number of Gaussian modes.
80 bool empty() const { return m_modes.empty(); } //!< Return whether there is any Gaussian mode.
81
82 iterator begin() { return m_modes.begin(); }
83 iterator end() { return m_modes.end(); }
84 const_iterator begin() const { return m_modes.begin(); }
85 const_iterator end()const { return m_modes.end(); }
86
87 void getMean(CPose3D &mean_pose) const MRPT_OVERRIDE; //!< Returns an estimate of the pose, (the mean, or mathematical expectation of the PDF), computed as a weighted average over all m_particles. \sa getCovariance
88 void getCovarianceAndMean(mrpt::math::CMatrixDouble66 &cov,CPose3D &mean_point) const MRPT_OVERRIDE; //!< Returns an estimate of the pose covariance matrix (6x6 cov matrix) and the mean, both at once. \sa getMean
89 void normalizeWeights(); //!< Normalize the weights in m_modes such as the maximum log-weight is 0.
90 void getMostLikelyMode( CPose3DPDFGaussian& outVal ) const; //!< Return the Gaussian mode with the highest likelihood (or an empty Gaussian if there are no modes in this SOG)
91
92 void copyFrom(const CPose3DPDF &o) MRPT_OVERRIDE; //!< Copy operator, translating if necesary (for example, between particles and gaussian representations)
93
94 /** Save the density to a text file, with the following format:
95 * There is one row per Gaussian "mode", and each row contains 10 elements:
96 * - w (The linear weight)
97 * - x_mean (gaussian mean value)
98 * - y_mean (gaussian mean value)
99 * - x_mean (gaussian mean value)
100 * - yaw_mean (gaussian mean value, in radians)
101 * - pitch_mean (gaussian mean value, in radians)
102 * - roll_mean (gaussian mean value, in radians)
103 * - C11,C22,C33,C44,C55,C66 (Covariance elements)
104 * - C12,C13,C14,C15,C16 (Covariance elements)
105 * - C23,C24,C25,C25 (Covariance elements)
106 * - C34,C35,C36 (Covariance elements)
107 * - C45,C46 (Covariance elements)
108 * - C56 (Covariance elements)
109 *
110 */
111 void saveToTextFile(const std::string &file) const MRPT_OVERRIDE;
112
113 /** this = p (+) this. This can be used to convert a PDF from local coordinates to global, providing the point (newReferenceBase) from which
114 * "to project" the current pdf. Result PDF substituted the currently stored one in the object. */
115 void changeCoordinatesReference(const CPose3D &newReferenceBase ) MRPT_OVERRIDE;
116
117 /** Bayesian fusion of two pose distributions, then save the result in this object (WARNING: Currently p1 must be a mrpt::poses::CPose3DPDFSOG object and p2 a mrpt::poses::CPose3DPDFSOG object) */
119
120 void drawSingleSample( CPose3D &outPart ) const MRPT_OVERRIDE; //!< Draws a single sample from the distribution
121 void drawManySamples( size_t N, std::vector<mrpt::math::CVectorDouble> & outSamples ) const MRPT_OVERRIDE; //!< Draws a number of samples from the distribution, and saves as a list of 1x6 vectors, where each row contains a (x,y,z,yaw,pitch,roll) datum
122 void inverse(CPose3DPDF &o) const MRPT_OVERRIDE; //!< Returns a new PDF such as: NEW_PDF = (0,0,0) - THIS_PDF
123
124 void appendFrom( const CPose3DPDFSOG &o ); //!< Append the Gaussian modes from "o" to the current set of modes of "this" density
125
126 }; // End of class def.
128 } // End of namespace
129} // End of namespace
130#endif
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
#define DEFINE_SERIALIZABLE_POST_CUSTOM_BASE(class_name, base_name)
#define DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE(class_name, base_name)
This declaration must be inserted in all CSerializable classes definition, before the class declarati...
A numeric matrix of compile-time fixed size.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:73
Declares a class that represents a Probability Density function (PDF) of a 3D pose .
Declares a class that represents a Probability Density Function (PDF) of a 3D pose (6D actually).
Definition: CPose3DPDF.h:41
Declares a class that represents a Probability Density function (PDF) of a 3D(6D) pose .
Definition: CPose3DPDFSOG.h:35
void saveToTextFile(const std::string &file) const MRPT_OVERRIDE
Save the density to a text file, with the following format: There is one row per Gaussian "mode",...
void assureSymmetry()
Assures the symmetry of the covariance matrix (eventually certain operations in the math-coprocessor ...
void copyFrom(const CPose3DPDF &o) MRPT_OVERRIDE
Copy operator, translating if necesary (for example, between particles and gaussian representations)
void getCovarianceAndMean(mrpt::math::CMatrixDouble66 &cov, CPose3D &mean_point) const MRPT_OVERRIDE
Returns an estimate of the pose covariance matrix (6x6 cov matrix) and the mean, both at once.
TModesList::iterator iterator
Definition: CPose3DPDFSOG.h:58
const_iterator begin() const
Definition: CPose3DPDFSOG.h:84
void clear()
Clear all the gaussian modes.
void bayesianFusion(const CPose3DPDF &p1, const CPose3DPDF &p2) MRPT_OVERRIDE
Bayesian fusion of two pose distributions, then save the result in this object (WARNING: Currently p1...
void resize(const size_t N)
Set the number of SOG modes.
TModesList::const_iterator const_iterator
Definition: CPose3DPDFSOG.h:57
void normalizeWeights()
Normalize the weights in m_modes such as the maximum log-weight is 0.
CPose3DPDFSOG(size_t nModes=1)
Default constructor.
const_iterator end() const
Definition: CPose3DPDFSOG.h:85
bool empty() const
Return whether there is any Gaussian mode.
Definition: CPose3DPDFSOG.h:80
TModesList m_modes
Access directly to this array for modify the modes as desired.
Definition: CPose3DPDFSOG.h:69
void inverse(CPose3DPDF &o) const MRPT_OVERRIDE
Returns a new PDF such as: NEW_PDF = (0,0,0) - THIS_PDF.
mrpt::aligned_containers< TGaussianMode >::vector_t TModesList
Definition: CPose3DPDFSOG.h:56
void getMostLikelyMode(CPose3DPDFGaussian &outVal) const
Return the Gaussian mode with the highest likelihood (or an empty Gaussian if there are no modes in t...
void drawSingleSample(CPose3D &outPart) const MRPT_OVERRIDE
Draws a single sample from the distribution.
void changeCoordinatesReference(const CPose3D &newReferenceBase) MRPT_OVERRIDE
this = p (+) this.
void drawManySamples(size_t N, std::vector< mrpt::math::CVectorDouble > &outSamples) const MRPT_OVERRIDE
Draws a number of samples from the distribution, and saves as a list of 1x6 vectors,...
void getMean(CPose3D &mean_pose) const MRPT_OVERRIDE
Returns an estimate of the pose, (the mean, or mathematical expectation of the PDF),...
void appendFrom(const CPose3DPDFSOG &o)
Append the Gaussian modes from "o" to the current set of modes of "this" density.
size_t size() const
Return the number of Gaussian modes.
Definition: CPose3DPDFSOG.h:79
#define MRPT_OVERRIDE
C++11 "override" for virtuals:
Definition: mrpt_macros.h:28
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
std::vector< TYPE1, Eigen::aligned_allocator< TYPE1 > > vector_t



Page generated by Doxygen 1.9.5 for MRPT 1.4.0 SVN: at Sun Nov 27 03:17:04 UTC 2022