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();
63 EXPECT_TRUE(val_mean_error < 1e-8);
64 EXPECT_TRUE(cov_mean_error < 1e-8);
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];
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;
129 EXPECT_NEAR(0, (y_cov - p6_comp.
cov).sum_abs(), 1e-2)
130 <<
"p1 mean: " << p6pdf1.
mean << endl
131 <<
"p2 mean: " << p6pdf2.mean << endl;
139 <<
"p1 mean: " << p6pdf1.
mean << endl
140 <<
"p2 mean: " << p6pdf2.mean << endl;
143 EXPECT_NEAR(0, (y_cov - p6_comp.
cov).sum_abs(), 1e-2)
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;
247 EXPECT_NEAR(0, (y_cov - p6_comp.
cov).sum_abs(), 1e-2)
248 <<
"p1 mean: " << p6pdf1.
mean << endl
249 <<
"p2 mean: " << p6pdf2.mean << endl;
257 <<
"p1 mean: " << p6pdf1.
mean << endl
258 <<
"p2 mean: " << p6pdf2.mean << endl;
261 EXPECT_NEAR(0, (y_cov - p6_comp.
cov).sum_abs(), 1e-2)
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;
293 EXPECT_NEAR(0, (p6_inv.
cov - p6_comp.
cov).sum_abs(), 1e-2)
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;
313 EXPECT_NEAR(0, (p6_inv2.cov - p6_comp.
cov).sum_abs(), 1e-2)
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,
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;
380 testToQuatPDFAndBack(
382 testToQuatPDFAndBack(
385 testToQuatPDFAndBack(
387 testToQuatPDFAndBack(
393 testCompositionJacobian(
394 0, 0, 0,
DEG2RAD(2),
DEG2RAD(0),
DEG2RAD(0), 0, 0, 0,
DEG2RAD(0),
396 testCompositionJacobian(
397 0, 0, 0,
DEG2RAD(2),
DEG2RAD(0),
DEG2RAD(0), 0, 0, 0,
DEG2RAD(0),
399 testCompositionJacobian(
400 1, 2, 3,
DEG2RAD(2),
DEG2RAD(0),
DEG2RAD(0), -8, 45, 10,
DEG2RAD(0),
402 testCompositionJacobian(
403 1, -2, 3,
DEG2RAD(2),
DEG2RAD(0),
DEG2RAD(0), -8, 45, 10,
DEG2RAD(0),
405 testCompositionJacobian(
406 1, 2, -3,
DEG2RAD(2),
DEG2RAD(0),
DEG2RAD(0), -8, 45, 10,
DEG2RAD(0),
408 testCompositionJacobian(
409 1, 2, 3,
DEG2RAD(20),
DEG2RAD(80),
DEG2RAD(70), -8, 45, 10,
DEG2RAD(50),
411 testCompositionJacobian(
414 testCompositionJacobian(
417 testCompositionJacobian(
420 testCompositionJacobian(
421 1, 2, 3,
DEG2RAD(20),
DEG2RAD(80),
DEG2RAD(70), -8, 45, 10,
DEG2RAD(50),
423 testCompositionJacobian(
424 1, 2, 3,
DEG2RAD(20),
DEG2RAD(80),
DEG2RAD(70), -8, 45, 10,
DEG2RAD(50),
431 testAllPoseOperators(
432 0, 0, 0,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1, 0, 0, 0,
DEG2RAD(0),
434 testAllPoseOperators(
435 1, 2, 3,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1, -8, 45, 10,
438 testAllPoseOperators(
439 1, 2, 3,
DEG2RAD(20),
DEG2RAD(80),
DEG2RAD(70), 0.1, -8, 45, 10,
441 testAllPoseOperators(
442 1, 2, 3,
DEG2RAD(20),
DEG2RAD(80),
DEG2RAD(70), 0.2, -8, 45, 10,
445 testAllPoseOperators(
446 1, 2, 3,
DEG2RAD(10),
DEG2RAD(0),
DEG2RAD(0), 0.1, -8, 45, 10,
448 testAllPoseOperators(
449 1, 2, 3,
DEG2RAD(0),
DEG2RAD(10),
DEG2RAD(0), 0.1, -8, 45, 10,
451 testAllPoseOperators(
452 1, 2, 3,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(10), 0.1, -8, 45, 10,
454 testAllPoseOperators(
455 1, 2, 3,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1, -8, 45, 10,
457 testAllPoseOperators(
458 1, 2, 3,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1, -8, 45, 10,
460 testAllPoseOperators(
461 1, 2, 3,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1, -8, 45, 10,
468 0, 0, 0,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1, 0, 0, 0,
DEG2RAD(0),
471 1, 2, 3,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1, -8, 45, 10,
475 1, 2, 3,
DEG2RAD(20),
DEG2RAD(80),
DEG2RAD(70), 0.1, -8, 45, 10,
478 1, 2, 3,
DEG2RAD(20),
DEG2RAD(80),
DEG2RAD(70), 0.2, -8, 45, 10,
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)
double DEG2RAD(const double x)
Degrees to radians.
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.
GLdouble GLdouble GLdouble r
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.
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...
#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)