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);
64 EXPECT_NEAR(0, (p2ypr.
cov - p1ypr.
cov).array().abs().mean(), 1e-2)
67 <<
"p1quat : " << endl
81 x[7 + 0],
x[7 + 1],
x[7 + 2],
84 for (
int i = 0; i < 7; i++) Y[i] =
p[i];
95 x[7 + 0],
x[7 + 1],
x[7 + 2],
98 for (
int i = 0; i < 7; i++) Y[i] =
p[i];
102 double x,
double y,
double z,
double yaw,
double pitch,
double roll,
103 double std_scale,
double x2,
double y2,
double z2,
double yaw2,
104 double pitch2,
double roll2,
double std_scale2)
107 generateRandomPoseQuat3DPDF(
x,
y,
z, yaw,
pitch,
roll, std_scale);
109 x2, y2, z2, yaw2, pitch2, roll2, std_scale2);
118 for (
int i = 0; i < 7; i++) x_mean[i] = p7pdf1.
mean[i];
119 for (
int i = 0; i < 7; i++) x_mean[7 + i] = p7pdf2.mean[i];
123 x_cov.insertMatrix(7, 7, p7pdf2.cov);
129 x_mean, x_cov, func_compose, DUMMY, y_mean, y_cov, x_incrs);
132 EXPECT_NEAR(0, (y_cov - p7_comp.
cov).array().abs().mean(), 1e-2)
133 <<
"p1 mean: " << p7pdf1.
mean << endl
134 <<
"p2 mean: " << p7pdf2.mean << endl
135 <<
"Numeric approximation of covariance: " << endl
137 <<
"Returned covariance: " << endl
138 << p7_comp.
cov << endl;
149 for (
int i = 0; i < 7; i++) Y[i] = p1_inv[i];
153 double x,
double y,
double z,
double yaw,
double pitch,
double roll,
154 double x2,
double y2,
double z2,
double yaw2,
double pitch2,
173 for (
int i = 0; i < 7; i++) x_mean[i] = q1[i];
174 for (
int i = 0; i < 7; i++) x_mean[7 + i] = q2[i];
185 x_incrs, DUMMY, numJacobs);
187 num_df_dx = numJacobs.
block<7, 7>(0, 0);
188 num_df_du = numJacobs.
block<7, 7>(0, 7);
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;
214 double x,
double y,
double z,
double yaw,
double pitch,
double roll,
218 generateRandomPoseQuat3DPDF(
x,
y,
z, yaw,
pitch,
roll, std_scale);
227 for (
int i = 0; i < 7; i++) x_mean[i] = p7pdf1.
mean[i];
236 x_mean, x_cov, func_inverse, DUMMY, y_mean, y_cov, x_incrs);
240 EXPECT_NEAR(0, (y_cov - p7_inv.
cov).array().abs().mean(), 1e-2)
241 <<
"p1 mean: " << p7pdf1.
mean << endl
242 <<
"inv mean: " << p7_inv.
mean << endl
243 <<
"Numeric approximation of covariance: " << endl
245 <<
"Returned covariance: " << endl
246 << p7_inv.
cov << endl
248 << y_cov - p7_inv.
cov << endl;
252 double x,
double y,
double z,
double yaw,
double pitch,
double roll,
253 double std_scale,
double x2,
double y2,
double z2,
double yaw2,
254 double pitch2,
double roll2,
double std_scale2)
257 generateRandomPoseQuat3DPDF(
x,
y,
z, yaw,
pitch,
roll, std_scale);
259 x2, y2, z2, yaw2, pitch2, roll2, std_scale2);
268 for (
int i = 0; i < 7; i++) x_mean[i] = p7pdf1.
mean[i];
269 for (
int i = 0; i < 7; i++) x_mean[7 + i] = p7pdf2.mean[i];
273 x_cov.insertMatrix(7, 7, p7pdf2.cov);
279 x_mean, x_cov, func_inv_compose, DUMMY, y_mean, y_cov, x_incrs);
282 EXPECT_NEAR(0, (y_cov - p7_comp.
cov).array().abs().mean(), 1e-2)
283 <<
"p1 mean: " << p7pdf1.
mean << endl
284 <<
"p2 mean: " << p7pdf2.mean << endl
285 <<
"Numeric approximation of covariance: " << endl
287 <<
"Returned covariance: " << endl
288 << p7_comp.
cov << endl;
292 double x,
double y,
double z,
double yaw,
double pitch,
double roll,
293 double std_scale,
double x2,
double y2,
double z2,
double yaw2,
294 double pitch2,
double roll2)
297 generateRandomPoseQuat3DPDF(
x,
y,
z, yaw,
pitch,
roll, std_scale);
309 0, (p7_new_base_pdf.
cov - p7pdf1.cov).array().abs().mean(), 1e-2)
310 <<
"p1 mean: " << p7pdf1.mean << endl
311 <<
"new_base: " << new_base << endl;
319 <<
"p1 mean: " << p7pdf1.mean << endl
320 <<
"new_base: " << new_base << endl;
334 testCompositionJacobian(
335 0, 0, 0,
DEG2RAD(2),
DEG2RAD(0),
DEG2RAD(0), 0, 0, 0,
DEG2RAD(0),
337 testCompositionJacobian(
338 1, 2, 3,
DEG2RAD(2),
DEG2RAD(0),
DEG2RAD(0), -8, 45, 10,
DEG2RAD(0),
340 testCompositionJacobian(
341 1, -2, 3,
DEG2RAD(2),
DEG2RAD(0),
DEG2RAD(0), -8, 45, 10,
DEG2RAD(0),
343 testCompositionJacobian(
344 1, 2, -3,
DEG2RAD(2),
DEG2RAD(0),
DEG2RAD(0), -8, 45, 10,
DEG2RAD(0),
346 testCompositionJacobian(
347 1, 2, 3,
DEG2RAD(20),
DEG2RAD(80),
DEG2RAD(70), -8, 45, 10,
DEG2RAD(50),
349 testCompositionJacobian(
352 testCompositionJacobian(
355 testCompositionJacobian(
358 testCompositionJacobian(
359 1, 2, 3,
DEG2RAD(20),
DEG2RAD(80),
DEG2RAD(70), -8, 45, 10,
DEG2RAD(50),
361 testCompositionJacobian(
362 1, 2, 3,
DEG2RAD(20),
DEG2RAD(80),
DEG2RAD(70), -8, 45, 10,
DEG2RAD(50),
405 0, 0, 0,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1, 0, 0, 0,
DEG2RAD(0),
408 1, 2, 3,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1, -8, 45, 10,
412 1, 2, 3,
DEG2RAD(20),
DEG2RAD(80),
DEG2RAD(70), 0.1, -8, 45, 10,
415 1, 2, 3,
DEG2RAD(20),
DEG2RAD(80),
DEG2RAD(70), 0.2, -8, 45, 10,
419 1, 2, 3,
DEG2RAD(10),
DEG2RAD(0),
DEG2RAD(0), 0.1, -8, 45, 10,
422 1, 2, 3,
DEG2RAD(0),
DEG2RAD(10),
DEG2RAD(0), 0.1, -8, 45, 10,
425 1, 2, 3,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(10), 0.1, -8, 45, 10,
428 1, 2, 3,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1, -8, 45, 10,
431 1, 2, 3,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1, -8, 45, 10,
434 1, 2, 3,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1, -8, 45, 10,
440 testPoseInverseComposition(
441 0, 0, 0,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1, 0, 0, 0,
DEG2RAD(0),
443 testPoseInverseComposition(
444 1, 2, 3,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1, -8, 45, 10,
447 testPoseInverseComposition(
448 1, 2, 3,
DEG2RAD(20),
DEG2RAD(80),
DEG2RAD(70), 0.1, -8, 45, 10,
450 testPoseInverseComposition(
451 1, 2, 3,
DEG2RAD(20),
DEG2RAD(80),
DEG2RAD(70), 0.2, -8, 45, 10,
454 testPoseInverseComposition(
455 1, 2, 3,
DEG2RAD(10),
DEG2RAD(0),
DEG2RAD(0), 0.1, -8, 45, 10,
457 testPoseInverseComposition(
458 1, 2, 3,
DEG2RAD(0),
DEG2RAD(10),
DEG2RAD(0), 0.1, -8, 45, 10,
460 testPoseInverseComposition(
461 1, 2, 3,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(10), 0.1, -8, 45, 10,
463 testPoseInverseComposition(
464 1, 2, 3,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1, -8, 45, 10,
466 testPoseInverseComposition(
467 1, 2, 3,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1, -8, 45, 10,
469 testPoseInverseComposition(
470 1, 2, 3,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1, -8, 45, 10,
477 0, 0, 0,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1, 0, 0, 0,
DEG2RAD(0),
480 1, 2, 3,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1, -8, 45, 10,
484 1, 2, 3,
DEG2RAD(20),
DEG2RAD(80),
DEG2RAD(70), 0.1, -8, 45, 10,
487 1, 2, 3,
DEG2RAD(20),
DEG2RAD(80),
DEG2RAD(70), 0.2, -8, 45, 10,
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)
double DEG2RAD(const double x)
Degrees to radians.
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
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
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...
static void func_inv_compose(const CVectorFixedDouble< 2 *7 > &x, const double &dummy, CVectorFixedDouble< 7 > &Y)
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.
static void func_inverse(const CVectorFixedDouble< 7 > &x, const double &dummy, CVectorFixedDouble< 7 > &Y)
GLdouble GLdouble GLdouble r
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
static void func_compose(const CVectorFixedDouble< 2 *7 > &x, const double &dummy, CVectorFixedDouble< 7 > &Y)
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)
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)
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 CPose3DQuatPDFGaussian generateRandomPoseQuat3DPDF(double x, double y, double z, double yaw, double pitch, double roll, double std_scale)