16 #include <gtest/gtest.h> 45 for (
int i=0;i<6;i++)
cov(i,i)+=1e-7;
60 EXPECT_NEAR(0,(p2ypr.
cov - p1ypr.
cov).array().abs().mean(), 1e-2)
61 <<
"p1ypr: " << endl << p1ypr << endl
62 <<
"p1quat : " << endl << p1quat << endl
63 <<
"p2ypr : " << endl << p2ypr << endl;
72 for (
int i=0;i<7;i++) Y[i]=
p[i];
81 for (
int i=0;i<7;i++) Y[i]=
p[i];
85 double x,
double y,
double z,
double yaw,
double pitch,
double roll,
double std_scale,
86 double x2,
double y2,
double z2,
double yaw2,
double pitch2,
double roll2,
double std_scale2 )
98 for (
int i=0;i<7;i++) x_mean[i]=p7pdf1.
mean[i];
99 for (
int i=0;i<7;i++) x_mean[7+i]=p7pdf2.mean[i];
102 x_cov.insertMatrix(0,0, p7pdf1.
cov);
103 x_cov.insertMatrix(7,7, p7pdf2.cov);
107 x_incrs.assign(1e-6);
112 EXPECT_NEAR(0, (y_cov-p7_comp.
cov).array().abs().mean(), 1e-2 )
113 <<
"p1 mean: " << p7pdf1.
mean << endl
114 <<
"p2 mean: " << p7pdf2.mean << endl
115 <<
"Numeric approximation of covariance: " << endl << y_cov << endl
116 <<
"Returned covariance: " << endl << p7_comp.
cov << endl;
125 for (
int i=0;i<7;i++) Y[i]=p1_inv[i];
129 double x,
double y,
double z,
double yaw,
double pitch,
double roll,
130 double x2,
double y2,
double z2,
double yaw2,
double pitch2,
double roll2)
147 for (
int i=0;i<7;i++) x_mean[i]=q1[i];
148 for (
int i=0;i<7;i++) x_mean[7+i]=q2[i];
152 x_incrs.assign(1e-7);
156 numJacobs.extractMatrix(0,0, num_df_dx);
157 numJacobs.extractMatrix(0,7, num_df_du);
161 EXPECT_NEAR(0, (df_dx-num_df_dx).array().abs().
sum(), 3e-3 )
162 <<
"q1: " << q1 << endl
163 <<
"q2: " << q2 << endl
164 <<
"Numeric approximation of df_dx: " << endl << num_df_dx << endl
165 <<
"Implemented method: " << endl << df_dx << endl
166 <<
"Error: " << endl << df_dx-num_df_dx << endl;
168 EXPECT_NEAR(0, (df_du-num_df_du).array().abs().
sum(), 3e-3 )
169 <<
"q1: " << q1 << endl
170 <<
"q2: " << q2 << endl
171 <<
"Numeric approximation of df_du: " << endl << num_df_du << endl
172 <<
"Implemented method: " << endl << df_du << endl
173 <<
"Error: " << endl << df_du-num_df_du << endl;
187 for (
int i=0;i<7;i++) x_mean[i]=p7pdf1.
mean[i];
190 x_cov.insertMatrix(0,0, p7pdf1.
cov);
194 x_incrs.assign(1e-6);
199 EXPECT_NEAR(0, (y_cov-p7_inv.
cov).array().abs().mean(), 1e-2 )
200 <<
"p1 mean: " << p7pdf1.
mean << endl
201 <<
"inv mean: " << p7_inv.
mean << endl
202 <<
"Numeric approximation of covariance: " << endl << y_cov << endl
203 <<
"Returned covariance: " << endl << p7_inv.
cov << endl
204 <<
"Error: " << endl << y_cov-p7_inv.
cov << endl;
209 double x,
double y,
double z,
double yaw,
double pitch,
double roll,
double std_scale,
210 double x2,
double y2,
double z2,
double yaw2,
double pitch2,
double roll2,
double std_scale2 )
222 for (
int i=0;i<7;i++) x_mean[i]=p7pdf1.
mean[i];
223 for (
int i=0;i<7;i++) x_mean[7+i]=p7pdf2.mean[i];
226 x_cov.insertMatrix(0,0, p7pdf1.
cov);
227 x_cov.insertMatrix(7,7, p7pdf2.cov);
231 x_incrs.assign(1e-6);
236 EXPECT_NEAR(0, (y_cov-p7_comp.
cov).array().abs().mean(), 1e-2 )
237 <<
"p1 mean: " << p7pdf1.
mean << endl
238 <<
"p2 mean: " << p7pdf2.mean << endl
239 <<
"Numeric approximation of covariance: " << endl << y_cov << endl
240 <<
"Returned covariance: " << endl << p7_comp.
cov << endl;
245 double x,
double y,
double z,
double yaw,
double pitch,
double roll,
double std_scale,
246 double x2,
double y2,
double z2,
double yaw2,
double pitch2,
double roll2 )
257 EXPECT_NEAR(0, (p7_new_base_pdf.
cov - p7pdf1.cov).array().abs().mean(), 1e-2 )
258 <<
"p1 mean: " << p7pdf1.mean << endl
259 <<
"new_base: " << new_base << endl;
260 EXPECT_NEAR(0, (p7_new_base_pdf.
mean.
getAsVectorVal() - p7pdf1.mean.getAsVectorVal() ).array().abs().mean(), 1e-2 )
261 <<
"p1 mean: " << p7pdf1.mean << endl
262 <<
"new_base: " << new_base << endl;
278 testCompositionJacobian(0,0,0,
DEG2RAD(2),
DEG2RAD(0),
DEG2RAD(0), 0,0,0,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0) );
279 testCompositionJacobian(1,2,3,
DEG2RAD(2),
DEG2RAD(0),
DEG2RAD(0), -8,45,10,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0) );
280 testCompositionJacobian(1,-2,3,
DEG2RAD(2),
DEG2RAD(0),
DEG2RAD(0), -8,45,10,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0) );
281 testCompositionJacobian(1,2,-3,
DEG2RAD(2),
DEG2RAD(0),
DEG2RAD(0), -8,45,10,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0) );
282 testCompositionJacobian(1,2,3,
DEG2RAD(20),
DEG2RAD(80),
DEG2RAD(70), -8,45,10,
DEG2RAD(50),
DEG2RAD(-10),
DEG2RAD(30) );
283 testCompositionJacobian(1,2,3,
DEG2RAD(20),
DEG2RAD(-80),
DEG2RAD(70), -8,45,10,
DEG2RAD(50),
DEG2RAD(-10),
DEG2RAD(30) );
284 testCompositionJacobian(1,2,3,
DEG2RAD(20),
DEG2RAD(80),
DEG2RAD(-70), -8,45,10,
DEG2RAD(50),
DEG2RAD(-10),
DEG2RAD(30) );
285 testCompositionJacobian(1,2,3,
DEG2RAD(20),
DEG2RAD(80),
DEG2RAD(70), -8,45,10,
DEG2RAD(-50),
DEG2RAD(-10),
DEG2RAD(30) );
286 testCompositionJacobian(1,2,3,
DEG2RAD(20),
DEG2RAD(80),
DEG2RAD(70), -8,45,10,
DEG2RAD(50),
DEG2RAD(10),
DEG2RAD(30) );
287 testCompositionJacobian(1,2,3,
DEG2RAD(20),
DEG2RAD(80),
DEG2RAD(70), -8,45,10,
DEG2RAD(50),
DEG2RAD(-10),
DEG2RAD(-30) );
328 testPoseComposition(0,0,0,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1, 0,0,0,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1 );
329 testPoseComposition(1,2,3,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1, -8,45,10,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1 );
331 testPoseComposition(1,2,3,
DEG2RAD(20),
DEG2RAD(80),
DEG2RAD(70), 0.1, -8,45,10,
DEG2RAD(50),
DEG2RAD(-10),
DEG2RAD(30), 0.1 );
332 testPoseComposition(1,2,3,
DEG2RAD(20),
DEG2RAD(80),
DEG2RAD(70), 0.2, -8,45,10,
DEG2RAD(50),
DEG2RAD(-10),
DEG2RAD(30), 0.2 );
334 testPoseComposition(1,2,3,
DEG2RAD(10),
DEG2RAD(0),
DEG2RAD(0), 0.1, -8,45,10,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1 );
335 testPoseComposition(1,2,3,
DEG2RAD(0),
DEG2RAD(10),
DEG2RAD(0), 0.1, -8,45,10,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1 );
336 testPoseComposition(1,2,3,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(10), 0.1, -8,45,10,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1 );
337 testPoseComposition(1,2,3,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1, -8,45,10,
DEG2RAD(10),
DEG2RAD(0),
DEG2RAD(0), 0.1 );
338 testPoseComposition(1,2,3,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1, -8,45,10,
DEG2RAD(0),
DEG2RAD(10),
DEG2RAD(0), 0.1 );
339 testPoseComposition(1,2,3,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1, -8,45,10,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(10), 0.1 );
344 testPoseInverseComposition(0,0,0,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1, 0,0,0,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1 );
345 testPoseInverseComposition(1,2,3,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1, -8,45,10,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1 );
347 testPoseInverseComposition(1,2,3,
DEG2RAD(20),
DEG2RAD(80),
DEG2RAD(70), 0.1, -8,45,10,
DEG2RAD(50),
DEG2RAD(-10),
DEG2RAD(30), 0.1 );
348 testPoseInverseComposition(1,2,3,
DEG2RAD(20),
DEG2RAD(80),
DEG2RAD(70), 0.2, -8,45,10,
DEG2RAD(50),
DEG2RAD(-10),
DEG2RAD(30), 0.2 );
350 testPoseInverseComposition(1,2,3,
DEG2RAD(10),
DEG2RAD(0),
DEG2RAD(0), 0.1, -8,45,10,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1 );
351 testPoseInverseComposition(1,2,3,
DEG2RAD(0),
DEG2RAD(10),
DEG2RAD(0), 0.1, -8,45,10,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1 );
352 testPoseInverseComposition(1,2,3,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(10), 0.1, -8,45,10,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1 );
353 testPoseInverseComposition(1,2,3,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1, -8,45,10,
DEG2RAD(10),
DEG2RAD(0),
DEG2RAD(0), 0.1 );
354 testPoseInverseComposition(1,2,3,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1, -8,45,10,
DEG2RAD(0),
DEG2RAD(10),
DEG2RAD(0), 0.1 );
355 testPoseInverseComposition(1,2,3,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1, -8,45,10,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(10), 0.1 );
361 testChangeCoordsRef(0,0,0,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1, 0,0,0,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0) );
362 testChangeCoordsRef(1,2,3,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0.1, -8,45,10,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0) );
364 testChangeCoordsRef(1,2,3,
DEG2RAD(20),
DEG2RAD(80),
DEG2RAD(70), 0.1, -8,45,10,
DEG2RAD(50),
DEG2RAD(-10),
DEG2RAD(30) );
365 testChangeCoordsRef(1,2,3,
DEG2RAD(20),
DEG2RAD(80),
DEG2RAD(70), 0.2, -8,45,10,
DEG2RAD(50),
DEG2RAD(-10),
DEG2RAD(30) );
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.
BASE_IMPEXP CRandomGenerator randomGenerator
A static instance of a CRandomGenerator class, for use in single-thread applications.
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.
Declares a class that represents a Probability Density function (PDF) of a 3D pose using a quaternion...
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.
CMatrixFixedNumeric< double, 7, 7 > CMatrixDouble77
#define MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler.
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...
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)
static void jacobiansPoseComposition(const CPose3DQuat &x, const CPose3DQuat &u, mrpt::math::CMatrixDouble77 &df_dx, mrpt::math::CMatrixDouble77 &df_du, CPose3DQuat *out_x_oplus_u=NULL)
This static method computes the two Jacobians of a pose composition operation $f(x,u)= x u$.
A partial specialization of CArrayNumeric for double numbers.
Declares a class that represents a Probability Density function (PDF) of a 3D pose ...
void jacob_numeric_estimate(const VECTORLIKE &x, void(*functor)(const VECTORLIKE &x, const USERPARAM &y, VECTORLIKE3 &out), 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_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)
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)
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)