MRPT  2.0.4
CPose3DQuatPDFGaussian_unittest.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 <CTraitsTest.h>
11 #include <gtest/gtest.h>
12 #include <mrpt/math/num_jacobian.h>
14 #include <mrpt/poses/CPose3D.h>
17 #include <mrpt/random.h>
18 #include <Eigen/Dense>
19 
20 using namespace mrpt;
21 using namespace mrpt::poses;
22 using namespace mrpt::math;
23 using namespace std;
24 
25 template class mrpt::CTraitsTest<CPose3DQuatPDFGaussian>;
26 
27 class Pose3DQuatPDFGaussTests : public ::testing::Test
28 {
29  protected:
30  void SetUp() override {}
31  void TearDown() override {}
33  double x, double y, double z, double yaw, double pitch, double roll,
34  double std_scale)
35  {
37  generateRandomPose3DPDF(x, y, z, yaw, pitch, roll, std_scale));
38  }
39 
41  double x, double y, double z, double yaw, double pitch, double roll,
42  double std_scale)
43  {
46  r, 0, std_scale);
48  cov.matProductOf_AAt(r); // random semi-definite positive matrix:
49  for (int i = 0; i < 6; i++) cov(i, i) += 1e-7;
50  CPose3DPDFGaussian p6pdf(CPose3D(x, y, z, yaw, pitch, roll), cov);
51  return p6pdf;
52  }
53 
54  void test_toFromYPRGauss(double yaw, double pitch, double roll)
55  {
56  // Random pose:
57  CPose3DPDFGaussian p1ypr =
58  generateRandomPose3DPDF(1.0, 2.0, 3.0, yaw, pitch, roll, 0.1);
60 
61  // Convert back to a 6x6 representation:
62  CPose3DPDFGaussian p2ypr = CPose3DPDFGaussian(p1quat);
63 
64  EXPECT_NEAR(0, (p2ypr.cov - p1ypr.cov).array().abs().maxCoeff(), 1e-6)
65  << "p1ypr: " << endl
66  << p1ypr << endl
67  << "p1quat : " << endl
68  << p1quat << endl
69  << "p2ypr : " << endl
70  << p2ypr << endl;
71  }
72 
73  static void func_compose(
75  [[maybe_unused]] const double& dummy, CVectorFixedDouble<7>& Y)
76  {
77  const CPose3DQuat p1(
78  x[0], x[1], x[2], CQuaternionDouble(x[3], x[4], x[5], x[6]));
79  const CPose3DQuat p2(
80  x[7 + 0], x[7 + 1], x[7 + 2],
81  CQuaternionDouble(x[7 + 3], x[7 + 4], x[7 + 5], x[7 + 6]));
82  const CPose3DQuat p = p1 + p2;
83  for (int i = 0; i < 7; i++) Y[i] = p[i];
84  }
85 
86  static void func_inv_compose(
88  [[maybe_unused]] const double& dummy, CVectorFixedDouble<7>& Y)
89  {
90  CQuaternionDouble q(x[3], x[4], x[5], x[6]);
91  q.normalize();
92  const CPose3DQuat p1(x[0], x[1], x[2], q);
93  const CPose3DQuat p2(
94  x[7 + 0], x[7 + 1], x[7 + 2],
95  CQuaternionDouble(x[7 + 3], x[7 + 4], x[7 + 5], x[7 + 6]));
96  const CPose3DQuat p = p1 - p2;
97  for (int i = 0; i < 7; i++) Y[i] = p[i];
98  }
99 
101  double x, double y, double z, double yaw, double pitch, double roll,
102  double std_scale, double x2, double y2, double z2, double yaw2,
103  double pitch2, double roll2, double std_scale2)
104  {
105  CPose3DQuatPDFGaussian p7pdf1 =
106  generateRandomPoseQuat3DPDF(x, y, z, yaw, pitch, roll, std_scale);
107  CPose3DQuatPDFGaussian p7pdf2 = generateRandomPoseQuat3DPDF(
108  x2, y2, z2, yaw2, pitch2, roll2, std_scale2);
109 
110  CPose3DQuatPDFGaussian p7_comp = p7pdf1 + p7pdf2;
111 
112  // Numeric approximation:
113  CVectorFixedDouble<7> y_mean;
115  {
117  for (int i = 0; i < 7; i++) x_mean[i] = p7pdf1.mean[i];
118  for (int i = 0; i < 7; i++) x_mean[7 + i] = p7pdf2.mean[i];
119 
121  x_cov.insertMatrix(0, 0, p7pdf1.cov);
122  x_cov.insertMatrix(7, 7, p7pdf2.cov);
123 
124  double DUMMY = 0;
126  x_incrs.fill(1e-6);
128  x_mean, x_cov, func_compose, DUMMY, y_mean, y_cov, x_incrs);
129  }
130  // Compare:
131  EXPECT_NEAR(0, (y_cov - p7_comp.cov).array().abs().maxCoeff(), 1e-3)
132  << "p1 mean: " << p7pdf1.mean << endl
133  << "p2 mean: " << p7pdf2.mean << endl
134  << "Numeric approximation of covariance: " << endl
135  << y_cov << endl
136  << "Returned covariance: " << endl
137  << p7_comp.cov << endl;
138  }
139 
140  static void func_inverse(
141  const CVectorFixedDouble<7>& x, [[maybe_unused]] const double& dummy,
143  {
144  CQuaternionDouble q(x[3], x[4], x[5], x[6]);
145  q.normalize();
146  const CPose3DQuat p1(x[0], x[1], x[2], q);
147  const CPose3DQuat p1_inv(-p1);
148  for (int i = 0; i < 7; i++) Y[i] = p1_inv[i];
149  }
150 
152  double x, double y, double z, double yaw, double pitch, double roll,
153  double x2, double y2, double z2, double yaw2, double pitch2,
154  double roll2)
155  {
156  const CPose3DQuat q1(CPose3D(x, y, z, yaw, pitch, roll));
157  const CPose3DQuat q2(CPose3D(x2, y2, z2, yaw2, pitch2, roll2));
158 
159  // Theoretical Jacobians:
161  df_du(UNINITIALIZED_MATRIX);
163  q1, // x
164  q2, // u
165  df_dx, df_du);
166 
167  // Numerical approximation:
169  num_df_du(UNINITIALIZED_MATRIX);
170  {
172  for (int i = 0; i < 7; i++) x_mean[i] = q1[i];
173  for (int i = 0; i < 7; i++) x_mean[7 + i] = q2[i];
174 
175  double DUMMY = 0;
177  x_incrs.fill(1e-7);
178  CMatrixDouble numJacobs;
180  x_mean,
181  std::function<void(
182  const CVectorFixedDouble<2 * 7>& x, const double& dummy,
183  CVectorFixedDouble<7>& Y)>(&func_compose),
184  x_incrs, DUMMY, numJacobs);
185 
186  num_df_dx = numJacobs.block<7, 7>(0, 0);
187  num_df_du = numJacobs.block<7, 7>(0, 7);
188  }
189 
190  // Compare:
191  EXPECT_NEAR(0, (df_dx - num_df_dx).array().abs().maxCoeff(), 1e-6)
192  << "q1: " << q1 << endl
193  << "q2: " << q2 << endl
194  << "Numeric approximation of df_dx: " << endl
195  << num_df_dx << endl
196  << "Implemented method: " << endl
197  << df_dx << endl
198  << "Error: " << endl
199  << df_dx - num_df_dx << endl;
200 
201  EXPECT_NEAR(0, (df_du - num_df_du).array().abs().maxCoeff(), 1e-6)
202  << "q1: " << q1 << endl
203  << "q2: " << q2 << endl
204  << "Numeric approximation of df_du: " << endl
205  << num_df_du << endl
206  << "Implemented method: " << endl
207  << df_du << endl
208  << "Error: " << endl
209  << df_du - num_df_du << endl;
210  }
211 
213  double x, double y, double z, double yaw, double pitch, double roll,
214  double std_scale)
215  {
216  CPose3DQuatPDFGaussian p7pdf1 =
217  generateRandomPoseQuat3DPDF(x, y, z, yaw, pitch, roll, std_scale);
218 
219  CPose3DQuatPDFGaussian p7_inv = -p7pdf1;
220 
221  // Numeric approximation:
222  CVectorFixedDouble<7> y_mean;
224  {
225  CVectorFixedDouble<7> x_mean;
226  for (int i = 0; i < 7; i++) x_mean[i] = p7pdf1.mean[i];
227 
229  x_cov.insertMatrix(0, 0, p7pdf1.cov);
230 
231  double DUMMY = 0;
232  CVectorFixedDouble<7> x_incrs;
233  x_incrs.fill(1e-6);
235  x_mean, x_cov, func_inverse, DUMMY, y_mean, y_cov, x_incrs);
236  }
237 
238  // Compare:
239  EXPECT_NEAR(0, (y_cov - p7_inv.cov).array().abs().maxCoeff(), 1e-6)
240  << "p1 mean: " << p7pdf1.mean << endl
241  << "inv mean: " << p7_inv.mean << endl
242  << "Numeric approximation of covariance: " << endl
243  << y_cov << endl
244  << "Returned covariance: " << endl
245  << p7_inv.cov << endl
246  << "Error: " << endl
247  << y_cov - p7_inv.cov << endl;
248  }
249 
251  double x, double y, double z, double yaw, double pitch, double roll,
252  double std_scale, double x2, double y2, double z2, double yaw2,
253  double pitch2, double roll2, double std_scale2)
254  {
255  CPose3DQuatPDFGaussian p7pdf1 =
256  generateRandomPoseQuat3DPDF(x, y, z, yaw, pitch, roll, std_scale);
257  CPose3DQuatPDFGaussian p7pdf2 = generateRandomPoseQuat3DPDF(
258  x2, y2, z2, yaw2, pitch2, roll2, std_scale2);
259 
260  CPose3DQuatPDFGaussian p7_comp = p7pdf1 - p7pdf2;
261 
262  // Numeric approximation:
263  CVectorFixedDouble<7> y_mean;
265  {
267  for (int i = 0; i < 7; i++) x_mean[i] = p7pdf1.mean[i];
268  for (int i = 0; i < 7; i++) x_mean[7 + i] = p7pdf2.mean[i];
269 
271  x_cov.insertMatrix(0, 0, p7pdf1.cov);
272  x_cov.insertMatrix(7, 7, p7pdf2.cov);
273 
274  double DUMMY = 0;
276  x_incrs.fill(1e-6);
278  x_mean, x_cov, func_inv_compose, DUMMY, y_mean, y_cov, x_incrs);
279  }
280  // Compare:
281  EXPECT_NEAR(0, (y_cov - p7_comp.cov).array().abs().maxCoeff(), 1e-6)
282  << "p1 mean: " << p7pdf1.mean << endl
283  << "p2 mean: " << p7pdf2.mean << endl
284  << "Numeric approximation of covariance: " << endl
285  << y_cov << endl
286  << "Returned covariance: " << endl
287  << p7_comp.cov << endl;
288  }
289 
291  double x, double y, double z, double yaw, double pitch, double roll,
292  double std_scale, double x2, double y2, double z2, double yaw2,
293  double pitch2, double roll2)
294  {
295  CPose3DQuatPDFGaussian p7pdf1 =
296  generateRandomPoseQuat3DPDF(x, y, z, yaw, pitch, roll, std_scale);
297 
298  const CPose3DQuat new_base =
299  CPose3DQuat(CPose3D(x2, y2, z2, yaw2, pitch2, roll2));
300  const CPose3DQuatPDFGaussian new_base_pdf(
301  new_base, CMatrixDouble77()); // COV = Zeros
302 
303  const CPose3DQuatPDFGaussian p7_new_base_pdf = new_base_pdf + p7pdf1;
304  p7pdf1.changeCoordinatesReference(new_base);
305 
306  // Compare:
307  EXPECT_NEAR(
308  0, (p7_new_base_pdf.cov - p7pdf1.cov).array().abs().maxCoeff(),
309  1e-2)
310  << "p1 mean: " << p7pdf1.mean << endl
311  << "new_base: " << new_base << endl;
312  EXPECT_NEAR(
313  0,
314  (p7_new_base_pdf.mean.asVectorVal() - p7pdf1.mean.asVectorVal())
315  .array()
316  .abs()
317  .mean(),
318  1e-2)
319  << "p1 mean: " << p7pdf1.mean << endl
320  << "new_base: " << new_base << endl;
321  }
322 };
323 
324 TEST_F(Pose3DQuatPDFGaussTests, ToYPRGaussPDFAndBack)
325 {
326  test_toFromYPRGauss(-30.0_deg, 10.0_deg, 60.0_deg);
327  test_toFromYPRGauss(30.0_deg, 88.0_deg, 0.0_deg);
328  test_toFromYPRGauss(30.0_deg, 89.5_deg, 0.0_deg);
329  // The formulas break at pitch=90, but this we cannot avoid...
330 }
331 
332 TEST_F(Pose3DQuatPDFGaussTests, CompositionJacobian)
333 {
334  testCompositionJacobian(
335  0, 0, 0, 2.0_deg, 0.0_deg, 0.0_deg, 0, 0, 0, 0.0_deg, 0.0_deg, 0.0_deg);
336  testCompositionJacobian(
337  1, 2, 3, 2.0_deg, 0.0_deg, 0.0_deg, -8, 45, 10, 0.0_deg, 0.0_deg,
338  0.0_deg);
339  testCompositionJacobian(
340  1, -2, 3, 2.0_deg, 0.0_deg, 0.0_deg, -8, 45, 10, 0.0_deg, 0.0_deg,
341  0.0_deg);
342  testCompositionJacobian(
343  1, 2, -3, 2.0_deg, 0.0_deg, 0.0_deg, -8, 45, 10, 0.0_deg, 0.0_deg,
344  0.0_deg);
345  testCompositionJacobian(
346  1, 2, 3, 20.0_deg, 80.0_deg, 70.0_deg, -8, 45, 10, 50.0_deg, -10.0_deg,
347  30.0_deg);
348  testCompositionJacobian(
349  1, 2, 3, 20.0_deg, -80.0_deg, 70.0_deg, -8, 45, 10, 50.0_deg, -10.0_deg,
350  30.0_deg);
351  testCompositionJacobian(
352  1, 2, 3, 20.0_deg, 80.0_deg, -70.0_deg, -8, 45, 10, 50.0_deg, -10.0_deg,
353  30.0_deg);
354  testCompositionJacobian(
355  1, 2, 3, 20.0_deg, 80.0_deg, 70.0_deg, -8, 45, 10, -50.0_deg, -10.0_deg,
356  30.0_deg);
357  testCompositionJacobian(
358  1, 2, 3, 20.0_deg, 80.0_deg, 70.0_deg, -8, 45, 10, 50.0_deg, 10.0_deg,
359  30.0_deg);
360  testCompositionJacobian(
361  1, 2, 3, 20.0_deg, 80.0_deg, 70.0_deg, -8, 45, 10, 50.0_deg, -10.0_deg,
362  -30.0_deg);
363 }
364 
366 {
367  testInverse(0, 0, 0, 0.0_deg, 0.0_deg, 0.0_deg, 0.1);
368  testInverse(0, 0, 0, 10.0_deg, 0.0_deg, 0.0_deg, 0.1);
369  testInverse(0, 0, 0, 0.0_deg, 10.0_deg, 0.0_deg, 0.1);
370  testInverse(0, 0, 0, 0.0_deg, 0.0_deg, 10.0_deg, 0.1);
371 
372  testInverse(1, 2, 3, 0.0_deg, 0.0_deg, 0.0_deg, 0.1);
373  testInverse(1, 2, 3, 0.0_deg, 0.0_deg, 0.0_deg, 0.2);
374 
375  testInverse(1, 2, 3, 30.0_deg, 0.0_deg, 0.0_deg, 0.1);
376  testInverse(-1, 2, 3, 30.0_deg, 0.0_deg, 0.0_deg, 0.1);
377  testInverse(1, 2, -3, 30.0_deg, 0.0_deg, 0.0_deg, 0.1);
378  testInverse(-1, 2, -3, 30.0_deg, 0.0_deg, 0.0_deg, 0.1);
379  testInverse(1, 2, 3, -30.0_deg, 0.0_deg, 0.0_deg, 0.1);
380  testInverse(-1, 2, 3, -30.0_deg, 0.0_deg, 0.0_deg, 0.1);
381  testInverse(1, 2, -3, -30.0_deg, 0.0_deg, 0.0_deg, 0.1);
382  testInverse(-1, 2, -3, -30.0_deg, 0.0_deg, 0.0_deg, 0.1);
383  testInverse(1, 2, 3, 0.0_deg, 30.0_deg, 0.0_deg, 0.1);
384  testInverse(-1, 2, 3, 0.0_deg, 30.0_deg, 0.0_deg, 0.1);
385  testInverse(1, 2, -3, 0.0_deg, 30.0_deg, 0.0_deg, 0.1);
386  testInverse(-1, 2, -3, 0.0_deg, 30.0_deg, 0.0_deg, 0.1);
387  testInverse(1, 2, 3, 0.0_deg, -30.0_deg, 0.0_deg, 0.1);
388  testInverse(-1, 2, 3, 0.0_deg, -30.0_deg, 0.0_deg, 0.1);
389  testInverse(1, 2, -3, 0.0_deg, -30.0_deg, 0.0_deg, 0.1);
390  testInverse(-1, 2, -3, 0.0_deg, -30.0_deg, 0.0_deg, 0.1);
391  testInverse(1, 2, 3, 0.0_deg, 0.0_deg, 30.0_deg, 0.1);
392  testInverse(-1, 2, 3, 0.0_deg, 0.0_deg, 30.0_deg, 0.1);
393  testInverse(1, 2, -3, 0.0_deg, 0.0_deg, 30.0_deg, 0.1);
394  testInverse(-1, 2, -3, 0.0_deg, 0.0_deg, 30.0_deg, 0.1);
395  testInverse(1, 2, 3, 0.0_deg, 0.0_deg, -30.0_deg, 0.1);
396  testInverse(-1, 2, 3, 0.0_deg, 0.0_deg, -30.0_deg, 0.1);
397  testInverse(1, 2, -3, 0.0_deg, 0.0_deg, -30.0_deg, 0.1);
398  testInverse(-1, 2, -3, 0.0_deg, 0.0_deg, -30.0_deg, 0.1);
399 }
400 
402 {
403  testPoseComposition(
404  0, 0, 0, 0.0_deg, 0.0_deg, 0.0_deg, 0.1, 0, 0, 0, 0.0_deg, 0.0_deg,
405  0.0_deg, 0.1);
406  testPoseComposition(
407  1, 2, 3, 0.0_deg, 0.0_deg, 0.0_deg, 0.1, -8, 45, 10, 0.0_deg, 0.0_deg,
408  0.0_deg, 0.1);
409 
410  testPoseComposition(
411  1, 2, 3, 20.0_deg, 80.0_deg, 70.0_deg, 0.1, -8, 45, 10, 50.0_deg,
412  -10.0_deg, 30.0_deg, 0.1);
413  testPoseComposition(
414  1, 2, 3, 20.0_deg, 80.0_deg, 70.0_deg, 0.2, -8, 45, 10, 50.0_deg,
415  -10.0_deg, 30.0_deg, 0.2);
416 
417  testPoseComposition(
418  1, 2, 3, 10.0_deg, 0.0_deg, 0.0_deg, 0.1, -8, 45, 10, 0.0_deg, 0.0_deg,
419  0.0_deg, 0.1);
420  testPoseComposition(
421  1, 2, 3, 0.0_deg, 10.0_deg, 0.0_deg, 0.1, -8, 45, 10, 0.0_deg, 0.0_deg,
422  0.0_deg, 0.1);
423  testPoseComposition(
424  1, 2, 3, 0.0_deg, 0.0_deg, 10.0_deg, 0.1, -8, 45, 10, 0.0_deg, 0.0_deg,
425  0.0_deg, 0.1);
426  testPoseComposition(
427  1, 2, 3, 0.0_deg, 0.0_deg, 0.0_deg, 0.1, -8, 45, 10, 10.0_deg, 0.0_deg,
428  0.0_deg, 0.1);
429  testPoseComposition(
430  1, 2, 3, 0.0_deg, 0.0_deg, 0.0_deg, 0.1, -8, 45, 10, 0.0_deg, 10.0_deg,
431  0.0_deg, 0.1);
432  testPoseComposition(
433  1, 2, 3, 0.0_deg, 0.0_deg, 0.0_deg, 0.1, -8, 45, 10, 0.0_deg, 0.0_deg,
434  10.0_deg, 0.1);
435 }
436 
437 TEST_F(Pose3DQuatPDFGaussTests, InverseComposition)
438 {
439  testPoseInverseComposition(
440  0, 0, 0, 0.0_deg, 0.0_deg, 0.0_deg, 0.1, 0, 0, 0, 0.0_deg, 0.0_deg,
441  0.0_deg, 0.1);
442  testPoseInverseComposition(
443  1, 2, 3, 0.0_deg, 0.0_deg, 0.0_deg, 0.1, -8, 45, 10, 0.0_deg, 0.0_deg,
444  0.0_deg, 0.1);
445 
446  testPoseInverseComposition(
447  1, 2, 3, 20.0_deg, 80.0_deg, 70.0_deg, 0.1, -8, 45, 10, 50.0_deg,
448  -10.0_deg, 30.0_deg, 0.1);
449  testPoseInverseComposition(
450  1, 2, 3, 20.0_deg, 80.0_deg, 70.0_deg, 0.2, -8, 45, 10, 50.0_deg,
451  -10.0_deg, 30.0_deg, 0.2);
452 
453  testPoseInverseComposition(
454  1, 2, 3, 10.0_deg, 0.0_deg, 0.0_deg, 0.1, -8, 45, 10, 0.0_deg, 0.0_deg,
455  0.0_deg, 0.1);
456  testPoseInverseComposition(
457  1, 2, 3, 0.0_deg, 10.0_deg, 0.0_deg, 0.1, -8, 45, 10, 0.0_deg, 0.0_deg,
458  0.0_deg, 0.1);
459  testPoseInverseComposition(
460  1, 2, 3, 0.0_deg, 0.0_deg, 10.0_deg, 0.1, -8, 45, 10, 0.0_deg, 0.0_deg,
461  0.0_deg, 0.1);
462  testPoseInverseComposition(
463  1, 2, 3, 0.0_deg, 0.0_deg, 0.0_deg, 0.1, -8, 45, 10, 10.0_deg, 0.0_deg,
464  0.0_deg, 0.1);
465  testPoseInverseComposition(
466  1, 2, 3, 0.0_deg, 0.0_deg, 0.0_deg, 0.1, -8, 45, 10, 0.0_deg, 10.0_deg,
467  0.0_deg, 0.1);
468  testPoseInverseComposition(
469  1, 2, 3, 0.0_deg, 0.0_deg, 0.0_deg, 0.1, -8, 45, 10, 0.0_deg, 0.0_deg,
470  10.0_deg, 0.1);
471 }
472 
474 {
475  testChangeCoordsRef(
476  0, 0, 0, 0.0_deg, 0.0_deg, 0.0_deg, 0.1, 0, 0, 0, 0.0_deg, 0.0_deg,
477  0.0_deg);
478  testChangeCoordsRef(
479  1, 2, 3, 0.0_deg, 0.0_deg, 0.0_deg, 0.1, -8, 45, 10, 0.0_deg, 0.0_deg,
480  0.0_deg);
481 
482  testChangeCoordsRef(
483  1, 2, 3, 20.0_deg, 80.0_deg, 70.0_deg, 0.1, -8, 45, 10, 50.0_deg,
484  -10.0_deg, 30.0_deg);
485  testChangeCoordsRef(
486  1, 2, 3, 20.0_deg, 80.0_deg, 70.0_deg, 0.2, -8, 45, 10, 50.0_deg,
487  -10.0_deg, 30.0_deg);
488 }
void changeCoordinatesReference(const CPose3DQuat &newReferenceBase)
this = p (+) this.
A compile-time fixed-size numeric matrix container.
Definition: CMatrixFixed.h:33
void normalize()
Normalize this quaternion, so its norm becomes the unitity.
Definition: CQuaternion.h:301
static CPose3DPDFGaussian generateRandomPose3DPDF(double x, double y, double z, double yaw, double pitch, double roll, double std_scale)
void test_toFromYPRGauss(double yaw, double pitch, double roll)
TEST_F(Pose3DQuatPDFGaussTests, ToYPRGaussPDFAndBack)
void drawGaussian1DMatrix(MAT &matrix, const double mean=0, const double std=1)
Fills the given matrix with independent, 1D-normally distributed samples.
void insertMatrix(const int row_start, const int col_start, const OTHERMATVEC &submat)
Copies the given input submatrix/vector into this matrix/vector, starting at the given top-left coord...
Definition: MatrixBase.h:210
mrpt::math::CMatrixDouble77 cov
The 7x7 covariance matrix.
CQuaternion< double > CQuaternionDouble
A quaternion of data type "double".
Definition: CQuaternion.h:540
STL namespace.
CMatrixFixed< double, 7, 7 > CMatrixDouble77
Definition: CMatrixFixed.h:370
Declares a class that represents a Probability Density function (PDF) of a 3D pose using a quaternion...
void matProductOf_AAt(const MAT_A &A)
this = A * AT
Definition: MatrixBase.h:276
static void func_compose(const CVectorFixedDouble< 2 *7 > &x, [[maybe_unused]] const double &dummy, CVectorFixedDouble< 7 > &Y)
This base provides a set of functions for maths stuff.
auto block(int start_row, int start_col)
non-const block(): Returns an Eigen::Block reference to the block
static void func_inv_compose(const CVectorFixedDouble< 2 *7 > &x, [[maybe_unused]] const double &dummy, CVectorFixedDouble< 7 > &Y)
A class used to store a 3D pose as a translation (x,y,z) and a quaternion (qr,qx,qy,qz).
Definition: CPose3DQuat.h:45
void transform_gaussian_linear(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 VECTORLIKE1 &x_increments)
First order uncertainty propagation estimator of the Gaussian distribution of a variable Y=f(X) for a...
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
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
void estimateJacobian(const VECTORLIKE &x, const std::function< void(const VECTORLIKE &x, const USERPARAM &y, VECTORLIKE3 &out)> &functor, const VECTORLIKE2 &increments, const USERPARAM &userParam, MATRIXLIKE &out_Jacobian)
Estimate the Jacobian of a multi-dimensional function around a point "x", using finite differences of...
Definition: num_jacobian.h:31
void testInverse(double x, double y, double z, double yaw, double pitch, double roll, double std_scale)
mrpt::math::CMatrixDouble66 cov
The 6x6 covariance matrix.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:85
void testChangeCoordsRef(double x, double y, double z, double yaw, double pitch, double roll, double std_scale, double x2, double y2, double z2, double yaw2, double pitch2, double roll2)
Declares a class that represents a Probability Density function (PDF) of a 3D pose ...
void testCompositionJacobian(double x, double y, double z, double yaw, double pitch, double roll, double x2, double y2, double z2, double yaw2, double pitch2, double roll2)
EXPECT_NEAR(out.cam_params.rightCameraPose.x, 0.1194, 0.005)
A quaternion, which can represent a 3D rotation as pair , with a real part "r" and a 3D vector ...
Definition: CQuaternion.h:44
static void jacobiansPoseComposition(const CPose3DQuat &x, const CPose3DQuat &u, mrpt::math::CMatrixDouble77 &df_dx, mrpt::math::CMatrixDouble77 &df_du, CPose3DQuat *out_x_oplus_u=nullptr)
This static method computes the two Jacobians of a pose composition operation $f(x,u)= x u$.
void testPoseInverseComposition(double x, double y, double z, double yaw, double pitch, double roll, double std_scale, double x2, double y2, double z2, double yaw2, double pitch2, double roll2, double std_scale2)
CRandomGenerator & getRandomGenerator()
A static instance of a CRandomGenerator class, for use in single-thread applications.
void testPoseComposition(double x, double y, double z, double yaw, double pitch, double roll, double std_scale, double x2, double y2, double z2, double yaw2, double pitch2, double roll2, double std_scale2)
static void func_inverse(const CVectorFixedDouble< 7 > &x, [[maybe_unused]] const double &dummy, CVectorFixedDouble< 7 > &Y)
vector_t asVectorVal() const
Return the pose or point as a 1xN vector with all the components (see derived classes for each implem...
Definition: CPoseOrPoint.h:266
for(unsigned int i=0;i< NUM_IMGS;i++)
static CPose3DQuatPDFGaussian generateRandomPoseQuat3DPDF(double x, double y, double z, double yaw, double pitch, double roll, double std_scale)



Page generated by Doxygen 1.8.14 for MRPT 2.0.4 Git: 33de1d0ad Sat Jun 20 11:02:42 2020 +0200 at sáb jun 20 17:35:17 CEST 2020