13 #include <gtest/gtest.h>
14 #include <CTraitsTest.h>
22 template class mrpt::CTraitsTest<mrpt::poses::CPose3DQuat>;
23 template class mrpt::CTraitsTest<mrpt::poses::CPose3D>;
24 template class mrpt::CTraitsTest<mrpt::math::CQuaternionDouble>;
34 CPose3D p1(0, 0, 0, YAW, PITCH, ROLL);
40 (
CPose3D(q1, 0, 0, 0).getAsVectorVal() -
41 CPose3D(q1r, 0, 0, 0).getAsVectorVal())
48 CPose3D p1(0, 0, 0, YAW, PITCH, ROLL);
58 <<
"ypr->quat->ypr failed with:" << endl
59 <<
" p1:" << p1 << endl
60 <<
" q1:" << q1 << endl
61 <<
" p2:" << p2 << endl;
70 <<
"pose constructor from quat failed with:" << endl
71 <<
" p1:" << p1 << endl
72 <<
" q1:" << q1 << endl
73 <<
" p3:" << p3 << endl;
78 const CPose3D pp(0, 0, 0, yaw1, pitch1, roll1);
86 EXPECT_NEAR(0, (q1 - q2).array().abs().
sum(), 1e-10) <<
"q1:\n"
106 EXPECT_NEAR(0, (q1_ln -
v).array().abs().
sum(), 1e-10) <<
"v:\n"
137 <<
"q1 = " << q1 << endl
138 <<
"q1 as CPose3D = " <<
CPose3D(q1, 0, 0, 0) << endl
139 <<
"q2 = " << q2 << endl
140 <<
"q2 as CPose3D = " <<
CPose3D(q2, 0, 0, 0) << endl
141 <<
"q3 = q1 * q2 = " << q3 << endl
142 <<
"q3 as CPose3D = " <<
CPose3D(q3, 0, 0, 0) << endl
143 <<
"Should be equal to p3 = p1 (+) p2 = " << p3 << endl;
165 const double list_test_YPR_angles_degrees[][3] = {
166 {0, 0, 0}, {-1, 0, 0}, {1, 0, 0}, {0, -1, 0},
167 {0, 1, 0}, {0, 0, -1}, {0, 0, 1}, {40, 0, 0},
168 {0, 40, 0}, {0, 0, 40}, {-40, 0, 0}, {0, -40, 0},
169 {0, 0, -40}, {-30, 20, 50}, {-30, 20, -50}, {30, -20, -50}};
171 const size_t N =
sizeof(list_test_YPR_angles_degrees) /
172 sizeof(list_test_YPR_angles_degrees[0]);
173 for (
size_t i = 0; i < N; i++)
174 test_lnAndExpMatches(
175 DEG2RAD(list_test_YPR_angles_degrees[i][0]),
176 DEG2RAD(list_test_YPR_angles_degrees[i][1]),
177 DEG2RAD(list_test_YPR_angles_degrees[i][2]));
182 const double list_test_XYZ[][3] = {
183 {0, 0, 0}, {-1, 0, 0}, {1, 0, 0},
184 {0, -1, 0}, {0, 1, 0}, {0, 0, -1},
185 {0, 0, 1}, {1e-3, 0, 0}, {0, 1e-3, 0},
186 {0, 0, 1e-3}, {-1e-3, 0, 0}, {0, -1e-3, 0},
187 {0, 0, -1e-3}, {-0.1, 0.2, 0.3}, {-0.1, -0.2, 0.3},
188 {-0.1, -0.2, -0.3}, {-0.1, 0.2, -0.3}, {0.1, 0.2, -0.3},
191 const size_t N =
sizeof(list_test_XYZ) /
sizeof(list_test_XYZ[0]);
192 for (
size_t i = 0; i < N; i++)
193 test_ExpAndLnMatches(
194 list_test_XYZ[i][0], list_test_XYZ[i][1], list_test_XYZ[i][2]);