MRPT  1.9.9
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-2019, Individual contributors, see AUTHORS file |
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
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...
CPoseRandomSampler()
Default constructor.
bool isPrepared() const
Return true if samples can be generated, which only requires a previous call to setPosePDF.
void getOriginalPDFCov3D(mrpt::math::CMatrixDouble66 &cov6x6) const
Retrieves the 6x6 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 do_sample_3D(CPose3D &p) const
Used internally: sample from m_pdf3D.
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 getOriginalPDFCov2D(mrpt::math::CMatrixDouble33 &cov3x3) const
Retrieves the 3x3 covariance of the original PDF in .
void do_sample_2D(CPose2D &p) const
Used internally: sample from m_pdf2D.
mrpt::math::CMatrixDouble33 m_fastdraw_gauss_Z3
Declares a class that represents a probability density function (pdf) of a 2D pose (x...
Definition: CPosePDF.h:38
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle...
Definition: CPose2D.h:39
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:85
CPoseRandomSampler & operator=(const CPoseRandomSampler &o)
CPosePDF::Ptr m_pdf2D
A local copy of the PDF.
CPose2D & drawSample(CPose2D &p) const
Generate a new sample from the selected PDF.
mrpt::math::CMatrixDouble66 m_fastdraw_gauss_Z6
An efficient generator of random samples drawn from a given 2D (CPosePDF) or 3D (CPose3DPDF) pose pro...
Declares a class that represents a Probability Density Function (PDF) of a 3D pose (6D actually)...
Definition: CPose3DPDF.h:39
CPose3DPDF::Ptr m_pdf3D
A local copy of the PDF.

 Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 24b95e159 Thu Jan 23 01:15:46 2020 +0100 at jue ene 23 01:30:10 CET 2020