MRPT  1.9.9
CPosePDFGaussianInf.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include "poses-precomp.h" // Precompiled headers
11 
12 #include <mrpt/math/TPose2D.h>
14 #include <mrpt/math/ops_matrices.h>
15 #include <mrpt/math/wrap2pi.h>
16 #include <mrpt/poses/CPose3D.h>
17 #include <mrpt/poses/CPose3DPDF.h>
21 #include <mrpt/random.h>
24 #include <mrpt/system/os.h>
25 #include <Eigen/Dense>
26 
27 using namespace mrpt;
28 using namespace mrpt::poses;
29 using namespace mrpt::math;
30 using namespace mrpt::random;
31 using namespace mrpt::system;
32 using namespace std;
33 
35 
36 /*---------------------------------------------------------------
37  Constructor
38  ---------------------------------------------------------------*/
39 CPosePDFGaussianInf::CPosePDFGaussianInf() : mean(0, 0, 0), cov_inv() {}
40 /*---------------------------------------------------------------
41  Constructor
42  ---------------------------------------------------------------*/
44  const CPose2D& init_Mean, const CMatrixDouble33& init_CovInv)
45  : mean(init_Mean), cov_inv(init_CovInv)
46 {
47 }
48 
49 /*---------------------------------------------------------------
50  Constructor
51  ---------------------------------------------------------------*/
53  : mean(init_Mean), cov_inv()
54 {
55 }
56 
57 uint8_t CPosePDFGaussianInf::serializeGetVersion() const { return 0; }
59 {
60  out << mean.x() << mean.y() << mean.phi();
61  out << cov_inv(0, 0) << cov_inv(1, 1) << cov_inv(2, 2);
62  out << cov_inv(0, 1) << cov_inv(0, 2) << cov_inv(1, 2);
63 }
65  mrpt::serialization::CArchive& in, uint8_t version)
66 {
67  switch (version)
68  {
69  case 0:
70  {
71  TPose2D p;
72  in >> p.x >> p.y >> p.phi;
73  mean = CPose2D(p);
74 
75  in >> cov_inv(0, 0) >> cov_inv(1, 1) >> cov_inv(2, 2);
76  in >> cov_inv(0, 1) >> cov_inv(0, 2) >> cov_inv(1, 2);
77  }
78  break;
79  default:
81  };
82 }
83 
86 {
88  out["mean"] = mean;
89  out["cov_inv"] = CMatrixD(cov_inv);
90 }
93 {
94  uint8_t version;
96  switch (version)
97  {
98  case 1:
99  {
100  in["mean"].readTo(mean);
101  CMatrixD m;
102  in["cov_inv"].readTo(m);
103  cov_inv = m;
104  }
105  break;
106  default:
108  }
109 }
110 
111 /*---------------------------------------------------------------
112  copyFrom
113  ---------------------------------------------------------------*/
115 {
116  if (this == &o) return; // It may be used sometimes
117 
119  { // It's my same class:
120  const auto* ptr = dynamic_cast<const CPosePDFGaussianInf*>(&o);
121  mean = ptr->mean;
122  cov_inv = ptr->cov_inv;
123  }
124  else
125  { // Convert to gaussian pdf:
126  o.getMean(mean);
127 
129  o.getCovariance(o_cov);
130  this->cov_inv = o_cov.inverse_LLt();
131  }
132 }
133 
134 /*---------------------------------------------------------------
135  copyFrom 3D
136  ---------------------------------------------------------------*/
138 {
139  // Convert to gaussian pdf:
140  mean = CPose2D(o.getMeanVal());
141 
143  { // Cov is already in information form:
144  const auto* ptr = dynamic_cast<const CPose3DPDFGaussianInf*>(&o);
145  cov_inv(0, 0) = ptr->cov_inv(0, 0);
146  cov_inv(1, 1) = ptr->cov_inv(1, 1);
147  cov_inv(2, 2) = ptr->cov_inv(3, 3);
148  cov_inv(0, 1) = cov_inv(1, 0) = ptr->cov_inv(0, 1);
149  cov_inv(0, 2) = cov_inv(2, 0) = ptr->cov_inv(0, 3);
150  cov_inv(1, 2) = cov_inv(2, 1) = ptr->cov_inv(1, 3);
151  }
152  else
153  {
155  o.getCovariance(C);
156 
157  // Clip to 3x3:
159  o_cov(0, 0) = C(0, 0);
160  o_cov(1, 1) = C(1, 1);
161  o_cov(2, 2) = C(3, 3);
162  o_cov(0, 1) = o_cov(1, 0) = C(0, 1);
163  o_cov(0, 2) = o_cov(2, 0) = C(0, 3);
164  o_cov(1, 2) = o_cov(2, 1) = C(1, 3);
165 
166  this->cov_inv = o_cov.inverse_LLt();
167  }
168 }
169 
170 /*---------------------------------------------------------------
171 
172  ---------------------------------------------------------------*/
173 bool CPosePDFGaussianInf::saveToTextFile(const std::string& file) const
174 {
175  FILE* f = os::fopen(file.c_str(), "wt");
176  if (!f) return false;
177 
178  os::fprintf(f, "%f %f %f\n", mean.x(), mean.y(), mean.phi());
179 
180  for (unsigned int i = 0; i < 3; i++)
181  os::fprintf(
182  f, "%f %f %f\n", cov_inv(i, 0), cov_inv(i, 1), cov_inv(i, 2));
183 
184  os::fclose(f);
185  return true;
186 }
187 
188 /*---------------------------------------------------------------
189  changeCoordinatesReference
190  ---------------------------------------------------------------*/
192  const CPose3D& newReferenceBase_)
193 {
194  const CPose2D newReferenceBase = CPose2D(newReferenceBase_);
195 
196  // The mean:
197  mean.composeFrom(newReferenceBase, mean);
198 
199  // The covariance:
200  rotateCov(newReferenceBase.phi());
201 }
202 
203 /*---------------------------------------------------------------
204  changeCoordinatesReference
205  ---------------------------------------------------------------*/
207  const CPose2D& newReferenceBase)
208 {
209  // The mean:
210  mean.composeFrom(newReferenceBase, mean);
211  // The covariance:
212  rotateCov(newReferenceBase.phi());
213 }
214 
215 /*---------------------------------------------------------------
216  changeCoordinatesReference
217  ---------------------------------------------------------------*/
218 void CPosePDFGaussianInf::rotateCov(const double ang)
219 {
220  const double ccos = cos(ang);
221  const double ssin = sin(ang);
222 
223  alignas(MRPT_MAX_STATIC_ALIGN_BYTES)
224  const double rot_vals[] = {ccos, -ssin, 0., ssin, ccos, 0., 0., 0., 1.};
225 
226  const CMatrixFixed<double, 3, 3> rot(rot_vals);
227 
228  // NEW_COV = H C H^T
229  // NEW_COV^(-1) = (H C H^T)^(-1) = (H^T)^(-1) C^(-1) H^(-1)
230  // rot: Inverse of a rotation matrix is its trasposed.
231  // But we need H^t^-1 -> H !! so rot stays unchanged:
232  cov_inv = rot.asEigen() * cov_inv.asEigen() * rot.asEigen().transpose();
233 }
234 
236 {
237  MRPT_START
238 
239  const CMatrixDouble33 cov = this->cov_inv.inverse_LLt();
240 
241  CVectorDouble v;
243 
244  outPart.x(mean.x() + v[0]);
245  outPart.y(mean.y() + v[1]);
246  outPart.phi(mean.phi() + v[2]);
247 
248  // Range -pi,pi
249  outPart.normalizePhi();
250 
252  "__DEBUG_EXC_DUMP_drawSingleSample_COV_INV.txt"););
253 }
254 
256  size_t N, std::vector<CVectorDouble>& outSamples) const
257 {
258  MRPT_START
259 
260  const CMatrixDouble33 cov = this->cov_inv.inverse_LLt();
261 
262  std::vector<CVectorDouble> rndSamples;
263 
265  outSamples.resize(N);
266  for (size_t i = 0; i < N; i++)
267  {
268  outSamples[i].resize(3);
269  outSamples[i][0] = mean.x() + rndSamples[i][0];
270  outSamples[i][1] = mean.y() + rndSamples[i][1];
271  outSamples[i][2] = mean.phi() + rndSamples[i][2];
272 
273  wrapToPiInPlace(outSamples[i][2]);
274  }
275 
276  MRPT_END
277 }
278 
279 /*---------------------------------------------------------------
280  bayesianFusion
281  ---------------------------------------------------------------*/
283  const CPosePDF& p1_, const CPosePDF& p2_,
284  const double minMahalanobisDistToDrop)
285 {
286  MRPT_START
287 
288  MRPT_UNUSED_PARAM(minMahalanobisDistToDrop); // Not used in this class!
289 
292 
293  const auto* p1 = dynamic_cast<const CPosePDFGaussianInf*>(&p1_);
294  const auto* p2 = dynamic_cast<const CPosePDFGaussianInf*>(&p2_);
295 
296  const CMatrixDouble33& C1_inv = p1->cov_inv;
297  const CMatrixDouble33& C2_inv = p2->cov_inv;
298 
299  auto x1 = CMatrixDouble31(p1->mean);
300  auto x2 = CMatrixDouble31(p2->mean);
301 
302  this->cov_inv = C1_inv + C2_inv;
303 
304  const CMatrixDouble33 cov = this->cov_inv.inverse_LLt();
305 
306  auto x = CMatrixDouble31(cov.asEigen() * (C1_inv * x1 + C2_inv * x2));
307 
308  this->mean.x(x(0, 0));
309  this->mean.y(x(1, 0));
310  this->mean.phi(x(2, 0));
311  this->mean.normalizePhi();
312 
313  MRPT_END
314 }
315 
316 /*---------------------------------------------------------------
317  inverse
318  ---------------------------------------------------------------*/
320 {
322  auto* out = dynamic_cast<CPosePDFGaussianInf*>(&o);
323 
324  // The mean:
325  out->mean = CPose2D(0, 0, 0) - mean;
326 
327  // The covariance:
328  const double ccos = ::cos(mean.phi());
329  const double ssin = ::sin(mean.phi());
330 
331  // jacobian:
332  alignas(MRPT_MAX_STATIC_ALIGN_BYTES) const double H_values[] = {
333  -ccos, -ssin, mean.x() * ssin - mean.y() * ccos,
334  ssin, -ccos, mean.x() * ccos + mean.y() * ssin,
335  0, 0, -1};
336  const CMatrixFixed<double, 3, 3> H(H_values);
337 
338  // o.cov = H * cov * Ht. It's the same with inverse covariances.
339  out->cov_inv.asEigen().noalias() =
340  (H.asEigen() * cov_inv.asEigen() * H.transpose()).eval();
341 }
342 
343 /*---------------------------------------------------------------
344  +=
345  ---------------------------------------------------------------*/
347 {
348  mean = mean + Ap;
349  rotateCov(Ap.phi());
350 }
351 
352 /*---------------------------------------------------------------
353  evaluatePDF
354  ---------------------------------------------------------------*/
356 {
357  auto X = CMatrixDouble31(x);
358  auto MU = CMatrixDouble31(mean);
359 
360  return math::normalPDF(X, MU, cov_inv.inverse());
361 }
362 
363 /*---------------------------------------------------------------
364  evaluateNormalizedPDF
365  ---------------------------------------------------------------*/
367 {
368  auto X = CMatrixDouble31(x);
369  auto MU = CMatrixDouble31(mean);
370 
371  const CMatrixDouble33 cov = this->cov_inv.inverse_LLt();
372 
373  return math::normalPDF(X, MU, cov) / math::normalPDF(MU, MU, cov);
374 }
375 
376 /*---------------------------------------------------------------
377  enforceCovSymmetry
378  ---------------------------------------------------------------*/
380 {
381  // Differences, when they exist, appear in the ~15'th significant
382  // digit, so... just take one of them arbitrarily!
383  cov_inv(0, 1) = cov_inv(1, 0);
384  cov_inv(0, 2) = cov_inv(2, 0);
385  cov_inv(1, 2) = cov_inv(2, 1);
386 }
387 
388 /*---------------------------------------------------------------
389  mahalanobisDistanceTo
390  ---------------------------------------------------------------*/
392  const CPosePDFGaussianInf& theOther)
393 {
394  MRPT_START
395 
396  auto MU = CVectorFixedDouble<3>(mean);
397  MU -= CVectorFixedDouble<3>(theOther.mean);
398 
399  wrapToPiInPlace(MU[2]);
400 
401  if (MU[0] == 0 && MU[1] == 0 && MU[2] == 0)
402  return 0; // This is the ONLY case where we know the result, whatever
403  // COVs are.
404 
405  CMatrixDouble33 COV_ = this->cov_inv.inverse_LLt();
406  const CMatrixDouble33 cov2 = theOther.cov_inv.inverse_LLt();
407  COV_ += cov2; // COV_ = cov1+cov2
408 
409  const CMatrixDouble33 COV_inv = COV_.inverse_LLt();
410 
411  // (~MU) * (!COV_) * MU
412  return std::sqrt(mrpt::math::multiply_HtCH_scalar(MU.asEigen(), COV_inv));
413 
414  MRPT_END
415 }
416 
417 /*---------------------------------------------------------------
418  operator <<
419  ---------------------------------------------------------------*/
421  std::ostream& out, const CPosePDFGaussianInf& obj)
422 {
423  out << "Mean: " << obj.mean << "\n";
424  out << "Inverse cov:\n" << obj.cov_inv << "\n";
425 
426  return out;
427 }
428 
429 /*---------------------------------------------------------------
430  operator +
431  ---------------------------------------------------------------*/
434 {
437  return ret;
438 }
439 
440 /*---------------------------------------------------------------
441  inverseComposition
442  Set 'this' = 'x' - 'ref', computing the mean using the "-"
443  operator and the covariances through the corresponding Jacobians.
444  ---------------------------------------------------------------*/
446  const CPosePDFGaussianInf& xv, const CPosePDFGaussianInf& xi)
447 {
448  // Use implementation in CPosePDFGaussian:
449  const CMatrixDouble33 xv_cov = xv.cov_inv.inverse_LLt();
450  const CMatrixDouble33 xi_cov = xi.cov_inv.inverse_LLt();
451 
452  const CPosePDFGaussian xv_(xv.mean, xv_cov);
453  const CPosePDFGaussian xi_(xi.mean, xi_cov);
454 
455  CPosePDFGaussian RET;
456  RET.inverseComposition(xv_, xi_);
457 
458  // Copy result to "this":
459  this->mean = RET.mean;
460  this->cov_inv = RET.cov.inverse_LLt();
461 }
462 
463 /*---------------------------------------------------------------
464  inverseComposition
465  Set \f$ this = x1 \ominus x0 \f$ , computing the mean using
466  the "-" operator and the covariances through the corresponding
467  Jacobians (Given the 3x3 cross-covariance matrix of variables x0 and x0).
468  ---------------------------------------------------------------*/
470  const CPosePDFGaussianInf& x1, const CPosePDFGaussianInf& x0,
471  const CMatrixDouble33& COV_01)
472 {
473  // Use implementation in CPosePDFGaussian:
474  const CMatrixDouble33 x1_cov = x1.cov_inv.inverse_LLt();
475  const CMatrixDouble33 x0_cov = x0.cov_inv.inverse_LLt();
476 
477  const CPosePDFGaussian x1_(x1.mean, x1_cov);
478  const CPosePDFGaussian x0_(x0.mean, x0_cov);
479 
480  CPosePDFGaussian RET;
481  RET.inverseComposition(x1_, x0_, COV_01);
482 
483  // Copy result to "this":
484  this->mean = RET.mean;
485  this->cov_inv = RET.cov.inverse_LLt();
486 }
487 
488 /*---------------------------------------------------------------
489  +=
490  ---------------------------------------------------------------*/
492 {
493  // COV:
494  const CMatrixDouble33 OLD_COV = this->cov_inv.inverse_LLt();
495 
496  CMatrixDouble33 df_dx, df_du;
497 
499  this->mean, // x
500  Ap.mean, // u
501  df_dx, df_du);
502 
503  const CMatrixDouble33 Ap_cov = Ap.cov_inv.inverse_LLt();
504 
505  this->cov_inv =
506  (multiply_HCHt(df_dx, OLD_COV) + multiply_HCHt(df_du, Ap_cov))
507  .inverse_LLt();
508 
509  // MEAN:
510  this->mean = this->mean + Ap.mean;
511 }
512 
514  const CPosePDFGaussianInf& p1, const CPosePDFGaussianInf& p2)
515 {
516  return p1.mean == p2.mean && p1.cov_inv == p2.cov_inv;
517 }
518 
519 /** Pose compose operator: RES = A (+) B , computing both the mean and the
520  * covariance */
522  const CPosePDFGaussianInf& a, const CPosePDFGaussianInf& b)
523 {
524  CPosePDFGaussianInf res(a);
525  res += b;
526  return res;
527 }
528 
529 /** Pose inverse compose operator: RES = A (-) B , computing both the mean and
530  * the covariance */
532  const CPosePDFGaussianInf& a, const CPosePDFGaussianInf& b)
533 {
535  res.inverseComposition(a, b);
536  return res;
537 }
A namespace of pseudo-random numbers generators of diferent distributions.
void bayesianFusion(const CPosePDF &p1, const CPosePDF &p2, const double minMahalanobisDistToDrop=0) override
Bayesian fusion of two points gauss.
void operator+=(const CPose2D &Ap)
Makes: thisPDF = thisPDF + Ap, where "+" is pose composition (both the mean, and the covariance matri...
MAT_C::Scalar multiply_HtCH_scalar(const VECTOR_H &H, const MAT_C &C)
r (scalar) = H^t*C*H (H: column vector, C: symmetric matrix)
Definition: ops_matrices.h:54
#define MRPT_START
Definition: exceptions.h:241
CPose2D mean
The mean value.
This class is a "CSerializable" wrapper for "CMatrixDynamic<double>".
Definition: CMatrixD.h:23
double x
X,Y coordinates.
Definition: TPose2D.h:30
int void fclose(FILE *f)
An OS-independent version of fclose.
Definition: os.cpp:275
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
To be added to all CSerializable-classes implementation files.
mrpt::math::TPoint2D operator+(const CPose2D &pose, const mrpt::math::TPoint2D &pnt)
Compose a 2D point from a new coordinate base given by a 2D pose.
Definition: CPose2D.cpp:394
std::ostream & operator<<(std::ostream &o, const CPoint2D &p)
Dumps a point as a string (x,y)
Definition: CPoint2D.cpp:102
bool saveToTextFile(const std::string &file) const override
Save PDF&#39;s particles to a text file, containing the 2D pose in the first line, then the covariance ma...
This file implements miscelaneous matrix and matrix/vector operations, and internal functions in mrpt...
STL namespace.
void getCovariance(mrpt::math::CMatrixDouble &cov) const
Returns the estimate of the covariance matrix (STATE_LEN x STATE_LEN covariance matrix) ...
virtual void getMean(type_value &mean_point) const =0
Returns the mean, or mathematical expectation of the probability density distribution (PDF)...
void enforceCovSymmetry()
Assures the symmetry of the covariance matrix (eventually certain operations in the math-coprocessor ...
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 1x3 vectors, where each row contains a (x,y,phi) datum.
#define MRPT_END_WITH_CLEAN_UP(stuff)
Definition: exceptions.h:247
mrpt::math::CMatrixDouble33 cov
The 3x3 covariance matrix.
void saveToTextFile(const std::string &file, mrpt::math::TMatrixTextFileFormat fileFormat=mrpt::math::MATRIX_FORMAT_ENG, bool appendMRPTHeader=false, const std::string &userHeader=std::string()) const
Saves the vector/matrix to a file compatible with MATLAB/Octave text format.
Virtual base class for "schematic archives" (JSON, XML,...)
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
Definition: exceptions.h:97
#define ASSERT_(f)
Defines an assertion mechanism.
Definition: exceptions.h:120
void wrapToPiInPlace(T &a)
Modifies the given angle to translate it into the ]-pi,pi] range.
Definition: wrap2pi.h:61
This base provides a set of functions for maths stuff.
Derived inverse() const
Returns the inverse of a general matrix using LU.
double evaluateNormalizedPDF(const CPose2D &x) const
Evaluates the ratio PDF(x) / PDF(MEAN), that is, the normalized PDF in the range [0,1].
#define CLASS_ID(T)
Access to runtime class ID for a defined class name.
Definition: CObject.h:102
CMatrixFixed< double, 3, 1 > CMatrixDouble31
Definition: CMatrixFixed.h:372
void copyFrom(const CPosePDF &o) override
Copy operator, translating if necesary (for example, between particles and gaussian representations) ...
Declares a class that represents a Probability Density function (PDF) of a 2D pose ...
double phi() const
Get the phi angle of the 2D pose (in radians)
Definition: CPose2D.h:86
void inverse(CPosePDF &o) const override
Returns a new PDF such as: NEW_PDF = (0,0,0) - THIS_PDF.
double evaluatePDF(const CPose2D &x) const
Evaluates the PDF at a given point.
virtual const mrpt::rtti::TRuntimeClassId * GetRuntimeClass() const override
Returns information about the class of an object in runtime.
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...
CPose2D operator-(const CPose2D &p)
Unary - operator: return the inverse pose "-p" (Note that is NOT the same than a pose with negative x...
Definition: CPose2D.cpp:356
#define IS_CLASS(obj, class_name)
True if the given reference to object (derived from mrpt::rtti::CObject) is of the given class...
Definition: CObject.h:146
double x() const
Common members of all points & poses classes.
Definition: CPoseOrPoint.h:143
Derived inverse_LLt() const
Returns the inverse of a symmetric matrix using LLt.
CMatrixDouble 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:149
type_value getMeanVal() const
Returns the mean, or mathematical expectation of the probability density distribution (PDF)...
void inverseComposition(const CPosePDFGaussian &x, const CPosePDFGaussian &ref)
Set , computing the mean using the "-" operator and the covariances through the corresponding Jacobi...
Declares a class that represents a probability density function (pdf) of a 2D pose (x...
Definition: CPosePDF.h:38
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
#define SCHEMA_DESERIALIZE_DATATYPE_VERSION()
For use inside serializeFrom(CSchemeArchiveBase) methods.
int fprintf(FILE *fil, const char *format,...) noexcept MRPT_printf_format_check(2
An OS-independent version of fprintf.
Definition: os.cpp:410
void rotateCov(const double ang)
Rotate the covariance matrix by replacing it by , where .
CPosePDFGaussianInf()
Default constructor (mean=all zeros, inverse covariance=all zeros -> so be careful!) ...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
A Probability Density function (PDF) of a 2D pose as a Gaussian with a mean and the inverse of the c...
bool operator==(const CPoint< DERIVEDCLASS, DIM > &p1, const CPoint< DERIVEDCLASS, DIM > &p2)
Definition: CPoint.h:119
Virtual base class for "archives": classes abstracting I/O streams.
Definition: CArchive.h:54
void drawGaussianMultivariate(std::vector< T > &out_result, const MATRIX &cov, const std::vector< T > *mean=nullptr)
Generate multidimensional random samples according to a given covariance matrix.
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle...
Definition: CPose2D.h:39
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:85
mrpt::vision::TStereoCalibResults out
static void jacobiansPoseComposition(const CPose2D &x, const CPose2D &u, mrpt::math::CMatrixDouble33 &df_dx, mrpt::math::CMatrixDouble33 &df_du, const bool compute_df_dx=true, const bool compute_df_du=true)
This static method computes the pose composition Jacobians, with these formulas:
Definition: CPosePDF.cpp:32
void composeFrom(const CPose2D &A, const CPose2D &B)
Makes .
Definition: CPose2D.cpp:135
#define MRPT_END
Definition: exceptions.h:245
Declares a class that represents a Probability Density function (PDF) of a 3D pose as a Gaussian des...
Lightweight 2D pose.
Definition: TPose2D.h:22
double mean(const CONTAINER &v)
Computes the mean value of a vector.
EIGEN_MAP asEigen()
Get as an Eigen-compatible Eigen::Map object.
Definition: CMatrixFixed.h:251
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
void drawSingleSample(CPose2D &outPart) const override
Draws a single sample from the distribution.
FILE * fopen(const char *fileName, const char *mode) noexcept
An OS-independent version of fopen.
Definition: os.cpp:257
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object.
#define SCHEMA_SERIALIZE_DATATYPE_VERSION(ser_version)
For use inside all serializeTo(CSchemeArchiveBase) methods.
CRandomGenerator & getRandomGenerator()
A static instance of a CRandomGenerator class, for use in single-thread applications.
double normalPDF(double x, double mu, double std)
Evaluates the univariate normal (Gaussian) distribution at a given point "x".
Definition: math.cpp:33
EIGEN_MAP asEigen()
Get as an Eigen-compatible Eigen::Map object.
void inverseComposition(const CPosePDFGaussianInf &x, const CPosePDFGaussianInf &ref)
Set , computing the mean using the "-" operator and the covariances through the corresponding Jacobi...
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
double phi
Orientation (rads)
Definition: TPose2D.h:32
Declares a class that represents a Probability Density Function (PDF) of a 3D pose (6D actually)...
Definition: CPose3DPDF.h:39
void changeCoordinatesReference(const CPose3D &newReferenceBase) override
this = p (+) this.
mrpt::math::CMatrixDouble33 cov_inv
The inverse of the 3x3 covariance matrix (the "information" matrix)
void normalizePhi()
Forces "phi" to be in the range [-pi,pi];.
Definition: CPose2D.cpp:333
double mahalanobisDistanceTo(const CPosePDFGaussianInf &theOther)
Computes the Mahalanobis distance between the centers of two Gaussians.
#define MRPT_UNUSED_PARAM(a)
Determines whether this is an X86 or AMD64 platform.
Definition: common.h:186
void multiply_HCHt(const MAT_H &H, const MAT_C &C, MAT_R &R, bool accumResultInOutput=false)
R = H * C * H^t.
Definition: ops_matrices.h:28



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 3a26b90fd Wed Mar 25 20:17:03 2020 +0100 at miƩ mar 25 23:05:41 CET 2020