10 #include <CTraitsTest.h> 11 #include <gtest/gtest.h> 17 #include <Eigen/Dense> 24 template class mrpt::CTraitsTest<CPose3DPDFGaussian>;
32 double x,
double y,
double z,
double yaw,
double pitch,
double roll,
40 for (
int i = 0; i < 6; i++)
cov(i, i) += 1e-7;
46 double x,
double y,
double z,
double yaw,
double pitch,
double roll,
50 generateRandomPose3DPDF(x, y, z, yaw,
pitch,
roll, std_scale);
57 const double val_mean_error =
60 const double cov_mean_error = (p6pdf_recov.
cov - p6pdf.
cov).sum_abs();
72 const CPose3D p1(x[0], x[1], x[2], x[3], x[4], x[5]);
74 x[6 + 0], x[6 + 1], x[6 + 2], x[6 + 3], x[6 + 4], x[6 + 5]);
76 for (
int i = 0; i < 6; i++) Y[i] = p[i];
84 const CPose3D p1(x[0], x[1], x[2], x[3], x[4], x[5]);
86 x[6 + 0], x[6 + 1], x[6 + 2], x[6 + 3], x[6 + 4], x[6 + 5]);
88 for (
int i = 0; i < 6; i++) Y[i] = p[i];
93 double x,
double y,
double z,
double yaw,
double pitch,
double roll,
94 double std_scale,
double x2,
double y2,
double z2,
double yaw2,
95 double pitch2,
double roll2,
double std_scale2)
98 generateRandomPose3DPDF(x, y, z, yaw,
pitch,
roll, std_scale);
100 x2, y2, z2, yaw2, pitch2, roll2, std_scale2);
110 for (
int i = 0; i < 6; i++) x_mean[i] = p6pdf1.
mean[i];
111 for (
int i = 0; i < 6; i++) x_mean[6 + i] = p6pdf2.mean[i];
115 x_cov.insertMatrix(6, 6, p6pdf2.cov);
121 x_mean, x_cov, func_compose, DUMMY, y_mean, y_cov, x_incrs);
125 <<
"p1 mean: " << p6pdf1.
mean << endl
126 <<
"p2 mean: " << p6pdf2.mean << endl;
130 <<
"p1 mean: " << p6pdf1.
mean << endl
131 <<
"p2 mean: " << p6pdf2.mean << endl;
139 <<
"p1 mean: " << p6pdf1.
mean << endl
140 <<
"p2 mean: " << p6pdf2.mean << endl;
144 <<
"p1 mean: " << p6pdf1.
mean << endl
145 <<
"p2 mean: " << p6pdf2.mean << endl;
149 double x,
double y,
double z,
double yaw,
double pitch,
double roll,
150 double x2,
double y2,
double z2,
double yaw2,
double pitch2,
154 const CPose3D q2(x2, y2, z2, yaw2, pitch2, roll2);
169 for (
int i = 0; i < 6; i++) x_mean[i] = q1[i];
170 for (
int i = 0; i < 6; i++) x_mean[6 + i] = q2[i];
181 x_incrs, DUMMY, numJacobs);
183 num_df_dx = numJacobs.
block<6, 6>(0, 0);
184 num_df_du = numJacobs.
block<6, 6>(0, 6);
188 EXPECT_NEAR(0, (df_dx - num_df_dx).sum_abs(), 3e-3)
189 <<
"q1: " << q1 << endl
190 <<
"q2: " << q2 << endl
191 <<
"Numeric approximation of df_dx: " << endl
193 <<
"Implemented method: " << endl
196 << df_dx - num_df_dx << endl;
198 EXPECT_NEAR(0, (df_du - num_df_du).sum_abs(), 3e-3)
199 <<
"q1: " << q1 << endl
200 <<
"q2: " << q2 << endl
201 <<
"Numeric approximation of df_du: " << endl
203 <<
"Implemented method: " << endl
206 << df_du - num_df_du << endl;
211 double x,
double y,
double z,
double yaw,
double pitch,
double roll,
212 double std_scale,
double x2,
double y2,
double z2,
double yaw2,
213 double pitch2,
double roll2,
double std_scale2)
216 generateRandomPose3DPDF(x, y, z, yaw,
pitch,
roll, std_scale);
218 x2, y2, z2, yaw2, pitch2, roll2, std_scale2);
228 for (
int i = 0; i < 6; i++) x_mean[i] = p6pdf1.
mean[i];
229 for (
int i = 0; i < 6; i++) x_mean[6 + i] = p6pdf2.mean[i];
233 x_cov.insertMatrix(6, 6, p6pdf2.cov);
239 x_mean, x_cov, func_inv_compose, DUMMY, y_mean, y_cov, x_incrs);
243 <<
"p1 mean: " << p6pdf1.
mean << endl
244 <<
"p2 mean: " << p6pdf2.mean << endl;
248 <<
"p1 mean: " << p6pdf1.
mean << endl
249 <<
"p2 mean: " << p6pdf2.mean << endl;
257 <<
"p1 mean: " << p6pdf1.
mean << endl
258 <<
"p2 mean: " << p6pdf2.mean << endl;
262 <<
"p1 mean: " << p6pdf1.
mean << endl
263 <<
"p2 mean: " << p6pdf2.mean << endl;
268 double x,
double y,
double z,
double yaw,
double pitch,
double roll,
272 generateRandomPose3DPDF(x, y, z, yaw,
pitch,
roll, std_scale);
290 <<
"p mean: " << p6pdf2.mean << endl;
294 <<
"p mean: " << p6pdf2.mean << endl;
308 <<
"p mean: " << p6pdf2.mean << endl
309 <<
"p6_inv2 mean: " << p6_inv2.mean << endl
310 <<
"p6_comp mean: " << p6_comp.
mean << endl;
314 <<
"p mean: " << p6pdf2.mean << endl
315 <<
"p6_inv2 mean: " << p6_inv2.mean << endl
316 <<
"p6_comp mean: " << p6_comp.
mean << endl;
321 double x,
double y,
double z,
double yaw,
double pitch,
double roll,
322 double std_scale,
double x2,
double y2,
double z2,
double yaw2,
323 double pitch2,
double roll2,
double std_scale2)
327 x, y, z, yaw,
pitch,
roll, std_scale, x2, y2, z2, yaw2, pitch2,
330 testPoseInverseComposition(
331 x, y, z, yaw,
pitch,
roll, std_scale, x2, y2, z2, yaw2, pitch2,
334 testPoseInverse(x, y, z, yaw,
pitch,
roll, std_scale);
338 double x,
double y,
double z,
double yaw,
double pitch,
double roll,
339 double std_scale,
double x2,
double y2,
double z2,
double yaw2,
340 double pitch2,
double roll2)
343 generateRandomPose3DPDF(x, y, z, yaw,
pitch,
roll, std_scale);
345 const CPose3D new_base =
CPose3D(x2, y2, z2, yaw2, pitch2, roll2);
354 0, (p6_new_base_pdf.
cov - p6pdf1.cov).array().abs().mean(), 1e-2)
355 <<
"p1 mean: " << p6pdf1.mean << endl
356 <<
"new_base: " << new_base << endl;
364 <<
"p1 mean: " << p6pdf1.mean << endl
365 <<
"new_base: " << new_base << endl;
371 testToQuatPDFAndBack(0, 0, 0, 0.0_deg, 0.0_deg, 0.0_deg, 0.1);
372 testToQuatPDFAndBack(0, 0, 0, 0.0_deg, 0.0_deg, 0.0_deg, 0.2);
374 testToQuatPDFAndBack(6, -2, -3, 0.0_deg, 0.0_deg, 0.0_deg, 0.1);
375 testToQuatPDFAndBack(6, -2, -3, 0.0_deg, 0.0_deg, 0.0_deg, 0.2);
377 testToQuatPDFAndBack(6, -2, -3, 10.0_deg, 40.0_deg, 5.0_deg, 0.1);
378 testToQuatPDFAndBack(6, -2, -3, 10.0_deg, 40.0_deg, 5.0_deg, 0.2);
380 testToQuatPDFAndBack(6, -2, -3, -50.0_deg, 87.0_deg, 20.0_deg, 0.1);
381 testToQuatPDFAndBack(6, -2, -3, -50.0_deg, 87.0_deg, 20.0_deg, 0.2);
383 testToQuatPDFAndBack(6, -2, -3, -50.0_deg, -87.0_deg, 20.0_deg, 0.1);
384 testToQuatPDFAndBack(6, -2, -3, -50.0_deg, -87.0_deg, 20.0_deg, 0.2);
389 testCompositionJacobian(
390 0, 0, 0, 2.0_deg, 0.0_deg, 0.0_deg, 0, 0, 0, 0.0_deg, 0.0_deg, 0.0_deg);
391 testCompositionJacobian(
392 0, 0, 0, 2.0_deg, 0.0_deg, 0.0_deg, 0, 0, 0, 0.0_deg, 0.0_deg, 0.0_deg);
393 testCompositionJacobian(
394 1, 2, 3, 2.0_deg, 0.0_deg, 0.0_deg, -8, 45, 10, 0.0_deg, 0.0_deg,
396 testCompositionJacobian(
397 1, -2, 3, 2.0_deg, 0.0_deg, 0.0_deg, -8, 45, 10, 0.0_deg, 0.0_deg,
399 testCompositionJacobian(
400 1, 2, -3, 2.0_deg, 0.0_deg, 0.0_deg, -8, 45, 10, 0.0_deg, 0.0_deg,
402 testCompositionJacobian(
403 1, 2, 3, 20.0_deg, 80.0_deg, 70.0_deg, -8, 45, 10, 50.0_deg, -10.0_deg,
405 testCompositionJacobian(
406 1, 2, 3, 20.0_deg, -80.0_deg, 70.0_deg, -8, 45, 10, 50.0_deg, -10.0_deg,
408 testCompositionJacobian(
409 1, 2, 3, 20.0_deg, 80.0_deg, -70.0_deg, -8, 45, 10, 50.0_deg, -10.0_deg,
411 testCompositionJacobian(
412 1, 2, 3, 20.0_deg, 80.0_deg, 70.0_deg, -8, 45, 10, -50.0_deg, -10.0_deg,
414 testCompositionJacobian(
415 1, 2, 3, 20.0_deg, 80.0_deg, 70.0_deg, -8, 45, 10, 50.0_deg, 10.0_deg,
417 testCompositionJacobian(
418 1, 2, 3, 20.0_deg, 80.0_deg, 70.0_deg, -8, 45, 10, 50.0_deg, -10.0_deg,
425 testAllPoseOperators(
426 0, 0, 0, 0.0_deg, 0.0_deg, 0.0_deg, 0.1, 0, 0, 0, 0.0_deg, 0.0_deg,
428 testAllPoseOperators(
429 1, 2, 3, 0.0_deg, 0.0_deg, 0.0_deg, 0.1, -8, 45, 10, 0.0_deg, 0.0_deg,
432 testAllPoseOperators(
433 1, 2, 3, 20.0_deg, 80.0_deg, 70.0_deg, 0.1, -8, 45, 10, 50.0_deg,
434 -10.0_deg, 30.0_deg, 0.1);
435 testAllPoseOperators(
436 1, 2, 3, 20.0_deg, 80.0_deg, 70.0_deg, 0.2, -8, 45, 10, 50.0_deg,
437 -10.0_deg, 30.0_deg, 0.2);
439 testAllPoseOperators(
440 1, 2, 3, 10.0_deg, 0.0_deg, 0.0_deg, 0.1, -8, 45, 10, 0.0_deg, 0.0_deg,
442 testAllPoseOperators(
443 1, 2, 3, 0.0_deg, 10.0_deg, 0.0_deg, 0.1, -8, 45, 10, 0.0_deg, 0.0_deg,
445 testAllPoseOperators(
446 1, 2, 3, 0.0_deg, 0.0_deg, 10.0_deg, 0.1, -8, 45, 10, 0.0_deg, 0.0_deg,
448 testAllPoseOperators(
449 1, 2, 3, 0.0_deg, 0.0_deg, 0.0_deg, 0.1, -8, 45, 10, 10.0_deg, 0.0_deg,
451 testAllPoseOperators(
452 1, 2, 3, 0.0_deg, 0.0_deg, 0.0_deg, 0.1, -8, 45, 10, 0.0_deg, 10.0_deg,
454 testAllPoseOperators(
455 1, 2, 3, 0.0_deg, 0.0_deg, 0.0_deg, 0.1, -8, 45, 10, 0.0_deg, 0.0_deg,
462 0, 0, 0, 0.0_deg, 0.0_deg, 0.0_deg, 0.1, 0, 0, 0, 0.0_deg, 0.0_deg,
465 1, 2, 3, 0.0_deg, 0.0_deg, 0.0_deg, 0.1, -8, 45, 10, 0.0_deg, 0.0_deg,
469 1, 2, 3, 20.0_deg, 80.0_deg, 70.0_deg, 0.1, -8, 45, 10, 50.0_deg,
470 -10.0_deg, 30.0_deg);
472 1, 2, 3, 20.0_deg, 80.0_deg, 70.0_deg, 0.2, -8, 45, 10, 50.0_deg,
473 -10.0_deg, 30.0_deg);
A compile-time fixed-size numeric matrix container.
CPose3D mean
The mean value.
void testAllPoseOperators(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)
EXPECT_TRUE(mrpt::system::fileExists(ini_fil))
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.
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...
TEST_F(Pose3DPDFGaussTests, ToQuatGaussPDFAndBack)
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)
void testPoseInverse(double x, double y, double z, double yaw, double pitch, double roll, double std_scale)
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
This base provides a set of functions for maths stuff.
void inverse(CPose3DPDF &o) const override
Returns a new PDF such as: NEW_PDF = (0,0,0) - THIS_PDF.
auto block(int start_row, int start_col)
non-const block(): Returns an Eigen::Block reference to the block
CMatrixDouble cov(const MATRIX &v)
Computes the covariance matrix from a list of samples in an NxM matrix, where each row is a sample...
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...
mrpt::math::CMatrixDouble66 cov
The 6x6 covariance matrix.
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)
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).
static CPose3DPDFGaussian generateRandomPose3DPDF(double x, double y, double z, double yaw, double pitch, double roll, double std_scale)
void testToQuatPDFAndBack(double x, double y, double z, double yaw, double pitch, double roll, double std_scale)
CMatrixFixed< double, 6, 6 > CMatrixDouble66
static void func_compose(const CVectorFixedDouble< 12 > &x, const double &dummy, CVectorFixedDouble< 6 > &Y)
Declares a class that represents a Probability Density function (PDF) of a 3D pose ...
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)
void changeCoordinatesReference(const CPose3D &newReferenceBase) override
this = p (+) this.
EXPECT_NEAR(out.cam_params.rightCameraPose.x, 0.1194, 0.005)
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)
vector_t asVectorVal() const
Return the pose or point as a 1xN vector with all the components (see derived classes for each implem...
for(unsigned int i=0;i< NUM_IMGS;i++)
#define MRPT_UNUSED_PARAM(a)
Determines whether this is an X86 or AMD64 platform.
static void func_inv_compose(const CVectorFixedDouble< 2 *6 > &x, const double &dummy, CVectorFixedDouble< 6 > &Y)