MRPT  2.0.4
CPoseRandomSampler.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #pragma once
10 
12 #include <mrpt/math/math_frwds.h>
13 #include <mrpt/poses/CPose2D.h>
14 #include <mrpt/poses/CPose3D.h>
15 #include <mrpt/poses/CPose3DPDF.h>
16 #include <mrpt/poses/CPosePDF.h>
17 #include <memory> // unique_ptr
18 
19 namespace mrpt::poses
20 {
21 /** An efficient generator of random samples drawn from a given 2D (CPosePDF) or
22  * 3D (CPose3DPDF) pose probability density function (pdf).
23  * This class keeps an internal state which speeds up the sequential generation
24  * of samples. It can manage
25  * any kind of pose PDF.
26  *
27  * Use with CPoseRandomSampler::setPosePDF, then CPoseRandomSampler::drawSample
28  * to draw values.
29  *
30  * Notice that you can pass a 2D or 3D pose PDF, then ask for a 2D or 3D sample.
31  * This class always returns
32  * the kind of sample you ask it for, but will skip missing terms or fill out
33  * with zeroes as required.
34  * Specifically, when sampling 3D poses from a 2D pose pdf, this class will be
35  * smart enough to draw only
36  * the 3 required dimensions, avoiding a waste of time with the other 3 missing
37  * components.
38  *
39  * \ingroup poses_pdf_grp
40  * \sa CPosePDF, CPose3DPDF
41  */
43 {
44  protected:
45  // Only ONE of these can be not-NULL at a time.
46  /** A local copy of the PDF */
48  /** A local copy of the PDF */
50 
55 
56  /** Clear internal pdf */
57  void clear();
58 
59  /** Used internally: sample from m_pdf2D */
60  void do_sample_2D(CPose2D& p) const;
61  /** Used internally: sample from m_pdf3D */
62  void do_sample_3D(CPose3D& p) const;
63 
64  public:
65  /** Default constructor */
67 
72 
73  /** This method must be called to select the PDF from which to draw samples.
74  * \sa drawSample
75  */
76  void setPosePDF(const CPosePDF& pdf);
77 
78  /** This method must be called to select the PDF from which to draw samples.
79  * \sa drawSample
80  */
81  void setPosePDF(const CPose3DPDF& pdf);
82 
83  /** Generate a new sample from the selected PDF.
84  * \return A reference to the same object passed as argument.
85  * \sa setPosePDF
86  */
87  CPose2D& drawSample(CPose2D& p) const;
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  CPose3D& drawSample(CPose3D& p) const;
94 
95  /** Return true if samples can be generated, which only requires a previous
96  * call to setPosePDF */
97  bool isPrepared() const;
98 
99  /** If the object has been loaded with setPosePDF this method returns the 2D
100  * pose mean samples will be drawn around. \return A reference to the
101  * argument */
102  CPose2D& getSamplingMean2D(CPose2D& out_mean) const;
103 
104  /** If the object has been loaded with setPosePDF this method returns the 3D
105  * pose mean samples will be drawn around. \return A reference to the
106  * argument */
107  CPose3D& getSamplingMean3D(CPose3D& out_mean) const;
108 
109  /** Retrieves the 3x3 covariance of the original PDF in \f$ [ x ~ y ~ \phi ]
110  * \f$. */
112 
113  /** Retrieves the 3x3 covariance of the original PDF in \f$ [ x ~ y ~ \phi ]
114  * \f$. */
116 
117  /** Retrieves the 6x6 covariance of the original PDF in \f$ [ x ~ y ~ z ~
118  * yaw ~ pitch ~ roll ] \f$. */
120 
121  /** Retrieves the 6x6 covariance of the original PDF in \f$ [ x ~ y ~ z ~
122  * yaw ~ pitch ~ roll ] \f$. */
124 
125 }; // End of class def.
126 } // namespace mrpt::poses
mrpt::poses::CPoseRandomSampler::m_fastdraw_gauss_Z6
mrpt::math::CMatrixDouble66 m_fastdraw_gauss_Z6
Definition: CPoseRandomSampler.h:52
mrpt::poses::CPoseRandomSampler::m_pdf3D
CPose3DPDF::Ptr m_pdf3D
A local copy of the PDF.
Definition: CPoseRandomSampler.h:49
mrpt::poses::CPoseRandomSampler::getSamplingMean2D
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...
Definition: CPoseRandomSampler.cpp:389
mrpt::poses::CPoseRandomSampler::getOriginalPDFCov3D
void getOriginalPDFCov3D(mrpt::math::CMatrixDouble66 &cov6x6) const
Retrieves the 6x6 covariance of the original PDF in .
Definition: CPoseRandomSampler.cpp:366
mrpt::poses::CPoseRandomSampler::setPosePDF
void setPosePDF(const CPosePDF &pdf)
This method must be called to select the PDF from which to draw samples.
Definition: CPoseRandomSampler.cpp:103
mrpt::poses::CPoseRandomSampler::m_fastdraw_gauss_M_2D
CPose2D m_fastdraw_gauss_M_2D
Definition: CPoseRandomSampler.h:53
mrpt::poses::CPoseRandomSampler::isPrepared
bool isPrepared() const
Return true if samples can be generated, which only requires a previous call to setPosePDF.
Definition: CPoseRandomSampler.cpp:338
mrpt::poses::CPose3DPDF
Declares a class that represents a Probability Density Function (PDF) of a 3D pose (6D actually).
Definition: CPose3DPDF.h:39
mrpt::poses::CPoseRandomSampler::m_pdf2D
CPosePDF::Ptr m_pdf2D
A local copy of the PDF.
Definition: CPoseRandomSampler.h:47
mrpt::poses::CPoseRandomSampler::drawSample
CPose2D & drawSample(CPose2D &p) const
Generate a new sample from the selected PDF.
Definition: CPoseRandomSampler.cpp:185
mrpt::poses
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
Definition: CHierarchicalMapMHPartition.h:22
CPose2D.h
mrpt::poses::CPoseRandomSampler::operator=
CPoseRandomSampler & operator=(const CPoseRandomSampler &o)
Definition: CPoseRandomSampler.cpp:38
mrpt::math::CMatrixFixed< double, 3, 3 >
CPosePDF.h
mrpt::poses::CPose2D
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle.
Definition: CPose2D.h:39
mrpt::poses::CPose3D
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:85
math_frwds.h
mrpt::poses::CPoseRandomSampler::do_sample_3D
void do_sample_3D(CPose3D &p) const
Used internally: sample from m_pdf3D.
Definition: CPoseRandomSampler.cpp:285
CMatrixDynamic.h
mrpt::poses::CPoseRandomSampler
An efficient generator of random samples drawn from a given 2D (CPosePDF) or 3D (CPose3DPDF) pose pro...
Definition: CPoseRandomSampler.h:42
CPose3D.h
mrpt::poses::CPosePDF
Declares a class that represents a probability density function (pdf) of a 2D pose (x,...
Definition: CPosePDF.h:38
mrpt::poses::CPoseRandomSampler::getOriginalPDFCov2D
void getOriginalPDFCov2D(mrpt::math::CMatrixDouble33 &cov3x3) const
Retrieves the 3x3 covariance of the original PDF in .
Definition: CPoseRandomSampler.cpp:342
mrpt::poses::CPoseRandomSampler::CPoseRandomSampler
CPoseRandomSampler()
Default constructor.
mrpt::poses::CPose3DPDF::Ptr
std::shared_ptr< CPose3DPDF > Ptr
Definition: CPose3DPDF.h:42
mrpt::poses::CPoseRandomSampler::m_fastdraw_gauss_Z3
mrpt::math::CMatrixDouble33 m_fastdraw_gauss_Z3
Definition: CPoseRandomSampler.h:51
CPose3DPDF.h
mrpt::poses::CPosePDF::Ptr
std::shared_ptr< CPosePDF > Ptr
Definition: CPosePDF.h:41
mrpt::poses::CPoseRandomSampler::getSamplingMean3D
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...
Definition: CPoseRandomSampler.cpp:406
mrpt::poses::CPoseRandomSampler::do_sample_2D
void do_sample_2D(CPose2D &p) const
Used internally: sample from m_pdf2D.
Definition: CPoseRandomSampler.cpp:235
mrpt::poses::CPoseRandomSampler::clear
void clear()
Clear internal pdf.
Definition: CPoseRandomSampler.cpp:94
mrpt::math::CMatrixDynamic< double >
mrpt::poses::CPoseRandomSampler::m_fastdraw_gauss_M_3D
CPose3D m_fastdraw_gauss_M_3D
Definition: CPoseRandomSampler.h:54



Page generated by Doxygen 1.8.17 for MRPT 2.0.4 at Sat Jun 27 14:00:59 UTC 2020