class mrpt::poses::CPoseRandomSampler
An efficient generator of random samples drawn from a given 2D (CPosePDF) or 3D (CPose3DPDF) pose probability density function (pdf).
This class keeps an internal state which speeds up the sequential generation of samples. It can manage any kind of pose PDF.
Use with CPoseRandomSampler::setPosePDF, then CPoseRandomSampler::drawSample to draw values.
Notice that you can pass a 2D or 3D pose PDF, then ask for a 2D or 3D sample. This class always returns the kind of sample you ask it for, but will skip missing terms or fill out with zeroes as required. Specifically, when sampling 3D poses from a 2D pose pdf, this class will be smart enough to draw only the 3 required dimensions, avoiding a waste of time with the other 3 missing components.
See also:
#include <mrpt/poses/CPoseRandomSampler.h> class CPoseRandomSampler { public: // construction CPoseRandomSampler(); CPoseRandomSampler(const CPoseRandomSampler& o); CPoseRandomSampler(CPoseRandomSampler&& o); // methods CPoseRandomSampler& operator = (const CPoseRandomSampler& o); CPoseRandomSampler& operator = (CPoseRandomSampler&& o); void setPosePDF(const CPosePDF& pdf); void setPosePDF(const CPose3DPDF& pdf); CPose2D& drawSample(CPose2D& p) const; CPose3D& drawSample(CPose3D& p) const; bool isPrepared() const; CPose2D& getSamplingMean2D(CPose2D& out_mean) const; CPose3D& getSamplingMean3D(CPose3D& out_mean) const; void getOriginalPDFCov2D(mrpt::math::CMatrixDouble33& cov3x3) const; void getOriginalPDFCov2D(mrpt::math::CMatrixDouble& cov3x3) const; void getOriginalPDFCov3D(mrpt::math::CMatrixDouble66& cov6x6) const; void getOriginalPDFCov3D(mrpt::math::CMatrixDouble& cov6x6) const; };
Construction
CPoseRandomSampler()
Default constructor.
Methods
void setPosePDF(const CPosePDF& pdf)
This method must be called to select the PDF from which to draw samples.
See also:
void setPosePDF(const CPose3DPDF& pdf)
This method must be called to select the PDF from which to draw samples.
See also:
CPose2D& drawSample(CPose2D& p) const
Generate a new sample from the selected PDF.
Returns:
A reference to the same object passed as argument.
See also:
CPose3D& drawSample(CPose3D& p) const
Generate a new sample from the selected PDF.
Returns:
A reference to the same object passed as argument.
See also:
bool isPrepared() const
Return true if samples can be generated, which only requires a previous call to setPosePDF.
CPose2D& getSamplingMean2D(CPose2D& out_mean) const
If the object has been loaded with setPosePDF this method returns the 2D pose mean samples will be drawn around.
Returns:
A reference to the argument
CPose3D& getSamplingMean3D(CPose3D& out_mean) const
If the object has been loaded with setPosePDF this method returns the 3D pose mean samples will be drawn around.
Returns:
A reference to the argument
void getOriginalPDFCov2D(mrpt::math::CMatrixDouble33& cov3x3) const
Retrieves the 3x3 covariance of the original PDF in \([ x ~ y ~ \phi ]\).
void getOriginalPDFCov2D(mrpt::math::CMatrixDouble& cov3x3) const
Retrieves the 3x3 covariance of the original PDF in \([ x ~ y ~ \phi ]\).
void getOriginalPDFCov3D(mrpt::math::CMatrixDouble66& cov6x6) const
Retrieves the 6x6 covariance of the original PDF in \([ x ~ y ~ z ~ yaw ~ pitch ~ roll ]\).
void getOriginalPDFCov3D(mrpt::math::CMatrixDouble& cov6x6) const
Retrieves the 6x6 covariance of the original PDF in \([ x ~ y ~ z ~ yaw ~ pitch ~ roll ]\).