Main MRPT website > C++ reference for MRPT 1.9.9
CPose3DPDFGaussian.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 
12 #include <mrpt/random.h>
17 #include <mrpt/math/wrap2pi.h>
18 #include <mrpt/system/os.h>
19 #include <mrpt/utils/CStream.h>
20 
21 #include <sstream>
22 
23 using namespace mrpt;
24 using namespace mrpt::poses;
25 using namespace mrpt::math;
26 using namespace mrpt::random;
27 using namespace mrpt::utils;
28 using namespace mrpt::system;
29 using namespace std;
30 
32 
34 {
36 }
38 {
40 }
41 
42 
44 
45 /*---------------------------------------------------------------
46  Constructor
47  ---------------------------------------------------------------*/
49 /*---------------------------------------------------------------
50  Constructor
51  ---------------------------------------------------------------*/
53  TConstructorFlags_Poses constructor_dummy_param)
55 {
56  MRPT_UNUSED_PARAM(constructor_dummy_param);
57 }
58 
59 /*---------------------------------------------------------------
60  Constructor
61  ---------------------------------------------------------------*/
63  const CPose3D& init_Mean, const CMatrixDouble66& init_Cov)
64  : mean(init_Mean), cov(init_Cov)
65 {
66 }
67 
68 /*---------------------------------------------------------------
69  Copy Constructor from 2D PDF
70  ---------------------------------------------------------------*/
72  : mean(o.mean.x(), o.mean.y(), 0, o.mean.phi(), 0, 0), cov()
73 {
74  for (size_t i = 0; i < 3; i++)
75  {
76  const size_t ii = (i == 2) ? 3 : i;
77  for (size_t j = 0; j < 3; j++)
78  {
79  const size_t jj = (j == 2) ? 3 : j;
80  cov(ii, jj) = o.cov(i, j);
81  }
82  }
83 }
84 
85 /*---------------------------------------------------------------
86  Constructor
87  ---------------------------------------------------------------*/
89  : mean(init_Mean), cov()
90 {
91 }
92 
93 //#define DO_TEST_JACOB
94 
95 #ifdef DO_TEST_JACOB
96 void ffff(
97  const CVectorDouble& x, const CQuaternionDouble& Q, CVectorDouble& OUT)
98 {
99  OUT.resize(3);
100  CQuaternionDouble q(x[0], x[1], x[2], x[3]);
101  q.normalize();
102  q.rpy(OUT[2], OUT[1], OUT[0]);
103 }
104 #endif
105 
107  const CArrayDouble<7>& x, const double& dummy, CArrayDouble<6>& y)
108 {
109  MRPT_UNUSED_PARAM(dummy);
110  y[0] = x[0];
111  y[1] = x[1];
112  y[2] = x[2];
113  CQuaternionDouble q(x[3], x[4], x[5], x[6]);
114  q.normalize();
115  q.rpy(y[5], y[4], y[3]);
116 }
117 
118 /*---------------------------------------------------------------
119  CPose3DPDFGaussian
120  ---------------------------------------------------------------*/
123 {
124  this->copyFrom(o);
125 }
126 
127 /*---------------------------------------------------------------
128  asString
129  ---------------------------------------------------------------*/
131 {
132  ostringstream ss;
133  ss << *this;
134  s = ss.str();
135 }
136 
137 /*---------------------------------------------------------------
138  copyFrom
139  ---------------------------------------------------------------*/
141 {
142  MRPT_START
144  {
145 // Convert using Jacobians and first order approximation:
146 
147 // [ I_3 | 0 ]
148 // dr_dq = [ -------+------------- ]
149 // [ 0 | dr_dq_angles ]
150 #ifdef DO_TEST_JACOB
151  // Test Jacob:
152  {
153  CVectorDouble x(4);
154  for (int i = 0; i < 4; i++) x[i] = o.mean.quat()[i];
155  CVectorDouble Ax(4);
156  Ax.assign(1e-7);
157  CMatrixDouble H;
158  jacobians::jacob_numeric_estimate(x, ffff, Ax, o.mean.quat(), H);
159  cout << "num:" << endl << H << endl << endl;
160  CMatrixDouble J;
161  double a, b, c;
162  o.mean.quat().rpy_and_jacobian(a, b, c, &J);
163  CMatrixDouble NJ;
165  cout << "lin:" << endl << J * NJ << endl << endl;
166  }
167 #endif
168 
169  double yaw, pitch, roll;
171 
172  o.mean.quat().rpy_and_jacobian(roll, pitch, yaw, &dr_dq_sub_aux, false);
173 
175  o.mean.quat().normalizationJacobian(dnorm_dq);
176 
178  dr_dq_sub.multiply(dr_dq_sub_aux, dnorm_dq);
179 
180  // Set the mean:
181  this->mean.setFromValues(
182  o.mean.x(), o.mean.y(), o.mean.z(), yaw, pitch, roll);
183 
184  // Cov:
188  o.cov.extractMatrix(3, 3, cov_Q);
189  o.cov.extractMatrix(0, 0, cov_T);
190  o.cov.extractMatrix(0, 3, cov_TQ);
191 
192  // [ S_T | S_TQ * H^t ]
193  // [ -----------------+---------------- ]
194  // [ (S_TQ * H^t)^t | H * S_Q * H^t ]
195 
196  // top-left:
197  this->cov.insertMatrix(0, 0, cov_T);
198 
199  // diagonals:
201  cov_TR.multiply_ABt(cov_TQ, dr_dq_sub);
202  this->cov.insertMatrix(0, 3, cov_TR);
203  this->cov.insertMatrixTranspose(3, 0, cov_TR);
204 
205  // bottom-right:
207  dr_dq_sub.multiply_HCHt(cov_Q, cov_r);
208  this->cov.insertMatrix(3, 3, cov_r);
209  }
210  else
211  {
212  // Use UT transformation:
213  // f: R^7 => R^6
214  const CArrayDouble<7> x_mean(o.mean);
215  CArrayDouble<6> y_mean;
216  static const bool elements_do_wrapPI[6] = {
217  false, false, false, true, true, true}; // xyz yaw pitch roll
218 
219  static const double dummy = 0;
221  x_mean, o.cov, aux_posequat2poseypr, dummy, y_mean, this->cov,
222  elements_do_wrapPI);
223  this->mean.setFromValues(
224  y_mean[0], y_mean[1], y_mean[2], y_mean[3], y_mean[4], y_mean[5]);
225  }
226  MRPT_END
227 }
228 
229 /*---------------------------------------------------------------
230  writeToStream
231  ---------------------------------------------------------------*/
233  mrpt::utils::CStream& out, int* version) const
234 {
235  if (version)
236  *version = 1;
237  else
238  {
239  out << mean;
240  for (size_t r = 0; r < size(cov, 1); r++) out << cov.get_unsafe(r, r);
241  for (size_t r = 0; r < size(cov, 1); r++)
242  for (size_t c = r + 1; c < size(cov, 2); c++)
243  out << cov.get_unsafe(r, c);
244  }
245 }
246 
247 /*---------------------------------------------------------------
248  readFromStream
249  ---------------------------------------------------------------*/
251 {
252  switch (version)
253  {
254  case 0:
255  {
256  in >> mean;
257 
258  for (size_t r = 0; r < size(cov, 1); r++)
259  in >> cov.get_unsafe(r, r);
260  for (size_t r = 0; r < size(cov, 1); r++)
261  for (size_t c = r + 1; c < size(cov, 2); c++)
262  {
263  float x;
264  in >> x;
265  cov.get_unsafe(r, c) = cov.get_unsafe(c, r) = x;
266  }
267  }
268  break;
269  case 1:
270  {
271  in >> mean;
272 
273  for (size_t r = 0; r < size(cov, 1); r++)
274  in >> cov.get_unsafe(r, r);
275  for (size_t r = 0; r < size(cov, 1); r++)
276  for (size_t c = r + 1; c < size(cov, 2); c++)
277  {
278  double x;
279  in >> x;
280  cov.get_unsafe(r, c) = cov.get_unsafe(c, r) = x;
281  }
282  }
283  break;
284  default:
286  };
287 }
288 
290 {
291  if (this == &o) return; // It may be used sometimes
292 
293  // Convert to gaussian pdf:
295 }
296 
298 {
299  // Convert to gaussian pdf:
300  CMatrixDouble33 C;
301  CPose2D p;
302  o.getCovarianceAndMean(C, p);
303  mean = CPose3D(p);
304 
305  cov.zeros();
306  cov.get_unsafe(0, 0) = C.get_unsafe(0, 0);
307  cov.get_unsafe(1, 1) = C.get_unsafe(1, 1);
308  cov.get_unsafe(3, 3) = C.get_unsafe(2, 2);
309 
310  cov.get_unsafe(0, 1) = cov.get_unsafe(1, 0) = C.get_unsafe(0, 1);
311 
312  cov.get_unsafe(0, 3) = cov.get_unsafe(3, 0) = C.get_unsafe(0, 2);
313 
314  cov.get_unsafe(1, 3) = cov.get_unsafe(3, 1) = C.get_unsafe(1, 2);
315 }
316 
317 /*---------------------------------------------------------------
318 
319  ---------------------------------------------------------------*/
320 void CPose3DPDFGaussian::saveToTextFile(const string& file) const
321 {
322  FILE* f = os::fopen(file.c_str(), "wt");
323  if (!f) return;
324 
325  os::fprintf(
326  f, "%e %e %e %e %e %e\n", mean.x(), mean.y(), mean.z(), mean.yaw(),
327  mean.pitch(), mean.roll());
328 
329  for (unsigned int i = 0; i < 6; i++)
330  os::fprintf(
331  f, "%e %e %e %e %e %e\n", cov(i, 0), cov(i, 1), cov(i, 2),
332  cov(i, 3), cov(i, 4), cov(i, 5));
333 
334  os::fclose(f);
335 }
336 
337 /*---------------------------------------------------------------
338  changeCoordinatesReference
339  ---------------------------------------------------------------*/
341  const CPose3D& newReferenceBase)
342 {
343  MRPT_START
344  // this = p (+) this
345 
346  // COV:
347  const CMatrixDouble66 OLD_COV = this->cov;
349 
351  newReferenceBase, // x
352  this->mean, // u
353  df_dx, df_du);
354 
355  // this->cov = H1*this->cov*~H1 + H2* 0 *~H2;
356  df_du.multiply_HCHt(OLD_COV, cov);
357 
358  // MEAN:
359  this->mean.composeFrom(newReferenceBase, this->mean);
360 
361  MRPT_END
362 }
363 
364 /*---------------------------------------------------------------
365  drawSingleSample
366  ---------------------------------------------------------------*/
368 {
369  MRPT_START
370 
373 
374  outPart.setFromValues(
375  mean.x() + v[0], mean.y() + v[1], mean.z() + v[2], mean.yaw() + v[3],
376  mean.pitch() + v[4], mean.roll() + v[5]);
377 
379  cov.saveToTextFile("__DEBUG_EXC_DUMP_drawSingleSample_COV.txt"););
380 }
381 
382 /*---------------------------------------------------------------
383  drawManySamples
384  ---------------------------------------------------------------*/
386  size_t N, vector<CVectorDouble>& outSamples) const
387 {
388  MRPT_START
389 
391 
392  for (vector<CVectorDouble>::iterator it = outSamples.begin();
393  it != outSamples.end(); ++it)
394  {
395  (*it)[0] += mean.x();
396  (*it)[1] += mean.y();
397  (*it)[2] += mean.z();
398  (*it)[3] = math::wrapToPi((*it)[3] + mean.yaw());
399  (*it)[4] = math::wrapToPi((*it)[4] + mean.pitch());
400  (*it)[5] = math::wrapToPi((*it)[5] + mean.roll());
401  }
402 
403  MRPT_END
404 }
405 
406 /*---------------------------------------------------------------
407  bayesianFusion
408  ---------------------------------------------------------------*/
410  const CPose3DPDF& p1_, const CPose3DPDF& p2_)
411 {
412  MRPT_UNUSED_PARAM(p1_);
413  MRPT_UNUSED_PARAM(p2_);
414  MRPT_START
415 
416  THROW_EXCEPTION("TO DO!!!");
417 
418  /* ASSERT_( p1_.GetRuntimeClass() == CLASS_ID( CPose3DPDFGaussian ) );
419  ASSERT_( p2_.GetRuntimeClass() == CLASS_ID( CPose3DPDFGaussian ) );
420 
421  CPose3DPDFGaussian *p1 = (CPose3DPDFGaussian*) &p1_;
422  CPose3DPDFGaussian *p2 = (CPose3DPDFGaussian*) &p2_;
423 
424 
425  CMatrixD x1(3,1),x2(3,1),x(3,1);
426  CMatrixD C1( p1->cov );
427  CMatrixD C2( p2->cov );
428  CMatrixD C1_inv = C1.inv();
429  CMatrixD C2_inv = C2.inv();
430  CMatrixD C;
431 
432  x1(0,0) = p1->mean.x; x1(1,0) = p1->mean.y; x1(2,0) = p1->mean.phi;
433  x2(0,0) = p2->mean.x; x2(1,0) = p2->mean.y; x2(2,0) = p2->mean.phi;
434 
435  C = !(C1_inv + C2_inv);
436 
437  this->cov = C;
438  this->assureSymmetry();
439 
440  x = C * ( C1_inv*x1 + C2_inv*x2 );
441 
442  this->mean.x = x(0,0);
443  this->mean.y = x(1,0);
444  this->mean.phi = x(2,0);
445  this->mean.normalizePhi();
446  */
447  MRPT_END
448 }
449 
450 /*---------------------------------------------------------------
451  inverse
452  ---------------------------------------------------------------*/
454 {
456  CPose3DPDFGaussian& out = static_cast<CPose3DPDFGaussian&>(o);
457 
458  // This is like: b=(0,0,0)
459  // OUT = b - THIS
460  CPose3DPDFGaussian p_zero(
461  CPose3D(0, 0, 0, 0, 0, 0), CMatrixDouble66()); // COV=All zeros
462 
463  out = p_zero - *this;
464 }
465 
466 /*---------------------------------------------------------------
467  +=
468  ---------------------------------------------------------------*/
470 {
471  // COV:
472  const CMatrixDouble66 OLD_COV = this->cov;
474 
476  this->mean, // x
477  Ap, // u
478  df_dx, df_du);
479 
480  // this->cov = H1*this->cov*~H1 + H2*Ap.cov*~H2;
481  df_dx.multiply_HCHt(OLD_COV, cov);
482  // df_du: Nothing to do, since COV(Ap) = zeros
483 
484  // MEAN:
485  this->mean.composeFrom(this->mean, Ap);
486 }
487 
488 /*---------------------------------------------------------------
489  +=
490  ---------------------------------------------------------------*/
492 {
493  // Direct equations (for the covariances) in yaw-pitch-roll are too complex.
494  // Make a way around them and consider instead this path:
495  //
496  // X(6D) U(6D)
497  // | |
498  // v v
499  // X(7D) U(7D)
500  // | |
501  // +--- (+) ---+
502  // |
503  // v
504  // RES(7D)
505  // |
506  // v
507  // RES(6D)
508  //
509  CPose3DQuatPDFGaussian X7(*this);
510  const CPose3DQuatPDFGaussian U7(Ap);
511 
512  X7 += U7;
513 
514  this->copyFrom(X7);
515 }
516 
517 /*---------------------------------------------------------------
518  -=
519  ---------------------------------------------------------------*/
521 {
522  // Direct equations (for the covariances) in yaw-pitch-roll are too complex.
523  // Make a way around them and consider instead this path:
524  //
525  // X(6D) U(6D)
526  // | |
527  // v v
528  // X(7D) U(7D)
529  // | |
530  // +--- (-) ---+
531  // |
532  // v
533  // RES(7D)
534  // |
535  // v
536  // RES(6D)
537  //
538  CPose3DQuatPDFGaussian X7(*this);
539  const CPose3DQuatPDFGaussian U7(Ap);
540 
541  X7 -= U7;
542 
543  this->copyFrom(X7);
544 }
545 
546 /*---------------------------------------------------------------
547  evaluatePDF
548  ---------------------------------------------------------------*/
550 {
552  THROW_EXCEPTION("TO DO!!!");
553 
554  /* CMatrixD X(6,1);
555  X(0,0) = x.x;
556  X(1,0) = x.y;
557  X(2,0) = x.z;
558 
559  CMatrixD MU(6,1);
560  MU(0,0) = mean.x;
561  MU(1,0) = mean.y;
562  MU(2,0) = mean.z;
563 
564  return math::normalPDF( X, MU, this->cov );
565  */
566 }
567 
568 /*---------------------------------------------------------------
569  evaluateNormalizedPDF
570  ---------------------------------------------------------------*/
572 {
574  THROW_EXCEPTION("TO DO!!!");
575  /* CMatrixD X(3,1);
576  X(0,0) = x.x;
577  X(1,0) = x.y;
578  X(2,0) = x.phi;
579 
580  CMatrixD MU(3,1);
581  MU(0,0) = mean.x;
582  MU(1,0) = mean.y;
583  MU(2,0) = mean.phi;
584 
585  return math::normalPDF( X, MU, this->cov ) / math::normalPDF( MU, MU,
586  this->cov );
587  */
588 }
589 
590 /*---------------------------------------------------------------
591  assureSymmetry
592  ---------------------------------------------------------------*/
594 {
595  // Differences, when they exist, appear in the ~15'th significant
596  // digit, so... just take one of them arbitrarily!
597  for (unsigned int i = 0; i < size(cov, 1) - 1; i++)
598  for (unsigned int j = i + 1; j < size(cov, 1); j++)
599  cov.get_unsafe(i, j) = cov.get_unsafe(j, i);
600 }
601 
602 /*---------------------------------------------------------------
603  mahalanobisDistanceTo
604  ---------------------------------------------------------------*/
606  const CPose3DPDFGaussian& theOther)
607 {
608  MRPT_START
609 
610  CMatrixDouble66 COV_ = cov + theOther.cov;
612 
613  for (int i = 0; i < 6; i++)
614  {
615  if (COV_.get_unsafe(i, i) == 0)
616  {
617  if (MU.get_unsafe(i, 0) != 0)
618  return std::numeric_limits<double>::infinity();
619  else
620  COV_.get_unsafe(i, i) = 1; // Any arbitrary value since
621  // MU(i)=0, and this value doesn't
622  // affect the result.
623  }
624  }
625 
626  return std::sqrt(MU.multiply_HtCH_scalar(COV_.inv()));
627 
628  MRPT_END
629 }
630 
631 /*---------------------------------------------------------------
632  operator <<
633  ---------------------------------------------------------------*/
634 ostream& mrpt::poses::operator<<(ostream& out, const CPose3DPDFGaussian& obj)
635 {
636  out << "Mean: " << obj.mean << "\n";
637  out << "Covariance:\n" << obj.cov << "\n";
638 
639  return out;
640 }
641 
642 /*---------------------------------------------------------------
643  getCovSubmatrix2D
644  ---------------------------------------------------------------*/
646 {
647  out_cov.setSize(3, 3);
648 
649  for (int i = 0; i < 3; i++)
650  {
651  int a = i == 2 ? 3 : i;
652  for (int j = i; j < 3; j++)
653  {
654  int b = j == 2 ? 3 : j;
655  double f = cov.get_unsafe(a, b);
656  out_cov.set_unsafe(i, j, f);
657  out_cov.set_unsafe(j, i, f);
658  }
659  }
660 }
661 
663  const CPose3DPDFGaussian& p1, const CPose3DPDFGaussian& p2)
664 {
665  return p1.mean == p2.mean && p1.cov == p2.cov;
666 }
A namespace of pseudo-random numbers genrators of diferent distributions.
void rpy_and_jacobian(T &roll, T &pitch, T &yaw, MATRIXLIKE *out_dr_dq=nullptr, bool resize_out_dr_dq_to3x4=true) const
Return the yaw, pitch & roll angles associated to quaternion, and (optionally) the 3x4 Jacobian of th...
Definition: CQuaternion.h:411
mrpt::math::CQuaternionDouble & quat()
Read/Write access to the quaternion representing the 3D rotation.
Definition: CPose3DQuat.h:60
double x() const
Common members of all points & poses classes.
Definition: CPoseOrPoint.h:135
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
CPose3D mean
The mean value.
#define MRPT_END_WITH_CLEAN_UP(stuff)
This namespace provides a OS-independent interface to many useful functions: filenames manipulation...
Definition: math_frwds.h:30
void copyFrom(const CPose3DPDF &o) override
Copy operator, translating if necesary (for example, between particles and gaussian representations) ...
double mahalanobisDistanceTo(const CPose3DPDFGaussian &theOther)
Computes the Mahalanobis distance between the centers of two Gaussians.
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.
static void jacobiansPoseComposition(const CPose3D &x, const CPose3D &u, mrpt::math::CMatrixDouble66 &df_dx, mrpt::math::CMatrixDouble66 &df_du)
This static method computes the pose composition Jacobians.
Definition: CPose3DPDF.cpp:141
#define THROW_EXCEPTION(msg)
GLdouble GLdouble GLdouble GLdouble q
Definition: glext.h:3721
Scalar * iterator
Definition: eigen_plugins.h:26
Column vector, like Eigen::MatrixX*, but automatically initialized to zeros since construction...
Definition: eigen_frwds.h:42
mrpt::math::CMatrixDouble77 cov
The 7x7 covariance matrix.
double pitch() const
Get the PITCH angle (in radians)
Definition: CPose3D.h:539
double yaw() const
Get the YAW angle (in radians)
Definition: CPose3D.h:533
STL namespace.
void assureSymmetry()
Assures the symmetry of the covariance matrix (eventually certain operations in the math-coprocessor ...
GLdouble s
Definition: glext.h:3676
GLsizei GLsizei GLuint * obj
Definition: glext.h:4070
mrpt::math::CMatrixDouble33 cov
The 3x3 covariance matrix.
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...
Declares a class that represents a Probability Density function (PDF) of a 3D pose using a quaternion...
void jacob_numeric_estimate(const VECTORLIKE &x, std::function< void(const VECTORLIKE &x, const USERPARAM &y, VECTORLIKE3 &out)> functor, const VECTORLIKE2 &increments, const USERPARAM &userParam, MATRIXLIKE &out_Jacobian)
Numerical estimation of the Jacobian of a user-supplied function - this template redirects to mrpt::m...
Definition: jacobians.h:144
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...
Definition: CStream.h:41
A numeric matrix of compile-time fixed size.
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
Declares a class that represents a Probability Density function (PDF) of a 2D pose ...
void USE_SUT_QUAT2EULER_CONVERSION(bool value)
If set to true (false), a Scaled Unscented Transform is used instead of a linear approximation with J...
#define MRPT_END
void saveToTextFile(const std::string &file) const override
Save the PDF to a text file, containing the 3D pose in the first line, then the covariance matrix in ...
#define MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler.
void composeFrom(const CPose3D &A, const CPose3D &B)
Makes "this = A (+) B"; this method is slightly more efficient than "this= A + B;" since it avoids th...
Definition: CPose3D.cpp:639
const GLubyte * c
Definition: glext.h:6313
double evaluatePDF(const CPose3D &x) const
Evaluates the PDF at a given point.
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
void drawGaussianMultivariateMany(VECTOR_OF_VECTORS &ret, size_t desiredSamples, const COVMATRIX &cov, const typename VECTOR_OF_VECTORS::value_type *mean=nullptr)
Generate a given number of multidimensional random samples according to a given covariance matrix...
void inverse(CPose3DPDF &o) const override
Returns a new PDF such as: NEW_PDF = (0,0,0) - THIS_PDF.
void writeToStream(mrpt::utils::CStream &out, int *getVersion) const override
Introduces a pure virtual method responsible for writing to a CStream.
void operator+=(const CPose3D &Ap)
Makes: thisPDF = thisPDF + Ap, where "+" is pose composition (both the mean, and the covariance matri...
CPose3DPDFGaussian()
Default constructor.
GLubyte GLubyte b
Definition: glext.h:6279
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,phi) datum.
void transform_gaussian_unscented(const VECTORLIKE1 &x_mean, const MATLIKE1 &x_cov, void(*functor)(const VECTORLIKE1 &x, const USERPARAM &fixed_param, VECTORLIKE3 &y), const USERPARAM &fixed_param, VECTORLIKE2 &y_mean, MATLIKE2 &y_cov, const bool *elem_do_wrap2pi=nullptr, const double alpha=1e-3, const double K=0, const double beta=2.0)
Scaled unscented transformation (SUT) for estimating the Gaussian distribution of a variable Y=f(X) f...
GLsizei const GLchar ** string
Definition: glext.h:4101
T wrapToPi(T a)
Modifies the given angle to translate it into the ]-pi,pi] range.
Definition: wrap2pi.h:53
void bayesianFusion(const CPose3DPDF &p1, const CPose3DPDF &p2) override
Bayesian fusion of two points gauss.
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
double roll() const
Get the ROLL angle (in radians)
Definition: CPose3D.h:545
int fprintf(FILE *fil, const char *format,...) noexcept MRPT_printf_format_check(2
An OS-independent version of fprintf.
Definition: os.cpp:405
mrpt::math::CMatrixDouble66 cov
The 6x6 covariance matrix.
double evaluateNormalizedPDF(const CPose3D &x) const
Evaluates the ratio PDF(x) / PDF(MEAN), that is, the normalized PDF in the range [0,1].
void getCovSubmatrix2D(mrpt::math::CMatrixDouble &out_cov) const
Returns a 3x3 matrix with submatrix of the covariance for the variables (x,y,yaw) only...
#define MRPT_START
const GLdouble * v
Definition: glext.h:3678
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
GLdouble GLdouble GLdouble r
Definition: glext.h:3705
void normalizationJacobian(MATRIXLIKE &J) const
Calculate the 4x4 Jacobian of the normalization operation of this quaternion.
Definition: CQuaternion.h:283
bool operator==(const CPoint< DERIVEDCLASS > &p1, const CPoint< DERIVEDCLASS > &p2)
Definition: CPoint.h:163
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle...
Definition: CPose2D.h:40
void aux_posequat2poseypr(const CArrayDouble< 7 > &x, const double &dummy, CArrayDouble< 6 > &y)
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:88
void setFromValues(const double x0, const double y0, const double z0, const double yaw=0, const double pitch=0, const double roll=0)
Set the pose from a 3D position (meters) and yaw/pitch/roll angles (radians) - This method recomputes...
Definition: CPose3D.cpp:248
GLuint in
Definition: glext.h:7274
#define ASSERT_(f)
A partial specialization of CArrayNumeric for double numbers.
Definition: CArrayNumeric.h:87
Declares a class that represents a Probability Density function (PDF) of a 3D pose ...
void operator-=(const CPose3DPDFGaussian &Ap)
Makes: thisPDF = thisPDF - Ap, where "-" is pose inverse composition (both the mean, and the covariance matrix are updated).
GLenum GLint GLint y
Definition: glext.h:3538
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...
Eigen::Matrix< typename MATRIX::Scalar, MATRIX::ColsAtCompileTime, MATRIX::ColsAtCompileTime > cov(const MATRIX &v)
Computes the covariance matrix from a list of samples in an NxM matrix, where each row is a sample...
Definition: ops_matrices.h:148
GLsizei const GLfloat * value
Definition: glext.h:4117
GLsizeiptr size
Definition: glext.h:3923
void changeCoordinatesReference(const CPose3D &newReferenceBase) override
this = p (+) this.
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
A quaternion, which can represent a 3D rotation as pair , with a real part "r" and a 3D vector ...
Definition: CQuaternion.h:46
CRandomGenerator & getRandomGenerator()
A static instance of a CRandomGenerator class, for use in single-thread applications.
GLubyte GLubyte GLubyte a
Definition: glext.h:6279
GLfloat GLfloat p
Definition: glext.h:6305
void drawSingleSample(CPose3D &outPart) const override
Draws a single sample from the distribution.
Declares a class that represents a Probability Density Function (PDF) of a 3D pose (6D actually)...
Definition: CPose3DPDF.h:42
CMatrixFixedNumeric< double, 6, 6 > CMatrixDouble66
Definition: eigen_frwds.h:57
bool USE_SUT_QUAT2EULER_CONVERSION_value
EIGEN_STRONG_INLINE double mean() const
Computes the mean of the entire matrix.
CMatrixFixedNumeric< double, 6, 1 > CMatrixDouble61
Definition: eigen_frwds.h:63
std::ostream & operator<<(std::ostream &o, const CPoint< DERIVEDCLASS > &p)
Dumps a point as a string [x,y] or [x,y,z].
Definition: CPoint.h:137



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