17 #include <gtest/gtest.h> 33 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 =
62 const double cov_mean_error =
63 (p6pdf_recov.
cov - p6pdf.
cov).array().abs().mean();
66 EXPECT_TRUE(val_mean_error < 1e-8);
67 EXPECT_TRUE(cov_mean_error < 1e-8);
76 x[6 + 0],
x[6 + 1],
x[6 + 2],
x[6 + 3],
x[6 + 4],
x[6 + 5]);
78 for (
int i = 0; i < 6; i++) Y[i] =
p[i];
87 x[6 + 0],
x[6 + 1],
x[6 + 2],
x[6 + 3],
x[6 + 4],
x[6 + 5]);
89 for (
int i = 0; i < 6; i++) Y[i] =
p[i];
94 double x,
double y,
double z,
double yaw,
double pitch,
double roll,
95 double std_scale,
double x2,
double y2,
double z2,
double yaw2,
96 double pitch2,
double roll2,
double std_scale2)
99 generateRandomPose3DPDF(
x,
y,
z, yaw,
pitch,
roll, std_scale);
101 x2, y2,
z2, yaw2, pitch2, roll2, std_scale2);
111 for (
int i = 0; i < 6; i++) x_mean[i] = p6pdf1.
mean[i];
112 for (
int i = 0; i < 6; i++) x_mean[6 + i] = p6pdf2.mean[i];
115 x_cov.insertMatrix(0, 0, p6pdf1.
cov);
116 x_cov.insertMatrix(6, 6, p6pdf2.cov);
120 x_incrs.assign(1e-6);
122 x_mean, x_cov, func_compose, DUMMY, y_mean, y_cov, x_incrs);
128 <<
"p1 mean: " << p6pdf1.
mean << endl
129 <<
"p2 mean: " << p6pdf2.mean << endl;
132 EXPECT_NEAR(0, (y_cov - p6_comp.
cov).array().abs().sum(), 1e-2)
133 <<
"p1 mean: " << p6pdf1.
mean << endl
134 <<
"p2 mean: " << p6pdf2.mean << endl;
144 <<
"p1 mean: " << p6pdf1.
mean << endl
145 <<
"p2 mean: " << p6pdf2.mean << endl;
148 EXPECT_NEAR(0, (y_cov - p6_comp.
cov).array().abs().sum(), 1e-2)
149 <<
"p1 mean: " << p6pdf1.
mean << endl
150 <<
"p2 mean: " << p6pdf2.mean << endl;
154 double x,
double y,
double z,
double yaw,
double pitch,
double roll,
155 double x2,
double y2,
double z2,
double yaw2,
double pitch2,
159 const CPose3D q2(x2, y2,
z2, yaw2, pitch2, roll2);
174 for (
int i = 0; i < 6; i++) x_mean[i] = q1[i];
175 for (
int i = 0; i < 6; i++) x_mean[6 + i] = q2[i];
179 x_incrs.assign(1e-7);
182 x_mean, std::function<
void(
185 x_incrs, DUMMY, numJacobs);
187 numJacobs.extractMatrix(0, 0, num_df_dx);
188 numJacobs.extractMatrix(0, 6, num_df_du);
192 EXPECT_NEAR(0, (df_dx - num_df_dx).array().abs().
sum(), 3e-3)
193 <<
"q1: " << q1 << endl
194 <<
"q2: " << q2 << endl
195 <<
"Numeric approximation of df_dx: " << endl
197 <<
"Implemented method: " << endl
200 << df_dx - num_df_dx << endl;
202 EXPECT_NEAR(0, (df_du - num_df_du).array().abs().
sum(), 3e-3)
203 <<
"q1: " << q1 << endl
204 <<
"q2: " << q2 << endl
205 <<
"Numeric approximation of df_du: " << endl
207 <<
"Implemented method: " << endl
210 << df_du - num_df_du << endl;
215 double x,
double y,
double z,
double yaw,
double pitch,
double roll,
216 double std_scale,
double x2,
double y2,
double z2,
double yaw2,
217 double pitch2,
double roll2,
double std_scale2)
220 generateRandomPose3DPDF(
x,
y,
z, yaw,
pitch,
roll, std_scale);
222 x2, y2,
z2, yaw2, pitch2, roll2, std_scale2);
232 for (
int i = 0; i < 6; i++) x_mean[i] = p6pdf1.
mean[i];
233 for (
int i = 0; i < 6; i++) x_mean[6 + i] = p6pdf2.mean[i];
236 x_cov.insertMatrix(0, 0, p6pdf1.
cov);
237 x_cov.insertMatrix(6, 6, p6pdf2.cov);
241 x_incrs.assign(1e-6);
243 x_mean, x_cov, func_inv_compose, DUMMY, y_mean, y_cov, x_incrs);
249 <<
"p1 mean: " << p6pdf1.
mean << endl
250 <<
"p2 mean: " << p6pdf2.mean << endl;
253 EXPECT_NEAR(0, (y_cov - p6_comp.
cov).array().abs().sum(), 1e-2)
254 <<
"p1 mean: " << p6pdf1.
mean << endl
255 <<
"p2 mean: " << p6pdf2.mean << endl;
265 <<
"p1 mean: " << p6pdf1.
mean << endl
266 <<
"p2 mean: " << p6pdf2.mean << endl;
269 EXPECT_NEAR(0, (y_cov - p6_comp.
cov).array().abs().sum(), 1e-2)
270 <<
"p1 mean: " << p6pdf1.
mean << endl
271 <<
"p2 mean: " << p6pdf2.mean << endl;
276 double x,
double y,
double z,
double yaw,
double pitch,
double roll,
280 generateRandomPose3DPDF(
x,
y,
z, yaw,
pitch,
roll, std_scale);
297 <<
"p mean: " << p6pdf2.
mean << endl;
300 EXPECT_NEAR(0, (p6_inv.
cov - p6_comp.
cov).array().abs().sum(), 1e-2)
301 <<
"p mean: " << p6pdf2.mean << endl;
314 <<
"p mean: " << p6pdf2.mean << endl
315 <<
"p6_inv2 mean: " << p6_inv2.mean << endl
316 <<
"p6_comp mean: " << p6_comp.
mean << endl;
319 EXPECT_NEAR(0, (p6_inv2.cov - p6_comp.
cov).array().abs().sum(), 1e-2)
320 <<
"p mean: " << p6pdf2.mean << endl
321 <<
"p6_inv2 mean: " << p6_inv2.mean << endl
322 <<
"p6_comp mean: " << p6_comp.
mean << endl;
327 double x,
double y,
double z,
double yaw,
double pitch,
double roll,
328 double std_scale,
double x2,
double y2,
double z2,
double yaw2,
329 double pitch2,
double roll2,
double std_scale2)
333 x,
y,
z, yaw,
pitch,
roll, std_scale, x2, y2,
z2, yaw2, pitch2,
336 testPoseInverseComposition(
337 x,
y,
z, yaw,
pitch,
roll, std_scale, x2, y2,
z2, yaw2, pitch2,
344 double x,
double y,
double z,
double yaw,
double pitch,
double roll,
345 double std_scale,
double x2,
double y2,
double z2,
double yaw2,
346 double pitch2,
double roll2)
349 generateRandomPose3DPDF(
x,
y,
z, yaw,
pitch,
roll, std_scale);
360 0, (p6_new_base_pdf.
cov - p6pdf1.cov).array().abs().mean(), 1e-2)
361 <<
"p1 mean: " << p6pdf1.mean << endl
362 <<
"new_base: " << new_base << endl;
365 p6pdf1.mean.getAsVectorVal())
370 <<
"p1 mean: " << p6pdf1.mean << endl
371 <<
"new_base: " << new_base << endl;
386 testToQuatPDFAndBack(
388 testToQuatPDFAndBack(
391 testToQuatPDFAndBack(
393 testToQuatPDFAndBack(
399 testCompositionJacobian(
400 0, 0, 0,
DEG2RAD(2),
DEG2RAD(0),
DEG2RAD(0), 0, 0, 0,
DEG2RAD(0),
402 testCompositionJacobian(
403 0, 0, 0,
DEG2RAD(2),
DEG2RAD(0),
DEG2RAD(0), 0, 0, 0,
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(2),
DEG2RAD(0),
DEG2RAD(0), -8, 45, 10,
DEG2RAD(0),
411 testCompositionJacobian(
412 1, 2, -3,
DEG2RAD(2),
DEG2RAD(0),
DEG2RAD(0), -8, 45, 10,
DEG2RAD(0),
414 testCompositionJacobian(
415 1, 2, 3,
DEG2RAD(20),
DEG2RAD(80),
DEG2RAD(70), -8, 45, 10,
DEG2RAD(50),
417 testCompositionJacobian(
420 testCompositionJacobian(
423 testCompositionJacobian(
426 testCompositionJacobian(
427 1, 2, 3,
DEG2RAD(20),
DEG2RAD(80),
DEG2RAD(70), -8, 45, 10,
DEG2RAD(50),
429 testCompositionJacobian(
430 1, 2, 3,
DEG2RAD(20),
DEG2RAD(80),
DEG2RAD(70), -8, 45, 10,
DEG2RAD(50),
437 testAllPoseOperators(
438 0, 0, 0,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1, 0, 0, 0,
DEG2RAD(0),
440 testAllPoseOperators(
441 1, 2, 3,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1, -8, 45, 10,
444 testAllPoseOperators(
445 1, 2, 3,
DEG2RAD(20),
DEG2RAD(80),
DEG2RAD(70), 0.1, -8, 45, 10,
447 testAllPoseOperators(
448 1, 2, 3,
DEG2RAD(20),
DEG2RAD(80),
DEG2RAD(70), 0.2, -8, 45, 10,
451 testAllPoseOperators(
452 1, 2, 3,
DEG2RAD(10),
DEG2RAD(0),
DEG2RAD(0), 0.1, -8, 45, 10,
454 testAllPoseOperators(
455 1, 2, 3,
DEG2RAD(0),
DEG2RAD(10),
DEG2RAD(0), 0.1, -8, 45, 10,
457 testAllPoseOperators(
458 1, 2, 3,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(10), 0.1, -8, 45, 10,
460 testAllPoseOperators(
461 1, 2, 3,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1, -8, 45, 10,
463 testAllPoseOperators(
464 1, 2, 3,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1, -8, 45, 10,
466 testAllPoseOperators(
467 1, 2, 3,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1, -8, 45, 10,
474 0, 0, 0,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1, 0, 0, 0,
DEG2RAD(0),
477 1, 2, 3,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1, -8, 45, 10,
481 1, 2, 3,
DEG2RAD(20),
DEG2RAD(80),
DEG2RAD(70), 0.1, -8, 45, 10,
484 1, 2, 3,
DEG2RAD(20),
DEG2RAD(80),
DEG2RAD(70), 0.2, -8, 45, 10,
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
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)
static void func_compose(const CArrayDouble< 12 > &x, const double &dummy, CArrayDouble< 6 > &Y)
mrpt::math::CVectorDouble getAsVectorVal() const
Return the pose or point as a 1xN vector with all the components (see derived classes for each implem...
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.
for(ctr=DCTSIZE;ctr > 0;ctr--)
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 jacob_numeric_estimate(const VECTORLIKE &x, std::function< void(const VECTORLIKE &x, const USERPARAM &y, VECTORLIKE3 &out)> functor, const VECTORLIKE2 &increments, const USERPARAM &userParam, MATRIXLIKE &out_Jacobian)
Numerical estimation of the Jacobian of a user-supplied function - this template redirects to mrpt::m...
static void func_inv_compose(const CArrayDouble< 2 *6 > &x, const double &dummy, CArrayDouble< 6 > &Y)
A numeric matrix of compile-time fixed size.
This base provides a set of functions for maths stuff.
#define MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler.
void inverse(CPose3DPDF &o) const override
Returns a new PDF such as: NEW_PDF = (0,0,0) - THIS_PDF.
CONTAINER::Scalar sum(const CONTAINER &v)
Computes the sum of all the elements.
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
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)
A partial specialization of CArrayNumeric for double numbers.
Declares a class that represents a Probability Density function (PDF) of a 3D pose ...
Eigen::Matrix< typename MATRIX::Scalar, MATRIX::ColsAtCompileTime, MATRIX::ColsAtCompileTime > cov(const MATRIX &v)
Computes the covariance matrix from a list of samples in an NxM matrix, where each row is a sample...
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)
CMatrixFixedNumeric< double, 6, 6 > CMatrixDouble66