13 #include <gtest/gtest.h> 22 template <
class POSE_TYPE>
30 typedef mrpt::poses::SE_traits<POSE_TYPE::rotation_dimensions>
SE_TYPE;
34 typename SE_TYPE::pose_t P1, D,
P2;
42 typename SE_TYPE::array_t eps1, eps2;
43 for (
int i=0;i<SE_TYPE::VECTOR_SIZE;i++)
46 eps2[i] =
x[SE_TYPE::VECTOR_SIZE+i];
49 POSE_TYPE incr1, incr2;
50 SE_TYPE::exp(eps1,incr1);
51 SE_TYPE::exp(eps2,incr2);
53 const POSE_TYPE P1 = incr1 +
params.P1;
54 const POSE_TYPE P2 = incr2 +
params.P2;
55 const POSE_TYPE &Pd =
params.D;
57 const CPose3D P1DP2inv_(
CMatrixDouble44(P1.getHomogeneousMatrixVal() * Pd.getHomogeneousMatrixVal() * P2.getInverseHomogeneousMatrix()));
58 const POSE_TYPE P1DP2inv(P1DP2inv_);
61 SE_TYPE::pseudo_ln(P1DP2inv,Y);
65 double x1,
double y1,
double z1,
double yaw1,
double pitch1,
double roll1,
66 double xd,
double yd,
double zd,
double yawd,
double pitchd,
double rolld,
67 double x2,
double y2,
double z2,
double yaw2,
double pitch2,
double roll2)
69 const CPose3D P1_(x1,y1,z1,yaw1,pitch1,roll1);
70 const CPose3D Pd_(xd,yd,zd,yawd,pitchd,rolld);
71 const CPose3D P2_(x2,y2,z2,yaw2,pitch2,roll2);
73 const POSE_TYPE P1(P1_);
74 const POSE_TYPE Pd(Pd_);
75 const POSE_TYPE P2(P2_);
77 const CPose3D P1DP2inv_(
CMatrixDouble44(P1.getHomogeneousMatrixVal() * Pd.getHomogeneousMatrixVal() * P2.getInverseHomogeneousMatrix()));
78 const POSE_TYPE P1DP2inv(P1DP2inv_);
80 static const int DIMS = SE_TYPE::VECTOR_SIZE;
84 SE_TYPE::jacobian_dP1DP2inv_depsilon(P1DP2inv, &J1, &J2);
90 for (
int i=0;i<DIMS+DIMS;i++) x_mean[i]=0;
102 numJacobs.extractMatrix(0,0, num_J1);
103 numJacobs.extractMatrix(0,DIMS, num_J2);
106 const double max_eror = 1e-3;
108 EXPECT_NEAR(0, (num_J1-J1).array().abs().
sum(), max_eror )
109 <<
"p1: " << P1 << endl
110 <<
"d: " << Pd << endl
111 <<
"p2: " << P2 << endl
112 <<
"Numeric J1:\n" << num_J1 << endl
113 <<
"Implemented J1:\n" << J1 << endl
114 <<
"Error:\n" << J1-num_J1 << endl;
116 EXPECT_NEAR(0, (num_J2-J2).array().abs().
sum(), max_eror )
117 <<
"p1: " << P1 << endl
118 <<
"d: " << Pd << endl
119 <<
"p2: " << P2 << endl
120 <<
"Numeric J2:\n" << num_J2 << endl
121 <<
"Implemented J2:\n" << J2 << endl
122 <<
"Error:\n" << J2-num_J2 << endl;
128 test_jacobs_P1DP2inv(
133 test_jacobs_P1DP2inv(
138 test_jacobs_P1DP2inv(
143 test_jacobs_P1DP2inv(
148 test_jacobs_P1DP2inv(
153 test_jacobs_P1DP2inv(
158 test_jacobs_P1DP2inv(
170 do_all_jacobs_test();
175 do_all_jacobs_test();
void do_all_jacobs_test()
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
mrpt::poses::SE_traits< POSE_TYPE::rotation_dimensions > SE_TYPE
TEST_F(SE3_traits_tests, SE3_jacobs)
CMatrixFixedNumeric< double, 4, 4 > CMatrixDouble44
A numeric matrix of compile-time fixed size.
This base provides a set of functions for maths stuff.
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...
static void func_numeric(const CArrayDouble< 2 *SE_TYPE::VECTOR_SIZE > &x, const TParams ¶ms, CArrayDouble< SE_TYPE::VECTOR_SIZE > &Y)
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
SE_traits_tests< mrpt::poses::CPose3D > SE3_traits_tests
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
A partial specialization of CArrayNumeric for double numbers.
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...
void test_jacobs_P1DP2inv(double x1, double y1, double z1, double yaw1, double pitch1, double roll1, double xd, double yd, double zd, double yawd, double pitchd, double rolld, double x2, double y2, double z2, double yaw2, double pitch2, double roll2)
SE_traits_tests< mrpt::poses::CPose2D > SE2_traits_tests
GLenum const GLfloat * params