50 for (
const_iterator it = m_modes.begin(); it != m_modes.end(); ++it)
52 const double w = exp(it->log_w);
59 p.setFromValues(0, 0, 0, 0, 0, 0);
69 size_t N = m_modes.size();
82 for (
const_iterator it = m_modes.begin(); it != m_modes.end(); ++it)
85 sumW +=
w = exp((it)->log_w);
87 MMt.multiply_AAt(estMean_i);
94 if (sumW != 0) estCov *= (1.0 / sumW);
111 for (
const_iterator it = m_modes.begin(); it != m_modes.end(); ++it)
114 out << (it)->
val.mean;
115 out << (it)->val.cov;
135 for (
iterator it = m_modes.begin(); it != m_modes.end(); ++it)
140 if (version == 0) (it)->log_w = log(max(1e-300, (it)->log_w));
142 in >> (it)->
val.mean;
164 if (
this == &o)
return;
173 m_modes[0].log_w = 0;
176 m_modes[0].val.cov = C;
190 for (
const_iterator it = m_modes.begin(); it != m_modes.end(); ++it)
192 f,
"%e %e %e %e %e %e %e %e %e %e\n", exp((it)->log_w),
193 (it)->
val.mean.x(), (it)->
val.mean.y(), (it)->
val.mean.z(),
194 (it)->
val.cov(0, 0), (it)->
val.cov(1, 1), (it)->
val.cov(2, 2),
195 (it)->
val.cov(0, 1), (it)->
val.cov(0, 2), (it)->
val.cov(1, 2));
204 for (
iterator it = m_modes.begin(); it != m_modes.end(); ++it)
205 (it)->val.changeCoordinatesReference(newReferenceBase);
297 for (
iterator it = m_modes.begin(); it != m_modes.end(); ++it)
299 for (
size_t i = 0; i < 6; i++)
300 for (
size_t j = i + 1; j < 6; j++)
301 (it)->val.cov.get_unsafe(i, j) = (it)->
val.cov.get_unsafe(j, i);
314 if (m_modes.empty())
return;
316 double maxW = m_modes[0].log_w;
317 for (
iterator it = m_modes.begin(); it != m_modes.end(); ++it)
318 maxW = max(maxW, (it)->log_w);
320 for (
iterator it = m_modes.begin(); it != m_modes.end(); ++it)
339 size_t N, std::vector<CVectorDouble>& outSamples)
const 356 out->
resize(m_modes.size());
361 for (it = m_modes.begin(), outIt = out->m_modes.begin();
362 it != m_modes.end(); it++, outIt++)
364 (it)->
val.inverse((outIt)->val);
365 (outIt)->log_w = (it)->log_w;
383 m_modes.push_back(*it);
401 for (
const_iterator it = m_modes.begin(); it != m_modes.end(); ++it)
402 if (it_best == m_modes.end() || it->log_w > it_best->log_w)
405 outVal = it_best->val;
EIGEN_STRONG_INLINE bool empty() const
void append(const mrpt::poses::CPose3D &p)
Adds a new pose to the computation.
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
This namespace provides a OS-independent interface to many useful functions: filenames manipulation...
void getCovarianceAndMean(mrpt::math::CMatrixDouble66 &cov, CPose3D &mean_point) const override
Returns an estimate of the pose covariance matrix (6x6 cov matrix) and the mean, both at once...
TModesList::iterator iterator
int void fclose(FILE *f)
An OS-independent version of fclose.
void getMostLikelyMode(CPose3DPDFGaussian &outVal) const
Return the Gaussian mode with the highest likelihood (or an empty Gaussian if there are no modes in t...
void appendFrom(const CPose3DPDFSOG &o)
Append the Gaussian modes from "o" to the current set of modes of "this" density. ...
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
#define THROW_EXCEPTION(msg)
Declares a class that represents a Probability Density function (PDF) of a 3D(6D) pose ...
void getMean(CPose3D &mean_pose) const override
Returns an estimate of the pose, (the mean, or mathematical expectation of the PDF), computed as a weighted average over all m_particles.
GLubyte GLubyte GLubyte GLubyte w
void normalizeWeights()
Normalize the weights in m_modes such as the maximum log-weight is 0.
void inverse(CPose3DPDF &o) const override
Returns a new PDF such as: NEW_PDF = (0,0,0) - THIS_PDF.
virtual const mrpt::utils::TRuntimeClassId * GetRuntimeClass() const override
Returns information about the class of an object in runtime.
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
A numeric matrix of compile-time fixed size.
This base provides a set of functions for maths stuff.
#define CLASS_ID(T)
Access to runtime class ID for a defined class name.
void readFromStream(mrpt::utils::CStream &in, int version) override
Introduces a pure virtual method responsible for loading from a CStream This can not be used directly...
#define MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler.
void drawManySamples(size_t N, std::vector< mrpt::math::CVectorDouble > &outSamples) const override
Draws a number of samples from the distribution, and saves as a list of 1x6 vectors, where each row contains a (x,y,z,yaw,pitch,roll) datum.
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
TModesList m_modes
Access directly to this array for modify the modes as desired.
TModesList::const_iterator const_iterator
void changeCoordinatesReference(const CPose3D &newReferenceBase) override
this = p (+) this.
void drawSingleSample(CPose3D &outPart) const override
Draws a single sample from the distribution.
void saveToTextFile(const std::string &file) const override
Save the density to a text file, with the following format: There is one row per Gaussian "mode"...
GLsizei const GLchar ** string
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
int fprintf(FILE *fil, const char *format,...) noexcept MRPT_printf_format_check(2
An OS-independent version of fprintf.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Computes weighted and un-weighted averages of SE(3) poses.
void get_average(mrpt::poses::CPose3D &out_mean) const
Returns the average pose.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
void clear()
Clear all the gaussian modes.
This file implements matrix/vector text and binary serialization.
Declares a class that represents a Probability Density function (PDF) of a 3D pose ...
void bayesianFusion(const CPose3DPDF &p1, const CPose3DPDF &p2) override
Bayesian fusion of two pose distributions, then save the result in this object (WARNING: Currently p1...
void assureSymmetry()
Assures the symmetry of the covariance matrix (eventually certain operations in the math-coprocessor ...
void writeToStream(mrpt::utils::CStream &out, int *getVersion) const override
Introduces a pure virtual method responsible for writing to a CStream.
FILE * fopen(const char *fileName, const char *mode) noexcept
An OS-independent version of fopen.
virtual void getCovarianceAndMean(mrpt::math::CMatrixFixedNumeric< double, STATE_LEN, STATE_LEN > &cov, TDATA &mean_point) const =0
Returns an estimate of the pose covariance matrix (STATE_LENxSTATE_LEN cov matrix) and the mean...
unsigned __int32 uint32_t
Declares a class that represents a Probability Density Function (PDF) of a 3D pose (6D actually)...
void copyFrom(const CPose3DPDF &o) override
Copy operator, translating if necesary (for example, between particles and gaussian representations) ...
EIGEN_STRONG_INLINE double mean() const
Computes the mean of the entire matrix.
CMatrixFixedNumeric< double, 6, 1 > CMatrixDouble61
void resize(const size_t N)
Set the number of SOG modes.