14 #include <CTraitsTest.h>
15 #include <gtest/gtest.h>
23 template class mrpt::CTraitsTest<CPose3DQuat>;
31 double x1,
double y1,
double z1,
double yaw1,
double pitch1,
32 double roll1,
double x2,
double y2,
double z2,
double yaw2,
33 double pitch2,
double roll2)
35 const CPose3D p1(x1, y1, z1, yaw1, pitch1, roll1);
36 const CPose3D p2(x2, y2, z2, yaw2, pitch2, roll2);
38 const CPose3D p1_c_p2 = p1 + p2;
39 const CPose3D p1_i_p2 = p1 - p2;
56 <<
"p1_c_p2: " << p1_c_p2 << endl
57 <<
"q1_c_p2: " << p_q1_c_q2 << endl;
65 <<
"p1_i_p2: " << p1_i_p2 << endl
66 <<
"q1_i_p2: " << p_q1_i_q2 << endl;
104 double x1,
double y1,
double z1,
double yaw1,
double pitch1,
105 double roll1,
double x,
double y,
double z)
107 const CPose3D p1(x1, y1, z1, yaw1, pitch1, roll1);
120 <<
"p1: " << p1 << endl
121 <<
"q1: " << q1 << endl
122 <<
"p: " <<
p << endl
123 <<
"p1_plus_p: " << p1_plus_p << endl
124 <<
"q1_plus_p: " << q1_plus_p << endl;
133 q.quat().normalize();
136 for (
int i = 0; i < 3; i++) Y[i] = pp[i];
140 double x1,
double y1,
double z1,
double yaw1,
double pitch1,
141 double roll1,
double x,
double y,
double z)
157 for (
int i = 0; i < 7; i++) x_mean[i] = q1[i];
164 x_incrs.assign(1e-7);
167 x_mean, std::function<
void(
170 x_incrs, DUMMY, numJacobs);
172 numJacobs.extractMatrix(0, 0, num_df_dpose);
173 numJacobs.extractMatrix(0, 7, num_df_dpoint);
177 EXPECT_NEAR(0, (df_dpoint - num_df_dpoint).array().abs().
sum(), 3e-3)
178 <<
"q1: " << q1 << endl
179 <<
"p: " <<
p << endl
180 <<
"Numeric approximation of df_dpoint: " << endl
181 << num_df_dpoint << endl
182 <<
"Implemented method: " << endl
185 << df_dpoint - num_df_dpoint << endl;
187 EXPECT_NEAR(0, (df_dpose - num_df_dpose).array().abs().
sum(), 3e-3)
188 <<
"q1: " << q1 << endl
189 <<
"p: " <<
p << endl
190 <<
"Numeric approximation of df_dpose: " << endl
191 << num_df_dpose << endl
192 <<
"Implemented method: " << endl
195 << df_dpose - num_df_dpose << endl;
199 double x1,
double y1,
double z1,
double yaw1,
double pitch1,
200 double roll1,
double x,
double y,
double z)
202 const CPose3D p1(x1, y1, z1, yaw1, pitch1, roll1);
217 <<
"p_minus_p1: " << p_minus_p1 << endl
218 <<
"p_minus_q1: " << p_minus_q1 << endl;
224 <<
"p_rec: " << p_rec << endl
225 <<
"p: " <<
p << endl;
234 q.quat().normalize();
243 double x1,
double y1,
double z1,
double yaw1,
double pitch1,
244 double roll1,
double x,
double y,
double z)
258 const double qr = q1.
quat().
r();
259 const double qx = q1.
quat().
x();
260 const double qy = q1.
quat().
y();
261 const double qz = q1.
quat().
z();
262 const double Ax =
x - x1;
263 const double Ay =
y - y1;
264 const double Az =
z - z1;
265 theorical.
x = Ax + 2 * (Ay) * (qr * qz + qx * qy) -
266 2 * (Az) * (qr * qy - qx * qz) -
268 theorical.
y = Ay - 2 * (Ax) * (qr * qz - qx * qy) +
269 2 * (Az) * (qr * qx + qy * qz) -
271 theorical.
z = Az + 2 * (Ax) * (qr * qy + qx * qz) -
272 2 * (Ay) * (qr * qx - qy * qz) -
275 EXPECT_NEAR(theorical.
x, l.
x, 1e-5);
276 EXPECT_NEAR(theorical.
y, l.
y, 1e-5);
277 EXPECT_NEAR(theorical.
z, l.
z, 1e-5);
284 for (
int i = 0; i < 7; i++) x_mean[i] = q1[i];
291 x_incrs.assign(1e-7);
294 x_mean, std::function<
void(
297 x_incrs, DUMMY, numJacobs);
299 numJacobs.extractMatrix(0, 0, num_df_dpose);
300 numJacobs.extractMatrix(0, 7, num_df_dpoint);
304 EXPECT_NEAR(0, (df_dpoint - num_df_dpoint).array().abs().
sum(), 3e-3)
305 <<
"q1: " << q1 << endl
306 <<
"from pose: " <<
CPose3D(x1, y1, z1, yaw1, pitch1, roll1) << endl
307 <<
"p: " <<
p << endl
308 <<
"local: " << l << endl
309 <<
"Numeric approximation of df_dpoint: " << endl
310 << num_df_dpoint << endl
311 <<
"Implemented method: " << endl
314 << df_dpoint - num_df_dpoint << endl;
316 EXPECT_NEAR(0, (df_dpose - num_df_dpose).array().abs().
sum(), 3e-3)
317 <<
"q1: " << q1 << endl
318 <<
"from pose: " <<
CPose3D(x1, y1, z1, yaw1, pitch1, roll1) << endl
319 <<
"p: " <<
p << endl
320 <<
"local: " << l << endl
321 <<
"Numeric approximation of df_dpose: " << endl
322 << num_df_dpose << endl
323 <<
"Implemented method: " << endl
326 << df_dpose - num_df_dpose << endl;
330 double x1,
double y1,
double z1,
double yaw1,
double pitch1,
333 const CPose3D p1(x1, y1, z1, yaw1, pitch1, roll1);
344 <<
"p1.getHomogeneousMatrixVal<CMatrixDouble44>():\n"
346 <<
"q1.getHomogeneousMatrixVal<CMatrixDouble44>():\n"
352 <<
"p1: " << p1 << endl
353 <<
"q1: " << q1 << endl
354 <<
"p1r: " << p1r << endl;
358 double x1,
double y1,
double z1,
double yaw1,
double pitch1,
361 const CPose3D p1(x1, y1, z1, yaw1, pitch1, roll1);
374 <<
"p1_inv.getHomogeneousMatrixVal<CMatrixDouble44>():\n"
376 <<
"q1_inv.getHomogeneousMatrixVal<CMatrixDouble44>():\n"
381 double x1,
double y1,
double z1,
double yaw1,
double pitch1,
384 const CPose3D p1(x1, y1, z1, yaw1, pitch1, roll1);
396 <<
"q1.getHomogeneousMatrixVal<CMatrixDouble44>():\n"
398 <<
"q2.getHomogeneousMatrixVal<CMatrixDouble44>():\n"
403 double x1,
double y1,
double z1,
double yaw1,
double pitch1,
404 double roll1,
double x,
double y,
double z)
411 EXPECT_NEAR(
x, aux.
x, 1e-7);
412 EXPECT_NEAR(
y, aux.
y, 1e-7);
413 EXPECT_NEAR(
z, aux.
z, 1e-7);
417 double x1,
double y1,
double z1,
double yaw1,
double pitch1,
418 double roll1,
double x,
double y,
double z)
420 const CPose3D p1(x1, y1, z1, yaw1, pitch1, roll1);
426 EXPECT_NEAR(pt1.
x, pt2.
x, 1e-7);
427 EXPECT_NEAR(pt1.
y, pt2.
y, 1e-7);
428 EXPECT_NEAR(pt1.
z, pt2.
z, 1e-7);
432 double x1,
double y1,
double z1,
double yaw1,
double pitch1,
433 double roll1,
double x,
double y,
double z)
435 const CPose3D p1(x1, y1, z1, yaw1, pitch1, roll1);
441 EXPECT_NEAR(pt1.
x, pt2.
x, 1e-7);
442 EXPECT_NEAR(pt1.
y, pt2.
y, 1e-7);
443 EXPECT_NEAR(pt1.
z, pt2.
z, 1e-7);
448 float gx =
x, gy =
y, gz =
z;
450 double dist, yaw,
pitch;
456 double lx2, ly2, lz2;
457 q.inverseComposePoint(gx, gy, gz, lx2, ly2, lz2);
459 EXPECT_NEAR(lx, lx2, 1e-7);
460 EXPECT_NEAR(ly, ly2, 1e-7);
461 EXPECT_NEAR(lz, lz2, 1e-7);
471 q.quat().normalize();
473 q.sphericalCoordinates(
p, Y[0], Y[1], Y[2]);
477 double x1,
double y1,
double z1,
double yaw1,
double pitch1,
478 double roll1,
double x,
double y,
double z)
494 for (
int i = 0; i < 7; i++) x_mean[i] = q1[i];
501 x_incrs.assign(1e-7);
504 x_mean, std::function<
void(
507 x_incrs, DUMMY, numJacobs);
509 numJacobs.extractMatrix(0, 0, num_df_dpose);
510 numJacobs.extractMatrix(0, 7, num_df_dpoint);
514 EXPECT_NEAR(0, (df_dpoint - num_df_dpoint).array().abs().
sum(), 3e-3)
515 <<
"q1: " << q1 << endl
516 <<
"p: " <<
p << endl
517 <<
"Numeric approximation of df_dpoint: " << endl
518 << num_df_dpoint << endl
519 <<
"Implemented method: " << endl
522 << df_dpoint - num_df_dpoint << endl;
524 EXPECT_NEAR(0, (df_dpose - num_df_dpose).array().abs().
sum(), 3e-3)
525 <<
"q1: " << q1 << endl
526 <<
"p: " <<
p << endl
527 <<
"Numeric approximation of df_dpose: " << endl
528 << num_df_dpose << endl
529 <<
"Implemented method: " << endl
532 << df_dpose - num_df_dpose << endl;
540 for (
int i = 0; i < 4; i++)
q[i] =
x[i];
542 for (
int i = 0; i < 4; i++) Y[i] =
q[i];
547 const CPose3D pp(0, 0, 0, yaw1, pitch1, roll1);
558 for (
int i = 0; i < 4; i++) x_mean[i] = q1[i];
562 x_incrs.assign(1e-5);
565 x_mean, std::function<
void(
568 x_incrs, DUMMY, numJacobs);
570 numJacobs.extractMatrix(0, 0, num_df_dpose);
574 EXPECT_NEAR(0, (df_dpose - num_df_dpose).array().abs().
sum(), 3e-3)
575 <<
"q1: " << q1 << endl
576 <<
"Numeric approximation of df_dpose: " << endl
577 << num_df_dpose << endl
578 <<
"Implemented method: " << endl
581 << df_dpose - num_df_dpose << endl;
646 test_composePointJacob(
648 test_composePointJacob(
650 test_composePointJacob(
652 test_composePointJacob(
654 test_composePointJacob(
657 test_composePointJacob(
664 test_invComposePoint(
666 test_invComposePoint(
668 test_invComposePoint(
670 test_invComposePoint(
672 test_invComposePoint(
675 test_invComposePoint(
682 test_invComposePointJacob(
684 test_invComposePointJacob(
686 test_invComposePointJacob(
688 test_invComposePointJacob(
690 test_invComposePointJacob(
692 test_invComposePointJacob(
694 test_invComposePointJacob(
696 test_invComposePointJacob(
699 test_invComposePointJacob(
706 test_composeAndInvComposePoint(
708 test_composeAndInvComposePoint(
710 test_composeAndInvComposePoint(
712 test_composeAndInvComposePoint(
714 test_composeAndInvComposePoint(
717 test_composeAndInvComposePoint(
724 test_composePoint_vs_CPose3D(
726 test_composePoint_vs_CPose3D(
728 test_composePoint_vs_CPose3D(
730 test_composePoint_vs_CPose3D(
732 test_composePoint_vs_CPose3D(
735 test_composePoint_vs_CPose3D(
742 test_invComposePoint_vs_CPose3D(
744 test_invComposePoint_vs_CPose3D(
746 test_invComposePoint_vs_CPose3D(
748 test_invComposePoint_vs_CPose3D(
751 for (
size_t i = 0; i < 10; i++)
753 std::vector<double>
v(9);
755 test_invComposePoint_vs_CPose3D(
756 v[0],
v[1],
v[2],
v[3],
v[4],
v[5],
v[6],
v[7],
v[8]);
762 test_sphericalCoords(
764 test_sphericalCoords(
766 test_sphericalCoords(
768 test_sphericalCoords(
770 test_sphericalCoords(
773 test_sphericalCoords(