Main MRPT website > C++ reference for MRPT 1.4.0
CPoseRandomSampler.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 CPoseRandomSampler_H
10#define CPoseRandomSampler_H
11
12#include <mrpt/poses/CPose3D.h>
13#include <mrpt/poses/CPose2D.h>
16
17namespace mrpt
18{
19 namespace poses
20 {
21 /** An efficient generator of random samples drawn from a given 2D (CPosePDF) or 3D (CPose3DPDF) pose probability density function (pdf).
22 * This class keeps an internal state which speeds up the sequential generation of samples. It can manage
23 * any kind of pose PDF.
24 *
25 * Use with CPoseRandomSampler::setPosePDF, then CPoseRandomSampler::drawSample to draw values.
26 *
27 * Notice that you can pass a 2D or 3D pose PDF, then ask for a 2D or 3D sample. This class always returns
28 * the kind of sample you ask it for, but will skip missing terms or fill out with zeroes as required.
29 * Specifically, when sampling 3D poses from a 2D pose pdf, this class will be smart enought to draw only
30 * the 3 required dimensions, avoiding a waste of time with the other 3 missing components.
31 *
32 * \ingroup poses_pdf_grp
33 * \sa CPosePDF, CPose3DPDF
34 */
36 {
37 protected:
38 // Only ONE of these can be not-NULL at a time.
39 CPosePDF* m_pdf2D; //!< A local copy of the PDF
40 CPose3DPDF* m_pdf3D; //!< A local copy of the PDF
41
46
47 void clear(); //!< Clear internal pdf
48
49 void do_sample_2D( CPose2D &p ) const; //!< Used internally: sample from m_pdf2D
50 void do_sample_3D( CPose3D &p ) const; //!< Used internally: sample from m_pdf3D
51
52 public:
53 /** Default constructor */
55
56 /** Destructor */
58
59 /** This method must be called to select the PDF from which to draw samples.
60 * \sa drawSample
61 */
62 void setPosePDF( const CPosePDF *pdf );
63
64 /** This method must be called to select the PDF from which to draw samples.
65 * \sa drawSample
66 */
67 void setPosePDF( const CPosePDFPtr &pdf );
68
69 /** This method must be called to select the PDF from which to draw samples.
70 * \sa drawSample
71 */
72 void setPosePDF( const CPosePDF &pdf ) { setPosePDF(&pdf); }
73
74 /** This method must be called to select the PDF from which to draw samples.
75 * \sa drawSample
76 */
77 void setPosePDF( const CPose3DPDF *pdf );
78
79 /** This method must be called to select the PDF from which to draw samples.
80 * \sa drawSample
81 */
82 void setPosePDF( const CPose3DPDFPtr &pdf );
83
84 /** This method must be called to select the PDF from which to draw samples.
85 * \sa drawSample
86 */
87 void setPosePDF( const CPose3DPDF &pdf ) { setPosePDF(&pdf); }
88
89 /** Generate a new sample from the selected PDF.
90 * \return A reference to the same object passed as argument.
91 * \sa setPosePDF
92 */
93 CPose2D & drawSample( CPose2D &p ) const;
94
95 /** Generate a new sample from the selected PDF.
96 * \return A reference to the same object passed as argument.
97 * \sa setPosePDF
98 */
99 CPose3D & drawSample( CPose3D &p ) const;
100
101 /** Return true if samples can be generated, which only requires a previous call to setPosePDF */
102 bool isPrepared() const;
103
104 /** If the object has been loaded with setPosePDF this method returns the 2D pose mean samples will be drawn around. \return A reference to the argument */
106
107 /** If the object has been loaded with setPosePDF this method returns the 3D pose mean samples will be drawn around. \return A reference to the argument */
109
110 /** Retrieves the 3x3 covariance of the original PDF in \f$ [ x ~ y ~ \phi ] \f$. */
112
113 /** Retrieves the 3x3 covariance of the original PDF in \f$ [ x ~ y ~ \phi ] \f$. */
114 inline void getOriginalPDFCov2D( mrpt::math::CMatrixDouble &cov3x3 ) const {
116 this->getOriginalPDFCov2D(M);
117 cov3x3 = mrpt::math::CMatrixDouble(M);
118 }
119
120 /** Retrieves the 6x6 covariance of the original PDF in \f$ [ x ~ y ~ z ~ yaw ~ pitch ~ roll ] \f$. */
122
123 /** Retrieves the 6x6 covariance of the original PDF in \f$ [ x ~ y ~ z ~ yaw ~ pitch ~ roll ] \f$. */
124 inline void getOriginalPDFCov3D( mrpt::math::CMatrixDouble &cov6x6 ) const {
126 this->getOriginalPDFCov3D(M);
127 cov6x6 = mrpt::math::CMatrixDouble(M);
128 }
129
130 }; // End of class def.
131 } // End of namespace
132} // End of namespace
133
134#endif
A numeric matrix of compile-time fixed size.
A class used to store a 2D pose.
Definition: CPose2D.h:37
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 (6D actually).
Definition: CPose3DPDF.h:41
Declares a class that represents a probability density function (pdf) of a 2D pose (x,...
Definition: CPosePDF.h:40
An efficient generator of random samples drawn from a given 2D (CPosePDF) or 3D (CPose3DPDF) pose pro...
CPose2D & drawSample(CPose2D &p) const
Generate a new sample from the selected PDF.
CPosePDF * m_pdf2D
A local copy of the PDF.
CPose3DPDF * m_pdf3D
A local copy of the PDF.
CPose2D & getSamplingMean2D(CPose2D &out_mean) const
If the object has been loaded with setPosePDF this method returns the 2D pose mean samples will be dr...
bool isPrepared() const
Return true if samples can be generated, which only requires a previous call to setPosePDF.
mrpt::math::CMatrixDouble33 m_fastdraw_gauss_Z3
void setPosePDF(const CPosePDF &pdf)
This method must be called to select the PDF from which to draw samples.
void setPosePDF(const CPose3DPDF *pdf)
This method must be called to select the PDF from which to draw samples.
void getOriginalPDFCov3D(mrpt::math::CMatrixDouble &cov6x6) const
Retrieves the 6x6 covariance of the original PDF in .
void setPosePDF(const CPose3DPDFPtr &pdf)
This method must be called to select the PDF from which to draw samples.
void do_sample_3D(CPose3D &p) const
Used internally: sample from m_pdf3D.
CPose3D & drawSample(CPose3D &p) const
Generate a new sample from the selected PDF.
mrpt::math::CMatrixDouble66 m_fastdraw_gauss_Z6
void setPosePDF(const CPose3DPDF &pdf)
This method must be called to select the PDF from which to draw samples.
void clear()
Clear internal pdf.
void setPosePDF(const CPosePDF *pdf)
This method must be called to select the PDF from which to draw samples.
void getOriginalPDFCov3D(mrpt::math::CMatrixDouble66 &cov6x6) const
Retrieves the 6x6 covariance of the original PDF in .
CPoseRandomSampler()
Default constructor.
void getOriginalPDFCov2D(mrpt::math::CMatrixDouble33 &cov3x3) const
Retrieves the 3x3 covariance of the original PDF in .
CPose3D & getSamplingMean3D(CPose3D &out_mean) const
If the object has been loaded with setPosePDF this method returns the 3D pose mean samples will be dr...
void setPosePDF(const CPosePDFPtr &pdf)
This method must be called to select the PDF from which to draw samples.
void do_sample_2D(CPose2D &p) const
Used internally: sample from m_pdf2D.
void getOriginalPDFCov2D(mrpt::math::CMatrixDouble &cov3x3) const
Retrieves the 3x3 covariance of the original PDF in .
CMatrixTemplateNumeric< double > CMatrixDouble
Declares a matrix of double numbers (non serializable).
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.



Page generated by Doxygen 1.9.5 for MRPT 1.4.0 SVN: at Sun Nov 27 02:56:26 UTC 2022