Main MRPT website > C++ reference for MRPT 1.9.9
CPointPDFSOG.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include "base-precomp.h" // Precompiled headers
11 
13 #include <mrpt/poses/CPosePDF.h>
14 #include <mrpt/poses/CPose3D.h>
16 #include <mrpt/random.h>
18 #include <mrpt/utils/CStream.h>
19 #include <mrpt/system/os.h>
20 
21 using namespace mrpt::poses;
22 using namespace mrpt::math;
23 using namespace mrpt::utils;
24 using namespace mrpt::bayes;
25 using namespace mrpt::random;
26 using namespace mrpt::system;
27 using namespace std;
28 
30 
31 /*---------------------------------------------------------------
32  Constructor
33  ---------------------------------------------------------------*/
34 CPointPDFSOG::CPointPDFSOG(size_t nModes) : m_modes(nModes) {}
35 /*---------------------------------------------------------------
36  clear
37  ---------------------------------------------------------------*/
38 void CPointPDFSOG::clear() { m_modes.clear(); }
39 /*---------------------------------------------------------------
40  Resize
41  ---------------------------------------------------------------*/
42 void CPointPDFSOG::resize(const size_t N) { m_modes.resize(N); }
43 /*---------------------------------------------------------------
44  getMean
45  Returns an estimate of the pose, (the mean, or mathematical expectation of the
46  PDF)
47  ---------------------------------------------------------------*/
49 {
50  size_t N = m_modes.size();
51  double X = 0, Y = 0, Z = 0;
52 
53  if (N)
54  {
56  double sumW = 0;
57 
58  for (it = m_modes.begin(); it != m_modes.end(); ++it)
59  {
60  double w;
61  sumW += w = exp(it->log_w);
62  X += it->val.mean.x() * w;
63  Y += it->val.mean.y() * w;
64  Z += it->val.mean.z() * w;
65  }
66  if (sumW > 0)
67  {
68  X /= sumW;
69  Y /= sumW;
70  Z /= sumW;
71  }
72  }
73 
74  p.x(X);
75  p.y(Y);
76  p.z(Z);
77 }
78 
79 /*---------------------------------------------------------------
80  getCovarianceAndMean
81  ---------------------------------------------------------------*/
83  CMatrixDouble33& estCov, CPoint3D& p) const
84 {
85  size_t N = m_modes.size();
86 
87  getMean(p);
88  estCov.zeros();
89 
90  if (N)
91  {
92  // 1) Get the mean:
93  double sumW = 0;
95 
97 
98  CMatrixDouble33 partCov;
99 
100  for (it = m_modes.begin(); it != m_modes.end(); ++it)
101  {
102  double w;
103  sumW += w = exp(it->log_w);
104 
105  // estCov += w * ( it->val.cov +
106  // ((estMean_i-estMean)*(~(estMean_i-estMean))) );
107  CMatrixDouble31 estMean_i = CMatrixDouble31(it->val.mean);
108  estMean_i -= estMean;
109  partCov.multiply_AAt(estMean_i);
110  partCov += it->val.cov;
111  partCov *= w;
112  estCov += partCov;
113  }
114 
115  if (sumW != 0) estCov *= (1.0 / sumW);
116  }
117 }
118 
119 /*---------------------------------------------------------------
120  writeToStream
121  ---------------------------------------------------------------*/
122 void CPointPDFSOG::writeToStream(mrpt::utils::CStream& out, int* version) const
123 {
124  if (version)
125  *version = 1;
126  else
127  {
128  uint32_t N = m_modes.size();
130 
131  out << N;
132 
133  for (it = m_modes.begin(); it != m_modes.end(); ++it)
134  {
135  out << it->log_w;
136  out << it->val.mean;
137  out << it->val.cov(0, 0) << it->val.cov(1, 1) << it->val.cov(2, 2);
138  out << it->val.cov(0, 1) << it->val.cov(0, 2) << it->val.cov(1, 2);
139  }
140  }
141 }
142 
143 /*---------------------------------------------------------------
144  readFromStream
145  ---------------------------------------------------------------*/
147 {
148  switch (version)
149  {
150  case 0:
151  case 1:
152  {
153  uint32_t N;
155  double x;
156 
157  in >> N;
158 
159  this->resize(N);
160 
161  for (it = m_modes.begin(); it != m_modes.end(); ++it)
162  {
163  in >> it->log_w;
164 
165  // In version 0, weights were linear!!
166  if (version == 0) it->log_w = log(max(1e-300, it->log_w));
167 
168  in >> it->val.mean;
169 
170  in >> x;
171  it->val.cov(0, 0) = x;
172  in >> x;
173  it->val.cov(1, 1) = x;
174  in >> x;
175  it->val.cov(2, 2) = x;
176 
177  in >> x;
178  it->val.cov(1, 0) = x;
179  it->val.cov(0, 1) = x;
180  in >> x;
181  it->val.cov(2, 0) = x;
182  it->val.cov(0, 2) = x;
183  in >> x;
184  it->val.cov(1, 2) = x;
185  it->val.cov(2, 1) = x;
186  }
187  }
188  break;
189  default:
191  };
192 }
193 
195 {
196  MRPT_START
197 
198  if (this == &o) return; // It may be used sometimes
199 
201  {
202  m_modes = static_cast<const CPointPDFSOG*>(&o)->m_modes;
203  }
204  else
205  {
206  // Approximate as a mono-modal gaussian pdf:
207  this->resize(1);
208  m_modes[0].log_w = 0;
209  o.getCovarianceAndMean(m_modes[0].val.cov, m_modes[0].val.mean);
210  }
211 
212  MRPT_END
213 }
214 
215 /*---------------------------------------------------------------
216  saveToTextFile
217  ---------------------------------------------------------------*/
219 {
220  FILE* f = os::fopen(file.c_str(), "wt");
221  if (!f) return;
222 
223  for (CListGaussianModes::const_iterator it = m_modes.begin();
224  it != m_modes.end(); ++it)
225  os::fprintf(
226  f, "%e %e %e %e %e %e %e %e %e %e\n", exp(it->log_w),
227  it->val.mean.x(), it->val.mean.y(), it->val.mean.z(),
228  it->val.cov(0, 0), it->val.cov(1, 1), it->val.cov(2, 2),
229  it->val.cov(0, 1), it->val.cov(0, 2), it->val.cov(1, 2));
230  os::fclose(f);
231 }
232 
233 /*---------------------------------------------------------------
234  changeCoordinatesReference
235  ---------------------------------------------------------------*/
237 {
238  for (CListGaussianModes::iterator it = m_modes.begin(); it != m_modes.end();
239  ++it)
240  it->val.changeCoordinatesReference(newReferenceBase);
241 }
242 
243 /*---------------------------------------------------------------
244  drawSingleSample
245  ---------------------------------------------------------------*/
247 {
248  MRPT_START
249 
250  ASSERT_(m_modes.size() > 0);
251 
252  // 1st: Select a mode with a probability proportional to its weight:
253  vector<double> logWeights(m_modes.size());
254  vector<size_t> outIdxs;
257  for (it = m_modes.begin(), itW = logWeights.begin(); it != m_modes.end();
258  ++it, ++itW)
259  *itW = it->log_w;
260 
261  CParticleFilterCapable::computeResampling(
262  CParticleFilter::prMultinomial, // Resampling algorithm
263  logWeights, // input: log weights
264  outIdxs // output: indexes
265  );
266 
267  // we need just one: take the first (arbitrary)
268  size_t selectedIdx = outIdxs[0];
269  ASSERT_(selectedIdx < m_modes.size());
270  const CPointPDFGaussian* selMode = &m_modes[selectedIdx].val;
271 
272  // 2nd: Draw a position from the selected Gaussian:
273  CVectorDouble vec;
274  getRandomGenerator().drawGaussianMultivariate(vec, selMode->cov);
275 
276  ASSERT_(vec.size() == 3);
277  outSample.x(selMode->mean.x() + vec[0]);
278  outSample.y(selMode->mean.y() + vec[1]);
279  outSample.z(selMode->mean.z() + vec[2]);
280 
281  MRPT_END
282 }
283 
284 /*---------------------------------------------------------------
285  bayesianFusion
286  ---------------------------------------------------------------*/
288  const CPointPDF& p1_, const CPointPDF& p2_,
289  const double& minMahalanobisDistToDrop)
290 {
291  MRPT_START
292 
293  // p1: CPointPDFSOG, p2: CPosePDFGaussian:
294 
297 
298  const CPointPDFSOG* p1 = static_cast<const CPointPDFSOG*>(&p1_);
299  const CPointPDFSOG* p2 = static_cast<const CPointPDFSOG*>(&p2_);
300 
301  // Compute the new kernel means, covariances, and weights after multiplying
302  // to the Gaussian "p2":
303  CPointPDFGaussian auxGaussianProduct, auxSOG_Kernel_i;
304 
305  float minMahalanobisDistToDrop2 = square(minMahalanobisDistToDrop);
306 
307  this->m_modes.clear();
308  bool is2D =
309  false; // to detect & avoid errors in 3x3 matrix inversions of range=2.
310 
311  for (CListGaussianModes::const_iterator it1 = p1->m_modes.begin();
312  it1 != p1->m_modes.end(); ++it1)
313  {
314  CMatrixDouble33 c = it1->val.cov;
315 
316  // Is a 2D covariance??
317  if (c.get_unsafe(2, 2) == 0)
318  {
319  is2D = true;
320  c.set_unsafe(2, 2, 1);
321  }
322 
323  ASSERT_(c(0, 0) != 0 && c(0, 0) != 0)
324 
326  c.inv(covInv);
327 
328  CMatrixDouble31 eta = covInv * CMatrixDouble31(it1->val.mean);
329 
330  // Normal distribution canonical form constant:
331  // See: http://www-static.cc.gatech.edu/~wujx/paper/Gaussian.pdf
332  double a = -0.5 * (3 * log(M_2PI) - log(covInv.det()) +
333  eta.multiply_HtCH_scalar(
334  c)); // (~eta * (*it1).val.cov * eta)(0,0) );
335 
336  for (CListGaussianModes::const_iterator it2 = p2->m_modes.begin();
337  it2 != p2->m_modes.end(); ++it2)
338  {
339  auxSOG_Kernel_i = (*it2).val;
340  if (auxSOG_Kernel_i.cov.get_unsafe(2, 2) == 0)
341  {
342  auxSOG_Kernel_i.cov.set_unsafe(2, 2, 1);
343  is2D = true;
344  }
345  ASSERT_(
346  auxSOG_Kernel_i.cov(0, 0) > 0 && auxSOG_Kernel_i.cov(1, 1) > 0)
347 
348  // Should we drop this product term??
349  bool reallyComputeThisOne = true;
350  if (minMahalanobisDistToDrop > 0)
351  {
352  // Approximate (fast) mahalanobis distance (square):
353  float mahaDist2;
354 
355  float stdX2 =
356  max(auxSOG_Kernel_i.cov.get_unsafe(0, 0),
357  (*it1).val.cov.get_unsafe(0, 0));
358  mahaDist2 =
359  square(auxSOG_Kernel_i.mean.x() - (*it1).val.mean.x()) /
360  stdX2;
361 
362  float stdY2 =
363  max(auxSOG_Kernel_i.cov.get_unsafe(1, 1),
364  (*it1).val.cov.get_unsafe(1, 1));
365  mahaDist2 +=
366  square(auxSOG_Kernel_i.mean.y() - (*it1).val.mean.y()) /
367  stdY2;
368 
369  if (!is2D)
370  {
371  float stdZ2 =
372  max(auxSOG_Kernel_i.cov.get_unsafe(2, 2),
373  (*it1).val.cov.get_unsafe(2, 2));
374  mahaDist2 +=
375  square(auxSOG_Kernel_i.mean.z() - (*it1).val.mean.z()) /
376  stdZ2;
377  }
378 
379  reallyComputeThisOne = mahaDist2 < minMahalanobisDistToDrop2;
380  }
381 
382  if (reallyComputeThisOne)
383  {
384  auxGaussianProduct.bayesianFusion(auxSOG_Kernel_i, (*it1).val);
385 
386  // ----------------------------------------------------------------------
387  // The new weight is given by:
388  //
389  // w'_i = w_i * exp( a + a_i - a' )
390  //
391  // a = -1/2 ( dimensionality * log(2pi) - log(det(Cov^-1))
392  // + (Cov^-1 * mu)^t * Cov^-1 * (Cov^-1 * mu) )
393  //
394  // ----------------------------------------------------------------------
395  TGaussianMode newKernel;
396 
397  newKernel.val = auxGaussianProduct; // Copy mean & cov
398 
399  CMatrixDouble33 covInv_i = auxSOG_Kernel_i.cov.inv();
400  CMatrixDouble31 eta_i = CMatrixDouble31(auxSOG_Kernel_i.mean);
401  eta_i = covInv_i * eta_i;
402 
403  CMatrixDouble33 new_covInv_i = newKernel.val.cov.inv();
404  CMatrixDouble31 new_eta_i = CMatrixDouble31(newKernel.val.mean);
405  new_eta_i = new_covInv_i * new_eta_i;
406 
407  double a_i =
408  -0.5 *
409  (3 * log(M_2PI) - log(new_covInv_i.det()) +
410  (eta_i.adjoint() * auxSOG_Kernel_i.cov * eta_i)(0, 0));
411  double new_a_i =
412  -0.5 * (3 * log(M_2PI) - log(new_covInv_i.det()) +
413  (new_eta_i.adjoint() * newKernel.val.cov *
414  new_eta_i)(0, 0));
415 
416  newKernel.log_w =
417  (it1)->log_w + (it2)->log_w + a + a_i - new_a_i;
418 
419  // Fix 2D case:
420  if (is2D) newKernel.val.cov(2, 2) = 0;
421 
422  // Add to the results (in "this") the new kernel:
423  this->m_modes.push_back(newKernel);
424  } // end if reallyComputeThisOne
425  } // end for it2
426 
427  } // end for it1
428 
429  normalizeWeights();
430 
431  MRPT_END
432 }
433 
434 /*---------------------------------------------------------------
435  assureSymmetry
436  ---------------------------------------------------------------*/
438 {
439  MRPT_START
440  // Differences, when they exist, appear in the ~15'th significant
441  // digit, so... just take one of them arbitrarily!
442  for (CListGaussianModes::iterator it = m_modes.begin(); it != m_modes.end();
443  ++it)
444  {
445  it->val.cov(0, 1) = it->val.cov(1, 0);
446  it->val.cov(0, 2) = it->val.cov(2, 0);
447  it->val.cov(1, 2) = it->val.cov(2, 1);
448  }
449 
450  MRPT_END
451 }
452 
453 /*---------------------------------------------------------------
454  normalizeWeights
455  ---------------------------------------------------------------*/
457 {
458  MRPT_START
459 
460  if (!m_modes.size()) return;
461 
463  double maxW = m_modes[0].log_w;
464  for (it = m_modes.begin(); it != m_modes.end(); ++it)
465  maxW = max(maxW, it->log_w);
466 
467  for (it = m_modes.begin(); it != m_modes.end(); ++it) it->log_w -= maxW;
468 
469  MRPT_END
470 }
471 
472 /*---------------------------------------------------------------
473  ESS
474  ---------------------------------------------------------------*/
475 double CPointPDFSOG::ESS() const
476 {
477  MRPT_START
479  double cum = 0;
480 
481  /* Sum of weights: */
482  double sumLinearWeights = 0;
483  for (it = m_modes.begin(); it != m_modes.end(); ++it)
484  sumLinearWeights += exp(it->log_w);
485 
486  /* Compute ESS: */
487  for (it = m_modes.begin(); it != m_modes.end(); ++it)
488  cum += square(exp(it->log_w) / sumLinearWeights);
489 
490  if (cum == 0)
491  return 0;
492  else
493  return 1.0 / (m_modes.size() * cum);
494  MRPT_END
495 }
496 
497 /*---------------------------------------------------------------
498  evaluatePDFInArea
499  ---------------------------------------------------------------*/
501  float x_min, float x_max, float y_min, float y_max, float resolutionXY,
502  float z, CMatrixD& outMatrix, bool sumOverAllZs)
503 {
504  MRPT_START
505 
506  ASSERT_(x_max > x_min);
507  ASSERT_(y_max > y_min);
508  ASSERT_(resolutionXY > 0);
509 
510  const size_t Nx = (size_t)ceil((x_max - x_min) / resolutionXY);
511  const size_t Ny = (size_t)ceil((y_max - y_min) / resolutionXY);
512  outMatrix.setSize(Ny, Nx);
513 
514  for (size_t i = 0; i < Ny; i++)
515  {
516  const float y = y_min + i * resolutionXY;
517  for (size_t j = 0; j < Nx; j++)
518  {
519  float x = x_min + j * resolutionXY;
520  outMatrix(i, j) = evaluatePDF(CPoint3D(x, y, z), sumOverAllZs);
521  }
522  }
523 
524  MRPT_END
525 }
526 
527 /*---------------------------------------------------------------
528  evaluatePDF
529  ---------------------------------------------------------------*/
530 double CPointPDFSOG::evaluatePDF(const CPoint3D& x, bool sumOverAllZs) const
531 {
532  if (!sumOverAllZs)
533  {
534  // Normal evaluation:
536  double ret = 0;
537 
538  CMatrixDouble31 MU;
539 
540  for (CListGaussianModes::const_iterator it = m_modes.begin();
541  it != m_modes.end(); ++it)
542  {
543  MU = CMatrixDouble31(it->val.mean);
544  ret += exp(it->log_w) * math::normalPDF(X, MU, it->val.cov);
545  }
546 
547  return ret;
548  }
549  else
550  {
551  // Only X,Y:
552  CMatrixD X(2, 1), MU(2, 1), COV(2, 2);
553  double ret = 0;
554 
555  X(0, 0) = x.x();
556  X(1, 0) = x.y();
557 
558  for (CListGaussianModes::const_iterator it = m_modes.begin();
559  it != m_modes.end(); ++it)
560  {
561  MU(0, 0) = it->val.mean.x();
562  MU(1, 0) = it->val.mean.y();
563 
564  COV(0, 0) = it->val.cov(0, 0);
565  COV(1, 1) = it->val.cov(1, 1);
566  COV(0, 1) = COV(1, 0) = it->val.cov(0, 1);
567 
568  ret += exp(it->log_w) * math::normalPDF(X, MU, COV);
569  }
570 
571  return ret;
572  }
573 }
574 
575 /*---------------------------------------------------------------
576  getMostLikelyMode
577  ---------------------------------------------------------------*/
579 {
580  if (this->empty())
581  {
582  outVal = CPointPDFGaussian();
583  }
584  else
585  {
586  const_iterator it_best = m_modes.end();
587  for (const_iterator it = m_modes.begin(); it != m_modes.end(); ++it)
588  if (it_best == m_modes.end() || it->log_w > it_best->log_w)
589  it_best = it;
590 
591  outVal = it_best->val;
592  }
593 }
594 
595 /*---------------------------------------------------------------
596  getAs3DObject
597  ---------------------------------------------------------------*/
598 // void CPointPDFSOG::getAs3DObject( mrpt::opengl::CSetOfObjects::Ptr &outObj
599 // )
600 // const
601 //{
602 // // For each gaussian node
603 // for (CListGaussianModes::const_iterator it = m_modes.begin(); it!=
604 // m_modes.end();++it)
605 // {
606 // opengl::CEllipsoid::Ptr obj =
607 // mrpt::make_aligned_shared<opengl::CEllipsoid>();
608 //
609 // obj->setPose( it->val.mean);
610 // obj->setCovMatrix(it->val.cov, it->val.cov(2,2)==0 ? 2:3);
611 //
612 // obj->setQuantiles(3);
613 // obj->enableDrawSolid3D(false);
614 // obj->setColor(1,0,0, 0.5);
615 //
616 // outObj->insert( obj );
617 // } // end for each gaussian node
618 //}
A namespace of pseudo-random numbers genrators of diferent distributions.
void writeToStream(mrpt::utils::CStream &out, int *getVersion) const override
Introduces a pure virtual method responsible for writing to a CStream.
double x() const
Common members of all points & poses classes.
Definition: CPoseOrPoint.h:135
EIGEN_STRONG_INLINE bool empty() const
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
GLdouble GLdouble z
Definition: glext.h:3872
This class is a "CSerializable" wrapper for "CMatrixTemplateNumeric<double>".
Definition: CMatrixD.h:25
This namespace provides a OS-independent interface to many useful functions: filenames manipulation...
Definition: math_frwds.h:30
void getMean(CPoint3D &mean_point) const override
Returns an estimate of the point, (the mean, or mathematical expectation of the PDF) ...
int void fclose(FILE *f)
An OS-independent version of fclose.
Definition: os.cpp:272
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
CPoint3D mean
The mean value.
The namespace for Bayesian filtering algorithm: different particle filters and Kalman filter algorith...
void resize(const size_t N)
Resize the number of SOG modes.
Declares a class that represents a Probability Density function (PDF) of a 3D point ...
Definition: CPointPDFSOG.h:36
The struct for each mode:
Definition: CPointPDFSOG.h:43
Scalar * iterator
Definition: eigen_plugins.h:26
Column vector, like Eigen::MatrixX*, but automatically initialized to zeros since construction...
Definition: eigen_frwds.h:42
void clear()
Clear all the gaussian modes.
void drawSingleSample(CPoint3D &outSample) const override
Draw a sample from the pdf.
STL namespace.
const Scalar * const_iterator
Definition: eigen_plugins.h:27
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:4178
#define M_2PI
Definition: mrpt_macros.h:437
T square(const T x)
Inline function for the square of a number.
Definition: bits.h:55
virtual const mrpt::utils::TRuntimeClassId * GetRuntimeClass() const override
Returns information about the class of an object in runtime.
void bayesianFusion(const CPointPDFGaussian &p1, const CPointPDFGaussian &p2)
Bayesian fusion of two points gauss.
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:41
This base provides a set of functions for maths stuff.
Definition: CArrayNumeric.h:19
#define CLASS_ID(T)
Access to runtime class ID for a defined class name.
Definition: CObject.h:85
#define MRPT_END
const GLubyte * c
Definition: glext.h:6313
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
mrpt::math::CMatrixDouble33 cov
The 3x3 covariance matrix.
std::deque< TGaussianMode >::const_iterator const_iterator
Definition: CPointPDFSOG.h:54
int val
Definition: mrpt_jpeglib.h:955
void normalizeWeights()
Normalize the weights in m_modes such as the maximum log-weight is 0.
void getCovarianceAndMean(mrpt::math::CMatrixDouble33 &cov, CPoint3D &mean_point) const override
Returns an estimate of the point covariance matrix (3x3 cov matrix) and the mean, both at once...
GLsizei const GLchar ** string
Definition: glext.h:4101
A class used to store a 3D point.
Definition: CPoint3D.h:32
Declares a class that represents a probability density function (pdf) of a 2D pose (x...
Definition: CPosePDF.h:41
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
Definition: CPoint.h:17
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...
int fprintf(FILE *fil, const char *format,...) noexcept MRPT_printf_format_check(2
An OS-independent version of fprintf.
Definition: os.cpp:405
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"...
#define MRPT_START
void changeCoordinatesReference(const CPose3D &newReferenceBase) override
this = p (+) this.
void copyFrom(const CPointPDF &o) override
Copy operator, translating if necesary (for example, between particles and gaussian representations) ...
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:88
double ESS() const
Computes the "Effective sample size" (typical measure for Particle Filters), applied to the weights o...
void bayesianFusion(const CPointPDF &p1, const CPointPDF &p2, const double &minMahalanobisDistToDrop=0) override
Bayesian fusion of two point distributions (product of two distributions->new distribution), then save the result in this object (WARNING: See implementing classes to see classes that can and cannot be mixtured!)
GLuint in
Definition: glext.h:7274
#define ASSERT_(f)
void evaluatePDFInArea(float x_min, float x_max, float y_min, float y_max, float resolutionXY, float z, mrpt::math::CMatrixD &outMatrix, bool sumOverAllZs=false)
Evaluates the PDF within a rectangular grid and saves the result in a matrix (each row contains value...
GLenum GLint GLint y
Definition: glext.h:3538
void getMostLikelyMode(CPointPDFGaussian &outVal) const
Return the Gaussian mode with the highest likelihood (or an empty Gaussian if there are no modes in t...
FILE * fopen(const char *fileName, const char *mode) noexcept
An OS-independent version of fopen.
Definition: os.cpp:254
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...
void drawGaussianMultivariate(std::vector< T > &out_result, const mrpt::math::CMatrixTemplateNumeric< T > &cov, const std::vector< T > *mean=nullptr)
Generate multidimensional random samples according to a given covariance matrix.
GLenum GLint x
Definition: glext.h:3538
unsigned __int32 uint32_t
Definition: rptypes.h:47
CRandomGenerator & getRandomGenerator()
A static instance of a CRandomGenerator class, for use in single-thread applications.
Declares a class that represents a Probability Distribution function (PDF) of a 3D point (x...
Definition: CPointPDF.h:39
double normalPDF(double x, double mu, double std)
Evaluates the univariate normal (Gaussian) distribution at a given point "x".
Definition: math.cpp:989
GLubyte GLubyte GLubyte a
Definition: glext.h:6279
GLfloat GLfloat p
Definition: glext.h:6305
double evaluatePDF(const CPoint3D &x, bool sumOverAllZs) const
Evaluates the PDF at a given point.
CListGaussianModes m_modes
The list of SOG modes.
Definition: CPointPDFSOG.h:64
A gaussian distribution for 3D points.
CMatrixFixedNumeric< double, 3, 1 > CMatrixDouble31
Definition: eigen_frwds.h:60
void assureSymmetry()
Assures the symmetry of the covariance matrix (eventually certain operations in the math-coprocessor ...



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019