MRPT
1.9.9
|
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 enought to draw only the 3 required dimensions, avoiding a waste of time with the other 3 missing components.
Definition at line 43 of file CPoseRandomSampler.h.
#include <mrpt/poses/CPoseRandomSampler.h>
Public Member Functions | |
CPoseRandomSampler () | |
Default constructor. More... | |
CPoseRandomSampler (const CPoseRandomSampler &o) | |
CPoseRandomSampler & | operator= (const CPoseRandomSampler &o) |
CPoseRandomSampler (CPoseRandomSampler &&o) | |
CPoseRandomSampler & | operator= (CPoseRandomSampler &&o) |
void | setPosePDF (const CPosePDF *pdf) |
This method must be called to select the PDF from which to draw samples. More... | |
void | setPosePDF (const CPosePDF::Ptr &pdf) |
This method must be called to select the PDF from which to draw samples. More... | |
void | setPosePDF (const CPosePDF &pdf) |
This method must be called to select the PDF from which to draw samples. More... | |
void | setPosePDF (const CPose3DPDF *pdf) |
This method must be called to select the PDF from which to draw samples. More... | |
void | setPosePDF (const CPose3DPDF::Ptr &pdf) |
This method must be called to select the PDF from which to draw samples. More... | |
void | setPosePDF (const CPose3DPDF &pdf) |
This method must be called to select the PDF from which to draw samples. More... | |
CPose2D & | drawSample (CPose2D &p) const |
Generate a new sample from the selected PDF. More... | |
CPose3D & | drawSample (CPose3D &p) const |
Generate a new sample from the selected PDF. More... | |
bool | isPrepared () const |
Return true if samples can be generated, which only requires a previous call to setPosePDF. More... | |
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. More... | |
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. More... | |
void | getOriginalPDFCov2D (mrpt::math::CMatrixDouble33 &cov3x3) const |
Retrieves the 3x3 covariance of the original PDF in . More... | |
void | getOriginalPDFCov2D (mrpt::math::CMatrixDouble &cov3x3) const |
Retrieves the 3x3 covariance of the original PDF in . More... | |
void | getOriginalPDFCov3D (mrpt::math::CMatrixDouble66 &cov6x6) const |
Retrieves the 6x6 covariance of the original PDF in . More... | |
void | getOriginalPDFCov3D (mrpt::math::CMatrixDouble &cov6x6) const |
Retrieves the 6x6 covariance of the original PDF in . More... | |
Protected Member Functions | |
void | clear () |
Clear internal pdf. More... | |
void | do_sample_2D (CPose2D &p) const |
Used internally: sample from m_pdf2D. More... | |
void | do_sample_3D (CPose3D &p) const |
Used internally: sample from m_pdf3D. More... | |
Protected Attributes | |
std::unique_ptr< const CPosePDF > | m_pdf2D |
A local copy of the PDF. More... | |
std::unique_ptr< const CPose3DPDF > | m_pdf3D |
A local copy of the PDF. More... | |
mrpt::math::CMatrixDouble33 | m_fastdraw_gauss_Z3 |
mrpt::math::CMatrixDouble66 | m_fastdraw_gauss_Z6 |
CPose2D | m_fastdraw_gauss_M_2D |
CPose3D | m_fastdraw_gauss_M_3D |
CPoseRandomSampler::CPoseRandomSampler | ( | ) |
Default constructor.
Definition at line 30 of file CPoseRandomSampler.cpp.
CPoseRandomSampler::CPoseRandomSampler | ( | const CPoseRandomSampler & | o | ) |
Definition at line 31 of file CPoseRandomSampler.cpp.
References m_fastdraw_gauss_M_2D, m_fastdraw_gauss_M_3D, m_fastdraw_gauss_Z3, m_fastdraw_gauss_Z6, m_pdf2D, and m_pdf3D.
CPoseRandomSampler::CPoseRandomSampler | ( | CPoseRandomSampler && | o | ) |
Definition at line 59 of file CPoseRandomSampler.cpp.
References m_fastdraw_gauss_M_2D, m_fastdraw_gauss_M_3D, m_fastdraw_gauss_Z3, m_fastdraw_gauss_Z6, m_pdf2D, and m_pdf3D.
|
protected |
Clear internal pdf.
Definition at line 101 of file CPoseRandomSampler.cpp.
References m_pdf2D, and m_pdf3D.
Referenced by operator=(), and setPosePDF().
Used internally: sample from m_pdf2D.
Definition at line 258 of file CPoseRandomSampler.cpp.
References ASSERT_, mrpt::random::CRandomGenerator::drawGaussian1D_normalized(), mrpt::poses::CPosePDFParticles::drawSingleSample(), mrpt::random::getRandomGenerator(), IS_CLASS, m_fastdraw_gauss_M_2D, m_fastdraw_gauss_Z3, m_pdf2D, MRPT_END, MRPT_START, mrpt::poses::CPose2D::phi(), THROW_EXCEPTION, THROW_EXCEPTION_FMT, mrpt::poses::CPoseOrPoint< DERIVEDCLASS >::x(), and mrpt::poses::CPoseOrPoint< DERIVEDCLASS >::y().
Referenced by drawSample().
Used internally: sample from m_pdf3D.
Definition at line 309 of file CPoseRandomSampler.cpp.
References ASSERT_, mrpt::random::CRandomGenerator::drawGaussian1D_normalized(), mrpt::poses::CPose3DPDFParticles::drawSingleSample(), mrpt::random::getRandomGenerator(), IS_CLASS, m_fastdraw_gauss_M_3D, m_fastdraw_gauss_Z6, m_pdf3D, MRPT_END, MRPT_START, mrpt::poses::CPose3D::pitch(), mrpt::poses::CPose3D::roll(), THROW_EXCEPTION, THROW_EXCEPTION_FMT, mrpt::poses::CPoseOrPoint< DERIVEDCLASS >::x(), mrpt::poses::CPoseOrPoint< DERIVEDCLASS >::y(), and mrpt::poses::CPose3D::yaw().
Referenced by drawSample().
Generate a new sample from the selected PDF.
Definition at line 208 of file CPoseRandomSampler.cpp.
References do_sample_2D(), do_sample_3D(), m_pdf2D, m_pdf3D, MRPT_END, MRPT_START, and THROW_EXCEPTION.
Referenced by mrpt::maps::CMultiMetricMapPDF::prediction_and_update_pfOptimalProposal().
Generate a new sample from the selected PDF.
Definition at line 234 of file CPoseRandomSampler.cpp.
References do_sample_2D(), do_sample_3D(), m_pdf2D, m_pdf3D, MRPT_END, MRPT_START, and THROW_EXCEPTION.
void CPoseRandomSampler::getOriginalPDFCov2D | ( | mrpt::math::CMatrixDouble33 & | cov3x3 | ) | const |
Retrieves the 3x3 covariance of the original PDF in .
Definition at line 367 of file CPoseRandomSampler.cpp.
References ASSERT_, mrpt::poses::CPosePDFGaussian::copyFrom(), mrpt::poses::CPosePDFGaussian::cov, isPrepared(), m_pdf2D, m_pdf3D, MRPT_END, and MRPT_START.
Referenced by getOriginalPDFCov2D(), and mrpt::maps::CMultiMetricMapPDF::prediction_and_update_pfOptimalProposal().
|
inline |
Retrieves the 3x3 covariance of the original PDF in .
Definition at line 134 of file CPoseRandomSampler.h.
References getOriginalPDFCov2D().
void CPoseRandomSampler::getOriginalPDFCov3D | ( | mrpt::math::CMatrixDouble66 & | cov6x6 | ) | const |
Retrieves the 6x6 covariance of the original PDF in .
Definition at line 391 of file CPoseRandomSampler.cpp.
References ASSERT_, mrpt::poses::CPose3DPDFGaussian::copyFrom(), mrpt::poses::CPose3DPDFGaussian::cov, isPrepared(), m_pdf2D, m_pdf3D, MRPT_END, and MRPT_START.
Referenced by getOriginalPDFCov3D().
|
inline |
Retrieves the 6x6 covariance of the original PDF in .
Definition at line 147 of file CPoseRandomSampler.h.
References getOriginalPDFCov3D().
If the object has been loaded with setPosePDF this method returns the 2D pose mean samples will be drawn around.
Definition at line 414 of file CPoseRandomSampler.cpp.
References ASSERT_, isPrepared(), m_fastdraw_gauss_M_2D, m_fastdraw_gauss_M_3D, m_pdf2D, MRPT_END, and MRPT_START.
If the object has been loaded with setPosePDF this method returns the 3D pose mean samples will be drawn around.
Definition at line 431 of file CPoseRandomSampler.cpp.
References ASSERT_, isPrepared(), m_fastdraw_gauss_M_2D, m_fastdraw_gauss_M_3D, m_pdf3D, MRPT_END, and MRPT_START.
bool CPoseRandomSampler::isPrepared | ( | ) | const |
Return true if samples can be generated, which only requires a previous call to setPosePDF.
Definition at line 363 of file CPoseRandomSampler.cpp.
References m_pdf2D, and m_pdf3D.
Referenced by getOriginalPDFCov2D(), getOriginalPDFCov3D(), getSamplingMean2D(), getSamplingMean3D(), and mrpt::maps::CMultiMetricMapPDF::prediction_and_update_pfOptimalProposal().
CPoseRandomSampler & CPoseRandomSampler::operator= | ( | const CPoseRandomSampler & | o | ) |
Definition at line 43 of file CPoseRandomSampler.cpp.
References m_fastdraw_gauss_M_2D, m_fastdraw_gauss_M_3D, m_fastdraw_gauss_Z3, m_fastdraw_gauss_Z6, m_pdf2D, and m_pdf3D.
CPoseRandomSampler & CPoseRandomSampler::operator= | ( | CPoseRandomSampler && | o | ) |
Definition at line 77 of file CPoseRandomSampler.cpp.
References clear(), m_fastdraw_gauss_M_2D, m_fastdraw_gauss_M_3D, m_fastdraw_gauss_Z3, m_fastdraw_gauss_Z6, m_pdf2D, and m_pdf3D.
This method must be called to select the PDF from which to draw samples.
Computes the eigenvalues/eigenvector decomposition of this matrix, so that: M = Z · D · ZT, where columns in Z are the eigenvectors and the diagonal matrix D contains the eigenvalues as diagonal elements, sorted in ascending order.
Definition at line 110 of file CPoseRandomSampler.cpp.
References clear(), mrpt::rtti::CObject::clone(), mrpt::poses::CPosePDFGaussian::cov, mrpt::math::cov(), IS_CLASS, m_fastdraw_gauss_M_2D, m_fastdraw_gauss_Z3, m_pdf2D, mrpt::poses::CPosePDFGaussian::mean, MRPT_END, MRPT_START, and THROW_EXCEPTION_FMT.
Referenced by mrpt::maps::CMultiMetricMapPDF::prediction_and_update_pfOptimalProposal(), and setPosePDF().
void CPoseRandomSampler::setPosePDF | ( | const CPosePDF::Ptr & | ) |
This method must be called to select the PDF from which to draw samples.
Definition at line 200 of file CPoseRandomSampler.cpp.
References setPosePDF().
This method must be called to select the PDF from which to draw samples.
Definition at line 87 of file CPoseRandomSampler.h.
References setPosePDF().
Referenced by setPosePDF().
void CPoseRandomSampler::setPosePDF | ( | const CPose3DPDF * | ) |
This method must be called to select the PDF from which to draw samples.
Computes the eigenvalues/eigenvector decomposition of this matrix, so that: M = Z · D · ZT, where columns in Z are the eigenvectors and the diagonal matrix D contains the eigenvalues as diagonal elements, sorted in ascending order.
Definition at line 154 of file CPoseRandomSampler.cpp.
References clear(), mrpt::rtti::CObject::clone(), mrpt::poses::CPose3DPDFGaussian::cov, mrpt::math::cov(), IS_CLASS, m_fastdraw_gauss_M_3D, m_fastdraw_gauss_Z6, m_pdf3D, mrpt::poses::CPose3DPDFGaussian::mean, MRPT_END, MRPT_START, and THROW_EXCEPTION_FMT.
void CPoseRandomSampler::setPosePDF | ( | const CPose3DPDF::Ptr & | ) |
This method must be called to select the PDF from which to draw samples.
Definition at line 195 of file CPoseRandomSampler.cpp.
References setPosePDF().
|
inline |
This method must be called to select the PDF from which to draw samples.
Definition at line 101 of file CPoseRandomSampler.h.
References setPosePDF().
Referenced by setPosePDF().
|
protected |
Definition at line 54 of file CPoseRandomSampler.h.
Referenced by CPoseRandomSampler(), do_sample_2D(), getSamplingMean2D(), getSamplingMean3D(), operator=(), and setPosePDF().
|
protected |
Definition at line 55 of file CPoseRandomSampler.h.
Referenced by CPoseRandomSampler(), do_sample_3D(), getSamplingMean2D(), getSamplingMean3D(), operator=(), and setPosePDF().
|
protected |
Definition at line 52 of file CPoseRandomSampler.h.
Referenced by CPoseRandomSampler(), do_sample_2D(), operator=(), and setPosePDF().
|
protected |
Definition at line 53 of file CPoseRandomSampler.h.
Referenced by CPoseRandomSampler(), do_sample_3D(), operator=(), and setPosePDF().
|
protected |
A local copy of the PDF.
Definition at line 48 of file CPoseRandomSampler.h.
Referenced by clear(), CPoseRandomSampler(), do_sample_2D(), drawSample(), getOriginalPDFCov2D(), getOriginalPDFCov3D(), getSamplingMean2D(), isPrepared(), operator=(), and setPosePDF().
|
protected |
A local copy of the PDF.
Definition at line 50 of file CPoseRandomSampler.h.
Referenced by clear(), CPoseRandomSampler(), do_sample_3D(), drawSample(), getOriginalPDFCov2D(), getOriginalPDFCov3D(), getSamplingMean3D(), isPrepared(), operator=(), and setPosePDF().
Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020 |