15 #include <gtest/gtest.h> 22 template <
class POSE_TYPE>
32 typename SE_TYPE::pose_t P1, D,
P2;
39 typename SE_TYPE::array_t eps1, eps2;
40 for (
int i = 0; i < SE_TYPE::VECTOR_SIZE; i++)
43 eps2[i] =
x[SE_TYPE::VECTOR_SIZE + i];
46 POSE_TYPE incr1, incr2;
47 SE_TYPE::exp(eps1, incr1);
48 SE_TYPE::exp(eps2, incr2);
50 const POSE_TYPE P1 = incr1 +
params.P1;
51 const POSE_TYPE P2 = incr2 +
params.P2;
52 const POSE_TYPE& Pd =
params.D;
55 P1.getHomogeneousMatrix(P1hm);
56 Pd.getHomogeneousMatrix(Pdhm);
57 P2.getInverseHomogeneousMatrix(HM_P2inv);
60 const POSE_TYPE P1DP2inv(P1DP2inv_);
63 SE_TYPE::pseudo_ln(P1DP2inv, Y);
67 double x1,
double y1,
double z1,
double yaw1,
double pitch1,
68 double roll1,
double xd,
double yd,
double zd,
double yawd,
69 double pitchd,
double rolld,
double x2,
double y2,
double z2,
70 double yaw2,
double pitch2,
double roll2)
72 const CPose3D P1_(x1, y1, z1, yaw1, pitch1, roll1);
73 const CPose3D Pd_(xd, yd, zd, yawd, pitchd, rolld);
74 const CPose3D P2_(x2, y2, z2, yaw2, pitch2, roll2);
76 const POSE_TYPE P1(P1_);
77 const POSE_TYPE Pd(Pd_);
78 const POSE_TYPE P2(P2_);
81 P1.getHomogeneousMatrix(P1hm);
82 Pd.getHomogeneousMatrix(Pdhm);
83 P2.getInverseHomogeneousMatrix(HM_P2inv);
85 const POSE_TYPE P1DP2inv(P1DP2inv_);
87 static const int DIMS = SE_TYPE::VECTOR_SIZE;
91 SE_TYPE::jacobian_dP1DP2inv_depsilon(P1DP2inv, &J1, &J2);
97 for (
int i = 0; i < DIMS + DIMS; i++) x_mean[i] = 0;
105 x_incrs.assign(1e-4);
113 x_incrs,
params, numJacobs);
115 numJacobs.extractMatrix(0, 0, num_J1);
116 numJacobs.extractMatrix(0, DIMS, num_J2);
119 const double max_eror = 1e-3;
121 EXPECT_NEAR(0, (num_J1 - J1).array().abs().
sum(), max_eror)
122 <<
"p1: " << P1 << endl
123 <<
"d: " << Pd << endl
124 <<
"p2: " << P2 << endl
127 <<
"Implemented J1:\n" 130 << J1 - num_J1 << endl;
132 EXPECT_NEAR(0, (num_J2 - J2).array().abs().
sum(), max_eror)
133 <<
"p1: " << P1 << endl
134 <<
"d: " << Pd << endl
135 <<
"p2: " << P2 << endl
138 <<
"Implemented J2:\n" 141 << J2 - num_J2 << endl;
146 test_jacobs_P1DP2inv(
147 0, 0, 0,
DEG2RAD(0),
DEG2RAD(0),
DEG2RAD(0), 0, 0, 0,
DEG2RAD(0),
151 test_jacobs_P1DP2inv(
152 0, 0, 0,
DEG2RAD(10),
DEG2RAD(0),
DEG2RAD(0), 0, 0, 0,
DEG2RAD(10),
156 test_jacobs_P1DP2inv(
157 0, 0, 0,
DEG2RAD(10),
DEG2RAD(0),
DEG2RAD(0), 0, 0, 0,
DEG2RAD(12),
161 test_jacobs_P1DP2inv(
162 0, 0, 0,
DEG2RAD(10),
DEG2RAD(20),
DEG2RAD(30), 0, 0, 0,
DEG2RAD(4),
166 test_jacobs_P1DP2inv(
171 test_jacobs_P1DP2inv(
176 test_jacobs_P1DP2inv(
void do_all_jacobs_test()
double DEG2RAD(const double x)
Degrees to radians.
CMatrixFixedNumeric< double, 4, 4 > CMatrixDouble44
TEST_F(SE3_traits_tests, SE3_jacobs)
CArrayNumeric is an array for numeric types supporting several mathematical operations (actually...
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...
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.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
A helper class for SE(2) and SE(3) geometry-related transformations, on-manifold optimization Jacobia...
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)
GLenum const GLfloat * params