10 #include <CTraitsTest.h> 11 #include <gtest/gtest.h> 18 #include <Eigen/Dense> 25 template class mrpt::CTraitsTest<CPose3DQuatPDFGaussian>;
33 double x,
double y,
double z,
double yaw,
double pitch,
double roll,
37 generateRandomPose3DPDF(x, y, z, yaw,
pitch,
roll, std_scale));
41 double x,
double y,
double z,
double yaw,
double pitch,
double roll,
49 for (
int i = 0; i < 6; i++)
cov(i, i) += 1e-7;
58 generateRandomPose3DPDF(1.0, 2.0, 3.0, yaw,
pitch,
roll, 0.1);
67 <<
"p1quat : " << endl
80 x[7 + 0], x[7 + 1], x[7 + 2],
83 for (
int i = 0; i < 7; i++) Y[i] = p[i];
93 x[7 + 0], x[7 + 1], x[7 + 2],
96 for (
int i = 0; i < 7; i++) Y[i] = p[i];
100 double x,
double y,
double z,
double yaw,
double pitch,
double roll,
101 double std_scale,
double x2,
double y2,
double z2,
double yaw2,
102 double pitch2,
double roll2,
double std_scale2)
105 generateRandomPoseQuat3DPDF(x, y, z, yaw,
pitch,
roll, std_scale);
107 x2, y2, z2, yaw2, pitch2, roll2, std_scale2);
116 for (
int i = 0; i < 7; i++) x_mean[i] = p7pdf1.
mean[i];
117 for (
int i = 0; i < 7; i++) x_mean[7 + i] = p7pdf2.mean[i];
121 x_cov.insertMatrix(7, 7, p7pdf2.cov);
127 x_mean, x_cov, func_compose, DUMMY, y_mean, y_cov, x_incrs);
131 <<
"p1 mean: " << p7pdf1.
mean << endl
132 <<
"p2 mean: " << p7pdf2.mean << endl
133 <<
"Numeric approximation of covariance: " << endl
135 <<
"Returned covariance: " << endl
136 << p7_comp.
cov << endl;
146 for (
int i = 0; i < 7; i++) Y[i] = p1_inv[i];
150 double x,
double y,
double z,
double yaw,
double pitch,
double roll,
151 double x2,
double y2,
double z2,
double yaw2,
double pitch2,
170 for (
int i = 0; i < 7; i++) x_mean[i] = q1[i];
171 for (
int i = 0; i < 7; i++) x_mean[7 + i] = q2[i];
182 x_incrs, DUMMY, numJacobs);
184 num_df_dx = numJacobs.
block<7, 7>(0, 0);
185 num_df_du = numJacobs.
block<7, 7>(0, 7);
190 <<
"q1: " << q1 << endl
191 <<
"q2: " << q2 << endl
192 <<
"Numeric approximation of df_dx: " << endl
194 <<
"Implemented method: " << endl
197 << df_dx - num_df_dx << endl;
200 <<
"q1: " << q1 << endl
201 <<
"q2: " << q2 << endl
202 <<
"Numeric approximation of df_du: " << endl
204 <<
"Implemented method: " << endl
207 << df_du - num_df_du << endl;
211 double x,
double y,
double z,
double yaw,
double pitch,
double roll,
215 generateRandomPoseQuat3DPDF(x, y, z, yaw,
pitch,
roll, std_scale);
224 for (
int i = 0; i < 7; i++) x_mean[i] = p7pdf1.
mean[i];
233 x_mean, x_cov, func_inverse, DUMMY, y_mean, y_cov, x_incrs);
238 <<
"p1 mean: " << p7pdf1.
mean << endl
239 <<
"inv mean: " << p7_inv.
mean << endl
240 <<
"Numeric approximation of covariance: " << endl
242 <<
"Returned covariance: " << endl
243 << p7_inv.
cov << endl
245 << y_cov - p7_inv.
cov << endl;
249 double x,
double y,
double z,
double yaw,
double pitch,
double roll,
250 double std_scale,
double x2,
double y2,
double z2,
double yaw2,
251 double pitch2,
double roll2,
double std_scale2)
254 generateRandomPoseQuat3DPDF(x, y, z, yaw,
pitch,
roll, std_scale);
256 x2, y2, z2, yaw2, pitch2, roll2, std_scale2);
265 for (
int i = 0; i < 7; i++) x_mean[i] = p7pdf1.
mean[i];
266 for (
int i = 0; i < 7; i++) x_mean[7 + i] = p7pdf2.mean[i];
270 x_cov.insertMatrix(7, 7, p7pdf2.cov);
276 x_mean, x_cov, func_inv_compose, DUMMY, y_mean, y_cov, x_incrs);
280 <<
"p1 mean: " << p7pdf1.
mean << endl
281 <<
"p2 mean: " << p7pdf2.mean << endl
282 <<
"Numeric approximation of covariance: " << endl
284 <<
"Returned covariance: " << endl
285 << p7_comp.
cov << endl;
289 double x,
double y,
double z,
double yaw,
double pitch,
double roll,
290 double std_scale,
double x2,
double y2,
double z2,
double yaw2,
291 double pitch2,
double roll2)
294 generateRandomPoseQuat3DPDF(x, y, z, yaw,
pitch,
roll, std_scale);
306 0, (p7_new_base_pdf.
cov - p7pdf1.cov).array().abs().mean(), 1e-2)
307 <<
"p1 mean: " << p7pdf1.mean << endl
308 <<
"new_base: " << new_base << endl;
316 <<
"p1 mean: " << p7pdf1.mean << endl
317 <<
"new_base: " << new_base << endl;
323 test_toFromYPRGauss(-30.0_deg, 10.0_deg, 60.0_deg);
324 test_toFromYPRGauss(30.0_deg, 88.0_deg, 0.0_deg);
325 test_toFromYPRGauss(30.0_deg, 89.5_deg, 0.0_deg);
331 testCompositionJacobian(
332 0, 0, 0, 2.0_deg, 0.0_deg, 0.0_deg, 0, 0, 0, 0.0_deg, 0.0_deg, 0.0_deg);
333 testCompositionJacobian(
334 1, 2, 3, 2.0_deg, 0.0_deg, 0.0_deg, -8, 45, 10, 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,
339 testCompositionJacobian(
340 1, 2, -3, 2.0_deg, 0.0_deg, 0.0_deg, -8, 45, 10, 0.0_deg, 0.0_deg,
342 testCompositionJacobian(
343 1, 2, 3, 20.0_deg, 80.0_deg, 70.0_deg, -8, 45, 10, 50.0_deg, -10.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,
348 testCompositionJacobian(
349 1, 2, 3, 20.0_deg, 80.0_deg, -70.0_deg, -8, 45, 10, 50.0_deg, -10.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,
354 testCompositionJacobian(
355 1, 2, 3, 20.0_deg, 80.0_deg, 70.0_deg, -8, 45, 10, 50.0_deg, 10.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,
364 testInverse(0, 0, 0, 0.0_deg, 0.0_deg, 0.0_deg, 0.1);
365 testInverse(0, 0, 0, 10.0_deg, 0.0_deg, 0.0_deg, 0.1);
366 testInverse(0, 0, 0, 0.0_deg, 10.0_deg, 0.0_deg, 0.1);
367 testInverse(0, 0, 0, 0.0_deg, 0.0_deg, 10.0_deg, 0.1);
369 testInverse(1, 2, 3, 0.0_deg, 0.0_deg, 0.0_deg, 0.1);
370 testInverse(1, 2, 3, 0.0_deg, 0.0_deg, 0.0_deg, 0.2);
372 testInverse(1, 2, 3, 30.0_deg, 0.0_deg, 0.0_deg, 0.1);
373 testInverse(-1, 2, 3, 30.0_deg, 0.0_deg, 0.0_deg, 0.1);
374 testInverse(1, 2, -3, 30.0_deg, 0.0_deg, 0.0_deg, 0.1);
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, 0.0_deg, 30.0_deg, 0.0_deg, 0.1);
381 testInverse(-1, 2, 3, 0.0_deg, 30.0_deg, 0.0_deg, 0.1);
382 testInverse(1, 2, -3, 0.0_deg, 30.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, 0.0_deg, 30.0_deg, 0.1);
389 testInverse(-1, 2, 3, 0.0_deg, 0.0_deg, 30.0_deg, 0.1);
390 testInverse(1, 2, -3, 0.0_deg, 0.0_deg, 30.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);
401 0, 0, 0, 0.0_deg, 0.0_deg, 0.0_deg, 0.1, 0, 0, 0, 0.0_deg, 0.0_deg,
404 1, 2, 3, 0.0_deg, 0.0_deg, 0.0_deg, 0.1, -8, 45, 10, 0.0_deg, 0.0_deg,
408 1, 2, 3, 20.0_deg, 80.0_deg, 70.0_deg, 0.1, -8, 45, 10, 50.0_deg,
409 -10.0_deg, 30.0_deg, 0.1);
411 1, 2, 3, 20.0_deg, 80.0_deg, 70.0_deg, 0.2, -8, 45, 10, 50.0_deg,
412 -10.0_deg, 30.0_deg, 0.2);
415 1, 2, 3, 10.0_deg, 0.0_deg, 0.0_deg, 0.1, -8, 45, 10, 0.0_deg, 0.0_deg,
418 1, 2, 3, 0.0_deg, 10.0_deg, 0.0_deg, 0.1, -8, 45, 10, 0.0_deg, 0.0_deg,
421 1, 2, 3, 0.0_deg, 0.0_deg, 10.0_deg, 0.1, -8, 45, 10, 0.0_deg, 0.0_deg,
424 1, 2, 3, 0.0_deg, 0.0_deg, 0.0_deg, 0.1, -8, 45, 10, 10.0_deg, 0.0_deg,
427 1, 2, 3, 0.0_deg, 0.0_deg, 0.0_deg, 0.1, -8, 45, 10, 0.0_deg, 10.0_deg,
430 1, 2, 3, 0.0_deg, 0.0_deg, 0.0_deg, 0.1, -8, 45, 10, 0.0_deg, 0.0_deg,
436 testPoseInverseComposition(
437 0, 0, 0, 0.0_deg, 0.0_deg, 0.0_deg, 0.1, 0, 0, 0, 0.0_deg, 0.0_deg,
439 testPoseInverseComposition(
440 1, 2, 3, 0.0_deg, 0.0_deg, 0.0_deg, 0.1, -8, 45, 10, 0.0_deg, 0.0_deg,
443 testPoseInverseComposition(
444 1, 2, 3, 20.0_deg, 80.0_deg, 70.0_deg, 0.1, -8, 45, 10, 50.0_deg,
445 -10.0_deg, 30.0_deg, 0.1);
446 testPoseInverseComposition(
447 1, 2, 3, 20.0_deg, 80.0_deg, 70.0_deg, 0.2, -8, 45, 10, 50.0_deg,
448 -10.0_deg, 30.0_deg, 0.2);
450 testPoseInverseComposition(
451 1, 2, 3, 10.0_deg, 0.0_deg, 0.0_deg, 0.1, -8, 45, 10, 0.0_deg, 0.0_deg,
453 testPoseInverseComposition(
454 1, 2, 3, 0.0_deg, 10.0_deg, 0.0_deg, 0.1, -8, 45, 10, 0.0_deg, 0.0_deg,
456 testPoseInverseComposition(
457 1, 2, 3, 0.0_deg, 0.0_deg, 10.0_deg, 0.1, -8, 45, 10, 0.0_deg, 0.0_deg,
459 testPoseInverseComposition(
460 1, 2, 3, 0.0_deg, 0.0_deg, 0.0_deg, 0.1, -8, 45, 10, 10.0_deg, 0.0_deg,
462 testPoseInverseComposition(
463 1, 2, 3, 0.0_deg, 0.0_deg, 0.0_deg, 0.1, -8, 45, 10, 0.0_deg, 10.0_deg,
465 testPoseInverseComposition(
466 1, 2, 3, 0.0_deg, 0.0_deg, 0.0_deg, 0.1, -8, 45, 10, 0.0_deg, 0.0_deg,
473 0, 0, 0, 0.0_deg, 0.0_deg, 0.0_deg, 0.1, 0, 0, 0, 0.0_deg, 0.0_deg,
476 1, 2, 3, 0.0_deg, 0.0_deg, 0.0_deg, 0.1, -8, 45, 10, 0.0_deg, 0.0_deg,
480 1, 2, 3, 20.0_deg, 80.0_deg, 70.0_deg, 0.1, -8, 45, 10, 50.0_deg,
481 -10.0_deg, 30.0_deg);
483 1, 2, 3, 20.0_deg, 80.0_deg, 70.0_deg, 0.2, -8, 45, 10, 50.0_deg,
484 -10.0_deg, 30.0_deg);
void changeCoordinatesReference(const CPose3DQuat &newReferenceBase)
this = p (+) this.
A compile-time fixed-size numeric matrix container.
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)
CPose3DQuat mean
The mean value.
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...
mrpt::math::CMatrixDouble77 cov
The 7x7 covariance matrix.
CQuaternion< double > CQuaternionDouble
A quaternion of data type "double".
CMatrixFixed< double, 7, 7 > CMatrixDouble77
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
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)
CONTAINER::Scalar sum(const CONTAINER &v)
Computes the sum of all the elements.
A class used to store a 3D pose as a translation (x,y,z) and a quaternion (qr,qx,qy,qz).
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...
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).
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)
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...
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)