17 #include <gtest/gtest.h> 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,
48 for (
int i = 0; i < 6; i++)
cov(i, i) += 1e-7;
57 generateRandomPose3DPDF(1.0, 2.0, 3.0, yaw,
pitch,
roll, 0.1);
63 EXPECT_NEAR(0, (p2ypr.
cov - p1ypr.
cov).array().abs().mean(), 1e-2)
66 <<
"p1quat : " << endl
79 x[7 + 0],
x[7 + 1],
x[7 + 2],
82 for (
int i = 0; i < 7; i++) Y[i] =
p[i];
92 x[7 + 0],
x[7 + 1],
x[7 + 2],
95 for (
int i = 0; i < 7; i++) Y[i] =
p[i];
99 double x,
double y,
double z,
double yaw,
double pitch,
double roll,
100 double std_scale,
double x2,
double y2,
double z2,
double yaw2,
101 double pitch2,
double roll2,
double std_scale2)
104 generateRandomPoseQuat3DPDF(
x,
y,
z, yaw,
pitch,
roll, std_scale);
106 x2, y2,
z2, yaw2, pitch2, roll2, std_scale2);
115 for (
int i = 0; i < 7; i++) x_mean[i] = p7pdf1.
mean[i];
116 for (
int i = 0; i < 7; i++) x_mean[7 + i] = p7pdf2.mean[i];
119 x_cov.insertMatrix(0, 0, p7pdf1.
cov);
120 x_cov.insertMatrix(7, 7, p7pdf2.cov);
124 x_incrs.assign(1e-6);
126 x_mean, x_cov, func_compose, DUMMY, y_mean, y_cov, x_incrs);
129 EXPECT_NEAR(0, (y_cov - p7_comp.
cov).array().abs().mean(), 1e-2)
130 <<
"p1 mean: " << p7pdf1.
mean << endl
131 <<
"p2 mean: " << p7pdf2.mean << endl
132 <<
"Numeric approximation of covariance: " << endl
134 <<
"Returned covariance: " << endl
135 << p7_comp.
cov << endl;
145 for (
int i = 0; i < 7; i++) Y[i] = p1_inv[i];
149 double x,
double y,
double z,
double yaw,
double pitch,
double roll,
150 double x2,
double y2,
double z2,
double yaw2,
double pitch2,
169 for (
int i = 0; i < 7; i++) x_mean[i] = q1[i];
170 for (
int i = 0; i < 7; i++) x_mean[7 + i] = q2[i];
174 x_incrs.assign(1e-7);
177 x_mean, std::function<
void(
180 x_incrs, DUMMY, numJacobs);
182 numJacobs.extractMatrix(0, 0, num_df_dx);
183 numJacobs.extractMatrix(0, 7, num_df_du);
187 EXPECT_NEAR(0, (df_dx - num_df_dx).array().abs().
sum(), 3e-3)
188 <<
"q1: " << q1 << endl
189 <<
"q2: " << q2 << endl
190 <<
"Numeric approximation of df_dx: " << endl
192 <<
"Implemented method: " << endl
195 << df_dx - num_df_dx << endl;
197 EXPECT_NEAR(0, (df_du - num_df_du).array().abs().
sum(), 3e-3)
198 <<
"q1: " << q1 << endl
199 <<
"q2: " << q2 << endl
200 <<
"Numeric approximation of df_du: " << endl
202 <<
"Implemented method: " << endl
205 << df_du - num_df_du << endl;
209 double x,
double y,
double z,
double yaw,
double pitch,
double roll,
213 generateRandomPoseQuat3DPDF(
x,
y,
z, yaw,
pitch,
roll, std_scale);
222 for (
int i = 0; i < 7; i++) x_mean[i] = p7pdf1.
mean[i];
225 x_cov.insertMatrix(0, 0, p7pdf1.
cov);
229 x_incrs.assign(1e-6);
231 x_mean, x_cov, func_inverse, DUMMY, y_mean, y_cov, x_incrs);
235 EXPECT_NEAR(0, (y_cov - p7_inv.
cov).array().abs().mean(), 1e-2)
236 <<
"p1 mean: " << p7pdf1.
mean << endl
237 <<
"inv mean: " << p7_inv.
mean << endl
238 <<
"Numeric approximation of covariance: " << endl
240 <<
"Returned covariance: " << endl
241 << p7_inv.
cov << endl
243 << y_cov - p7_inv.
cov << endl;
247 double x,
double y,
double z,
double yaw,
double pitch,
double roll,
248 double std_scale,
double x2,
double y2,
double z2,
double yaw2,
249 double pitch2,
double roll2,
double std_scale2)
252 generateRandomPoseQuat3DPDF(
x,
y,
z, yaw,
pitch,
roll, std_scale);
254 x2, y2,
z2, yaw2, pitch2, roll2, std_scale2);
263 for (
int i = 0; i < 7; i++) x_mean[i] = p7pdf1.
mean[i];
264 for (
int i = 0; i < 7; i++) x_mean[7 + i] = p7pdf2.mean[i];
267 x_cov.insertMatrix(0, 0, p7pdf1.
cov);
268 x_cov.insertMatrix(7, 7, p7pdf2.cov);
272 x_incrs.assign(1e-6);
274 x_mean, x_cov, func_inv_compose, DUMMY, y_mean, y_cov, x_incrs);
277 EXPECT_NEAR(0, (y_cov - p7_comp.
cov).array().abs().mean(), 1e-2)
278 <<
"p1 mean: " << p7pdf1.
mean << endl
279 <<
"p2 mean: " << p7pdf2.mean << endl
280 <<
"Numeric approximation of covariance: " << endl
282 <<
"Returned covariance: " << endl
283 << p7_comp.
cov << endl;
287 double x,
double y,
double z,
double yaw,
double pitch,
double roll,
288 double std_scale,
double x2,
double y2,
double z2,
double yaw2,
289 double pitch2,
double roll2)
292 generateRandomPoseQuat3DPDF(
x,
y,
z, yaw,
pitch,
roll, std_scale);
304 0, (p7_new_base_pdf.
cov - p7pdf1.cov).array().abs().mean(), 1e-2)
305 <<
"p1 mean: " << p7pdf1.mean << endl
306 <<
"new_base: " << new_base << endl;
309 p7pdf1.mean.getAsVectorVal())
314 <<
"p1 mean: " << p7pdf1.mean << endl
315 <<
"new_base: " << new_base << endl;
329 testCompositionJacobian(
330 0, 0, 0,
DEG2RAD(2),
DEG2RAD(0),
DEG2RAD(0), 0, 0, 0,
DEG2RAD(0),
332 testCompositionJacobian(
333 1, 2, 3,
DEG2RAD(2),
DEG2RAD(0),
DEG2RAD(0), -8, 45, 10,
DEG2RAD(0),
335 testCompositionJacobian(
336 1, -2, 3,
DEG2RAD(2),
DEG2RAD(0),
DEG2RAD(0), -8, 45, 10,
DEG2RAD(0),
338 testCompositionJacobian(
339 1, 2, -3,
DEG2RAD(2),
DEG2RAD(0),
DEG2RAD(0), -8, 45, 10,
DEG2RAD(0),
341 testCompositionJacobian(
342 1, 2, 3,
DEG2RAD(20),
DEG2RAD(80),
DEG2RAD(70), -8, 45, 10,
DEG2RAD(50),
344 testCompositionJacobian(
347 testCompositionJacobian(
350 testCompositionJacobian(
353 testCompositionJacobian(
354 1, 2, 3,
DEG2RAD(20),
DEG2RAD(80),
DEG2RAD(70), -8, 45, 10,
DEG2RAD(50),
356 testCompositionJacobian(
357 1, 2, 3,
DEG2RAD(20),
DEG2RAD(80),
DEG2RAD(70), -8, 45, 10,
DEG2RAD(50),
400 0, 0, 0,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1, 0, 0, 0,
DEG2RAD(0),
403 1, 2, 3,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1, -8, 45, 10,
407 1, 2, 3,
DEG2RAD(20),
DEG2RAD(80),
DEG2RAD(70), 0.1, -8, 45, 10,
410 1, 2, 3,
DEG2RAD(20),
DEG2RAD(80),
DEG2RAD(70), 0.2, -8, 45, 10,
414 1, 2, 3,
DEG2RAD(10),
DEG2RAD(0),
DEG2RAD(0), 0.1, -8, 45, 10,
417 1, 2, 3,
DEG2RAD(0),
DEG2RAD(10),
DEG2RAD(0), 0.1, -8, 45, 10,
420 1, 2, 3,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(10), 0.1, -8, 45, 10,
423 1, 2, 3,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1, -8, 45, 10,
426 1, 2, 3,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1, -8, 45, 10,
429 1, 2, 3,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1, -8, 45, 10,
435 testPoseInverseComposition(
436 0, 0, 0,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1, 0, 0, 0,
DEG2RAD(0),
438 testPoseInverseComposition(
439 1, 2, 3,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1, -8, 45, 10,
442 testPoseInverseComposition(
443 1, 2, 3,
DEG2RAD(20),
DEG2RAD(80),
DEG2RAD(70), 0.1, -8, 45, 10,
445 testPoseInverseComposition(
446 1, 2, 3,
DEG2RAD(20),
DEG2RAD(80),
DEG2RAD(70), 0.2, -8, 45, 10,
449 testPoseInverseComposition(
450 1, 2, 3,
DEG2RAD(10),
DEG2RAD(0),
DEG2RAD(0), 0.1, -8, 45, 10,
452 testPoseInverseComposition(
453 1, 2, 3,
DEG2RAD(0),
DEG2RAD(10),
DEG2RAD(0), 0.1, -8, 45, 10,
455 testPoseInverseComposition(
456 1, 2, 3,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(10), 0.1, -8, 45, 10,
458 testPoseInverseComposition(
459 1, 2, 3,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1, -8, 45, 10,
461 testPoseInverseComposition(
462 1, 2, 3,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1, -8, 45, 10,
464 testPoseInverseComposition(
465 1, 2, 3,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1, -8, 45, 10,
472 0, 0, 0,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1, 0, 0, 0,
DEG2RAD(0),
475 1, 2, 3,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1, -8, 45, 10,
479 1, 2, 3,
DEG2RAD(20),
DEG2RAD(80),
DEG2RAD(70), 0.1, -8, 45, 10,
482 1, 2, 3,
DEG2RAD(20),
DEG2RAD(80),
DEG2RAD(70), 0.2, -8, 45, 10,
CMatrixFixedNumeric< double, 7, 7 > CMatrixDouble77
void changeCoordinatesReference(const CPose3DQuat &newReferenceBase)
this = p (+) this.
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
static CPose3DPDFGaussian generateRandomPose3DPDF(double x, double y, double z, double yaw, double pitch, double roll, double std_scale)
mrpt::math::CVectorDouble getAsVectorVal() const
Return the pose or point as a 1xN vector with all the components (see derived classes for each implem...
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.
CQuaternion< double > CQuaternionDouble
A quaternion of data type "double".
mrpt::math::CMatrixDouble77 cov
The 7x7 covariance matrix.
for(ctr=DCTSIZE;ctr > 0;ctr--)
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_compose(const CArrayDouble< 2 *7 > &x, const double &dummy, CArrayDouble< 7 > &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.
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).
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
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.
GLdouble GLdouble GLdouble r
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)
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...
static void func_inverse(const CArrayDouble< 7 > &x, const double &dummy, CArrayDouble< 7 > &Y)
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.
static void func_inv_compose(const CArrayDouble< 2 *7 > &x, const double &dummy, CArrayDouble< 7 > &Y)
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 CPose3DQuatPDFGaussian generateRandomPoseQuat3DPDF(double x, double y, double z, double yaw, double pitch, double roll, double std_scale)