10 #include <CTraitsTest.h> 11 #include <gtest/gtest.h> 16 #include <Eigen/Dense> 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;
57 <<
"p1_c_p2: " << p1_c_p2 << endl
58 <<
"q1_c_p2: " << p_q1_c_q2 << endl;
67 <<
"p1_i_p2: " << p1_i_p2 << endl
68 <<
"q1_i_p2: " << p_q1_i_q2 << endl;
76 (
A.asVectorVal() - q1_c_q2.
asVectorVal()).array().abs().sum(),
85 (
A.asVectorVal() - q1_c_q2.
asVectorVal()).array().abs().sum(),
94 (
A.asVectorVal() - q1_c_q2.
asVectorVal()).array().abs().sum(),
100 double x1,
double y1,
double z1,
double yaw1,
double pitch1,
101 double roll1,
double x,
double y,
double z)
103 const CPose3D p1(x1, y1, z1, yaw1, pitch1, roll1);
117 <<
"p1: " << p1 << endl
118 <<
"q1: " << q1 << endl
119 <<
"p: " << p << endl
120 <<
"p1_plus_p: " << p1_plus_p << endl
121 <<
"q1_plus_p: " << q1_plus_p << endl;
132 const CPoint3D p(x[7 + 0], x[7 + 1], x[7 + 2]);
134 for (
int i = 0; i < 3; i++) Y[i] = pp[i];
138 double x1,
double y1,
double z1,
double yaw1,
double pitch1,
139 double roll1,
double x,
double y,
double z)
155 for (
int i = 0; i < 7; i++) x_mean[i] = q1[i];
169 x_incrs, DUMMY, numJacobs);
171 num_df_dpose = numJacobs.
asEigen().block<3, 7>(0, 0);
172 num_df_dpoint = numJacobs.
asEigen().block<3, 3>(0, 7);
178 (df_dpoint.
asEigen() - num_df_dpoint.
asEigen()).array().abs().sum(),
180 <<
"q1: " << q1 << endl
181 <<
"p: " << p << endl
182 <<
"Numeric approximation of df_dpoint: " << endl
183 << num_df_dpoint.
asEigen() << endl
184 <<
"Implemented method: " << endl
191 (df_dpose.
asEigen() - num_df_dpose.
asEigen()).array().abs().sum(),
193 <<
"q1: " << q1 << endl
194 <<
"p: " << p << endl
195 <<
"Numeric approximation of df_dpose: " << endl
196 << num_df_dpose.
asEigen() << endl
197 <<
"Implemented method: " << endl
204 double x1,
double y1,
double z1,
double yaw1,
double pitch1,
205 double roll1,
double x,
double y,
double z)
207 const CPose3D p1(x1, y1, z1, yaw1, pitch1, roll1);
218 (p_minus_p1.
asVectorVal() - p_minus_q1.asVectorVal())
223 <<
"p_minus_p1: " << p_minus_p1 << endl
224 <<
"p_minus_q1: " << p_minus_q1 << endl;
229 <<
"p_rec: " << p_rec << endl
230 <<
"p: " << p << endl;
241 const CPoint3D p(x[7 + 0], x[7 + 1], x[7 + 2]);
249 double x1,
double y1,
double z1,
double yaw1,
double pitch1,
250 double roll1,
double x,
double y,
double z)
264 const double qr = q1.
quat().
r();
265 const double qx = q1.
quat().
x();
266 const double qy = q1.
quat().
y();
267 const double qz = q1.
quat().
z();
268 const double Ax = x - x1;
269 const double Ay = y - y1;
270 const double Az = z - z1;
271 theorical.
x = Ax + 2 * (Ay) * (qr * qz + qx * qy) -
272 2 * (Az) * (qr * qy - qx * qz) -
274 theorical.
y = Ay - 2 * (Ax) * (qr * qz - qx * qy) +
275 2 * (Az) * (qr * qx + qy * qz) -
277 theorical.
z = Az + 2 * (Ax) * (qr * qy + qx * qz) -
278 2 * (Ay) * (qr * qx - qy * qz) -
290 for (
int i = 0; i < 7; i++) x_mean[i] = q1[i];
304 x_incrs, DUMMY, numJacobs);
306 num_df_dpose = numJacobs.
block<3, 7>(0, 0);
307 num_df_dpoint = numJacobs.
block<3, 3>(0, 7);
313 (df_dpoint.
asEigen() - num_df_dpoint.
asEigen()).array().abs().sum(),
315 <<
"q1: " << q1 << endl
316 <<
"from pose: " <<
CPose3D(x1, y1, z1, yaw1, pitch1, roll1) << endl
317 <<
"p: " << p << endl
318 <<
"local: " << l << endl
319 <<
"Numeric approximation of df_dpoint: " << endl
320 << num_df_dpoint.
asEigen() << endl
321 <<
"Implemented method: " << endl
324 << df_dpoint - num_df_dpoint << endl;
328 (df_dpose.
asEigen() - num_df_dpose.
asEigen()).array().abs().sum(),
330 <<
"q1: " << q1 << endl
331 <<
"from pose: " <<
CPose3D(x1, y1, z1, yaw1, pitch1, roll1) << endl
332 <<
"p: " << p << endl
333 <<
"local: " << l << endl
334 <<
"Numeric approximation of df_dpose: " << endl
335 << num_df_dpose.
asEigen() << endl
336 <<
"Implemented method: " << endl
343 double x1,
double y1,
double z1,
double yaw1,
double pitch1,
346 const CPose3D p1(x1, y1, z1, yaw1, pitch1, roll1);
358 <<
"p1.getHomogeneousMatrixVal<CMatrixDouble44>():\n" 360 <<
"q1.getHomogeneousMatrixVal<CMatrixDouble44>():\n" 365 <<
"p1: " << p1 << endl
366 <<
"q1: " << q1 << endl
367 <<
"p1r: " << p1r << endl;
371 double x1,
double y1,
double z1,
double yaw1,
double pitch1,
374 const CPose3D p1(x1, y1, z1, yaw1, pitch1, roll1);
388 <<
"p1_inv.getHomogeneousMatrixVal<CMatrixDouble44>():\n" 390 <<
"q1_inv.getHomogeneousMatrixVal<CMatrixDouble44>():\n" 395 double x1,
double y1,
double z1,
double yaw1,
double pitch1,
398 const CPose3D p1(x1, y1, z1, yaw1, pitch1, roll1);
411 <<
"q1.getHomogeneousMatrixVal<CMatrixDouble44>():\n" 413 <<
"q2.getHomogeneousMatrixVal<CMatrixDouble44>():\n" 418 double x1,
double y1,
double z1,
double yaw1,
double pitch1,
419 double roll1,
double x,
double y,
double z)
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);
447 double x1,
double y1,
double z1,
double yaw1,
double pitch1,
448 double roll1,
double x,
double y,
double z)
450 const CPose3D p1(x1, y1, z1, yaw1, pitch1, roll1);
463 double gx = x, gy = y, gz = z;
465 double dist, yaw,
pitch;
471 double lx2, ly2, lz2;
488 const TPoint3D p(x[7 + 0], x[7 + 1], x[7 + 2]);
493 double x1,
double y1,
double z1,
double yaw1,
double pitch1,
494 double roll1,
double x,
double y,
double z)
510 for (
int i = 0; i < 7; i++) x_mean[i] = q1[i];
524 x_incrs, DUMMY, numJacobs);
526 num_df_dpose = numJacobs.
block<3, 7>(0, 0);
527 num_df_dpoint = numJacobs.
block<3, 3>(0, 7);
533 (df_dpoint.
asEigen() - num_df_dpoint.
asEigen()).array().abs().sum(),
535 <<
"q1: " << q1 << endl
536 <<
"p: " << p << endl
537 <<
"Numeric approximation of df_dpoint: " << endl
538 << num_df_dpoint.
asEigen() << endl
539 <<
"Implemented method: " << endl
546 (df_dpose.
asEigen() - num_df_dpose.
asEigen()).array().abs().sum(),
548 <<
"q1: " << q1 << endl
549 <<
"p: " << p << endl
550 <<
"Numeric approximation of df_dpose: " << endl
551 << num_df_dpose.
asEigen() << endl
552 <<
"Implemented method: " << endl
564 for (
int i = 0; i < 4; i++) q[i] = x[i];
566 for (
int i = 0; i < 4; i++) Y[i] = q[i];
571 const CPose3D pp(0, 0, 0, yaw1, pitch1, roll1);
582 for (
int i = 0; i < 4; i++) x_mean[i] = q1[i];
593 x_incrs, DUMMY, numJacobs);
595 num_df_dpose = numJacobs.
block<4, 4>(0, 0);
601 (df_dpose.
asEigen() - num_df_dpose.
asEigen()).array().abs().sum(),
603 <<
"q1: " << q1 << endl
604 <<
"Numeric approximation of df_dpose: " << endl
605 << num_df_dpose.
asEigen() << endl
606 <<
"Implemented method: " << endl
615 double yaw,
double pitch,
double roll,
double qx,
double qy,
double qz,
616 double qw,
const std::string& sRotMat)
618 const double eps = 1e-4;
623 std::stringstream sErr;
625 GTEST_FAIL() <<
"Incorrect R_gt matrix: '" << sRotMat
626 <<
"'. Error: " << sErr.str() <<
"\n";
627 EXPECT_EQ(R_gt.
cols(), 3) <<
" for: sRotMat='" << sRotMat <<
"'\n";
628 EXPECT_EQ(R_gt.
rows(), 3) <<
" for: sRotMat='" << sRotMat <<
"'\n";
638 << R_gt <<
"\np.R=\n" 646 if (std::abs(q.
w() - q_gt.w()) >
eps || std::abs(q.
x() - q_gt.x()) >
eps ||
647 std::abs(q.
y() - q_gt.y()) >
eps || std::abs(q.
z() - q_gt.z()) >
eps)
649 GTEST_FAIL() <<
"q = " << q.
asString()
650 <<
"\nExpected = " << q_gt.asString() <<
"\n";
673 0.0_deg, 0.0_deg, 0.0_deg,
675 "[ 1.0000000 0.0000000 0.0000000; " 676 " 0.0000000 1.0000000 0.0000000; " 677 " 0.0000000 0.0000000 1.0000000 ]");
679 90.0_deg, 0.0_deg, 0.0_deg,
680 0, 0, 0.7071068, 0.7071068,
681 "[ 0.0000000 -1.0000000 0.0000000;" 682 " 1.0000000 0.0000000 0.0000000;" 683 " 0.0000000 0.0000000 1.0000000 ]");
685 30.0_deg, 10.0_deg, 60.0_deg,
686 0.4615897, 0.2018243, 0.1811979, 0.8446119,
687 "[ 0.8528686 -0.1197639 0.5082046;" 688 " 0.4924039 0.5082046 -0.7065880;" 689 " -0.1736482 0.8528686 0.4924039 ]");
691 -10.0_deg, -20.0_deg, -30.0_deg,
692 -0.2685358, -0.1448781, -0.1276794, 0.9437144,
693 "[ 0.9254166 0.3187958 -0.2048741;" 694 " -0.1631759 0.8231729 0.5438381;" 695 " 0.3420202 -0.4698463 0.8137977 ]");
697 -179.9995949_deg, -90.0_deg, 0.0_deg,
698 0.7071068, 0, 0.7071068, -0.000005,
699 "[ 0.0000000 0.0000071 1.0000000;" 700 " -0.0000071 -1.0000000 0.0000071;" 701 " 1.0000000 -0.0000071 0.0000000 ]");
706 test_fromYPRAndBack(1.0, 2.0, 3.0, 0.0_deg, 0.0_deg, 0.0_deg);
707 test_fromYPRAndBack(1.0, 2.0, 3.0, 90.0_deg, 0.0_deg, 0.0_deg);
708 test_fromYPRAndBack(1.0, 2.0, 3.0, -30.0_deg, 10.0_deg, 60.0_deg);
709 test_fromYPRAndBack(1.0, 2.0, 3.0, 179.0_deg, 0.0_deg, 60.0_deg);
710 test_fromYPRAndBack(1.0, 2.0, 3.0, -179.0_deg, 0.0_deg, 60.0_deg);
711 test_fromYPRAndBack(1.0, 2.0, 3.0, 30.0_deg, 89.0_deg, 0.0_deg);
712 test_fromYPRAndBack(1.0, 2.0, 3.0, 30.0_deg, -89.0_deg, 0.0_deg);
717 test_unaryInverse(1.0, 2.0, 3.0, 0.0_deg, 0.0_deg, 0.0_deg);
718 test_unaryInverse(1.0, 2.0, 3.0, 90.0_deg, 0.0_deg, 0.0_deg);
719 test_unaryInverse(1.0, 2.0, 3.0, -30.0_deg, 10.0_deg, 60.0_deg);
720 test_unaryInverse(1.0, 2.0, 3.0, 179.0_deg, 0.0_deg, 60.0_deg);
721 test_unaryInverse(1.0, 2.0, 3.0, -179.0_deg, 0.0_deg, 60.0_deg);
722 test_unaryInverse(1.0, 2.0, 3.0, 30.0_deg, 89.0_deg, 0.0_deg);
723 test_unaryInverse(1.0, 2.0, 3.0, 30.0_deg, -89.0_deg, 0.0_deg);
728 test_copy(1.0, 2.0, 3.0, 0.0_deg, 0.0_deg, 0.0_deg);
729 test_copy(1.0, 2.0, 3.0, 90.0_deg, 0.0_deg, 0.0_deg);
730 test_copy(1.0, 2.0, 3.0, -30.0_deg, 10.0_deg, 60.0_deg);
731 test_copy(1.0, 2.0, 3.0, 30.0_deg, -89.0_deg, 0.0_deg);
737 1.0, 2.0, 3.0, -30.0_deg, 10.0_deg, 60.0_deg, 2.0, -5.0, 8.0, 40.0_deg,
741 25.0, 2.0, 3.0, -30.0_deg, 90.0_deg, 0.0_deg, -10.0, 4.0, -8.0,
742 20.0_deg, 9.0_deg, 0.0_deg);
747 test_composePoint(1.0, 2.0, 3.0, 0.0_deg, 0.0_deg, 0.0_deg, 10, 11, 12);
748 test_composePoint(1.0, 2.0, 3.0, 10.0_deg, 0.0_deg, 0.0_deg, 10, 11, 12);
749 test_composePoint(1.0, 2.0, 3.0, 0.0_deg, 10.0_deg, 0.0_deg, 10, 11, 12);
750 test_composePoint(1.0, 2.0, 3.0, 0.0_deg, 0.0_deg, 10.0_deg, 10, 11, 12);
752 1.0, 2.0, 3.0, -30.0_deg, 10.0_deg, 60.0_deg, 10.0, 20.0, 30.0);
754 1.0, 2.0, 3.0, 10.0_deg, -50.0_deg, -40.0_deg, -5.0, -15.0, 8.0);
759 test_composePointJacob(
760 1.0, 2.0, 3.0, 0.0_deg, 0.0_deg, 0.0_deg, 10, 11, 12);
761 test_composePointJacob(
762 1.0, 2.0, 3.0, 10.0_deg, 0.0_deg, 0.0_deg, 10, 11, 12);
763 test_composePointJacob(
764 1.0, 2.0, 3.0, 0.0_deg, 10.0_deg, 0.0_deg, 10, 11, 12);
765 test_composePointJacob(
766 1.0, 2.0, 3.0, 0.0_deg, 0.0_deg, 10.0_deg, 10, 11, 12);
767 test_composePointJacob(
768 1.0, 2.0, 3.0, -30.0_deg, 10.0_deg, 60.0_deg, 10.0, 20.0, 30.0);
769 test_composePointJacob(
770 1.0, 2.0, 3.0, 10.0_deg, -50.0_deg, -40.0_deg, -5.0, -15.0, 8.0);
775 test_invComposePoint(1.0, 2.0, 3.0, 0.0_deg, 0.0_deg, 0.0_deg, 10, 11, 12);
776 test_invComposePoint(1.0, 2.0, 3.0, 10.0_deg, 0.0_deg, 0.0_deg, 10, 11, 12);
777 test_invComposePoint(1.0, 2.0, 3.0, 0.0_deg, 10.0_deg, 0.0_deg, 10, 11, 12);
778 test_invComposePoint(1.0, 2.0, 3.0, 0.0_deg, 0.0_deg, 10.0_deg, 10, 11, 12);
779 test_invComposePoint(
780 1.0, 2.0, 3.0, -30.0_deg, 10.0_deg, 60.0_deg, 10.0, 20.0, 30.0);
781 test_invComposePoint(
782 1.0, 2.0, 3.0, 10.0_deg, -50.0_deg, -40.0_deg, -5.0, -15.0, 8.0);
787 test_invComposePointJacob(0, 0, 0, 0.0_deg, 0.0_deg, 0.0_deg, 0, 0, 0);
788 test_invComposePointJacob(0, 0, 0, 0.0_deg, 0.0_deg, 0.0_deg, 1, 2, 3);
789 test_invComposePointJacob(
790 1.0, 2.0, 3.0, 0.0_deg, 0.0_deg, 0.0_deg, 0, 0, 0);
791 test_invComposePointJacob(
792 1.0, 2.0, 3.0, 0.0_deg, 0.0_deg, 0.0_deg, 10, 11, 12);
793 test_invComposePointJacob(
794 1.0, 2.0, 3.0, 10.0_deg, 0.0_deg, 0.0_deg, 10, 11, 12);
795 test_invComposePointJacob(
796 1.0, 2.0, 3.0, 0.0_deg, 10.0_deg, 0.0_deg, 10, 11, 12);
797 test_invComposePointJacob(
798 1.0, 2.0, 3.0, 0.0_deg, 0.0_deg, 10.0_deg, 10, 11, 12);
799 test_invComposePointJacob(
800 1.0, 2.0, 3.0, -30.0_deg, 10.0_deg, 60.0_deg, 10.0, 20.0, 30.0);
801 test_invComposePointJacob(
802 1.0, 2.0, 3.0, 10.0_deg, -50.0_deg, -40.0_deg, -5.0, -15.0, 8.0);
807 test_composeAndInvComposePoint(
808 1.0, 2.0, 3.0, 0.0_deg, 0.0_deg, 0.0_deg, 10, 11, 12);
809 test_composeAndInvComposePoint(
810 1.0, 2.0, 3.0, 10.0_deg, 0.0_deg, 0.0_deg, 10, 11, 12);
811 test_composeAndInvComposePoint(
812 1.0, 2.0, 3.0, 0.0_deg, 10.0_deg, 0.0_deg, 10, 11, 12);
813 test_composeAndInvComposePoint(
814 1.0, 2.0, 3.0, 0.0_deg, 0.0_deg, 10.0_deg, 10, 11, 12);
815 test_composeAndInvComposePoint(
816 1.0, 2.0, 3.0, -30.0_deg, 10.0_deg, 60.0_deg, 10.0, 20.0, 30.0);
817 test_composeAndInvComposePoint(
818 1.0, 2.0, 3.0, 10.0_deg, -50.0_deg, -40.0_deg, -5.0, -15.0, 8.0);
823 test_composePoint_vs_CPose3D(
824 1.0, 2.0, 3.0, 0.0_deg, 0.0_deg, 0.0_deg, 10, 11, 12);
825 test_composePoint_vs_CPose3D(
826 1.0, 2.0, 3.0, 10.0_deg, 0.0_deg, 0.0_deg, 10, 11, 12);
827 test_composePoint_vs_CPose3D(
828 1.0, 2.0, 3.0, 0.0_deg, 10.0_deg, 0.0_deg, 10, 11, 12);
829 test_composePoint_vs_CPose3D(
830 1.0, 2.0, 3.0, 0.0_deg, 0.0_deg, 10.0_deg, 10, 11, 12);
831 test_composePoint_vs_CPose3D(
832 1.0, 2.0, 3.0, -30.0_deg, 10.0_deg, 60.0_deg, 10.0, 20.0, 30.0);
833 test_composePoint_vs_CPose3D(
834 1.0, 2.0, 3.0, 10.0_deg, -50.0_deg, -40.0_deg, -5.0, -15.0, 8.0);
839 test_invComposePoint_vs_CPose3D(
840 1.0, 2.0, 3.0, 0.0_deg, 0.0_deg, 0.0_deg, 10, 11, 12);
841 test_invComposePoint_vs_CPose3D(
842 1.0, 2.0, 3.0, 10.0_deg, 0.0_deg, 0.0_deg, 10, 11, 12);
843 test_invComposePoint_vs_CPose3D(
844 1.0, 2.0, 3.0, 0.0_deg, 10.0_deg, 0.0_deg, 10, 11, 12);
845 test_invComposePoint_vs_CPose3D(
846 1.0, 2.0, 3.0, 0.0_deg, 0.0_deg, 10.0_deg, 10, 11, 12);
848 for (
size_t i = 0; i < 10; i++)
850 std::vector<double> v(9);
852 test_invComposePoint_vs_CPose3D(
853 v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7], v[8]);
859 test_sphericalCoords(1.0, 2.0, 3.0, 0.0_deg, 0.0_deg, 0.0_deg, 10, 11, 12);
860 test_sphericalCoords(1.0, 2.0, 3.0, 10.0_deg, 0.0_deg, 0.0_deg, 10, 11, 12);
861 test_sphericalCoords(1.0, 2.0, 3.0, 0.0_deg, 10.0_deg, 0.0_deg, 10, 11, 12);
862 test_sphericalCoords(1.0, 2.0, 3.0, 0.0_deg, 0.0_deg, 10.0_deg, 10, 11, 12);
863 test_sphericalCoords(
864 1.0, 2.0, 3.0, -30.0_deg, 10.0_deg, 60.0_deg, 10.0, 20.0, 30.0);
865 test_sphericalCoords(
866 1.0, 2.0, 3.0, 10.0_deg, -50.0_deg, -40.0_deg, -5.0, -15.0, 8.0);
871 test_normalizeJacob(0.0_deg, 0.0_deg, 0.0_deg);
872 test_normalizeJacob(10.0_deg, 0.0_deg, 0.0_deg);
873 test_normalizeJacob(0.0_deg, 10.0_deg, 0.0_deg);
874 test_normalizeJacob(0.0_deg, 0.0_deg, 10.0_deg);
875 test_normalizeJacob(-30.0_deg, 10.0_deg, 60.0_deg);
876 test_normalizeJacob(10.0_deg, -50.0_deg, -40.0_deg);
static void quat_vs_YPR(double yaw, double pitch, double roll, double qx, double qy, double qz, double qw, const std::string &sRotMat)
void test_sphericalCoords(double x1, double y1, double z1, double yaw1, double pitch1, double roll1, double x, double y, double z)
mrpt::math::CQuaternionDouble & quat()
Read/Write access to the quaternion representing the 3D rotation.
void rotationMatrix(MATRIXLIKE &M) const
Calculate the 3x3 rotation matrix associated to this quaternion: .
A compile-time fixed-size numeric matrix container.
void test_composePointJacob(double x1, double y1, double z1, double yaw1, double pitch1, double roll1, double x, double y, double z)
void normalize()
Normalize this quaternion, so its norm becomes the unitity.
std::string asString() const
Returns a string representation of the vector/matrix, using Eigen's default settings.
void test_fromYPRAndBack(double x1, double y1, double z1, double yaw1, double pitch1, double roll1)
void drawGaussian1DVector(VEC &v, const double mean=0, const double std=1)
Fills the given vector with independent, 1D-normally distributed samples.
T y() const
Return y coordinate of the quaternion.
static void func_spherical_coords(const CVectorFixedDouble< 7+3 > &x, const double &dummy, CVectorFixedDouble< 3 > &Y)
void inverseComposePoint(const double gx, const double gy, const double gz, double &lx, double &ly, double &lz, mrpt::optional_ref< mrpt::math::CMatrixDouble33 > out_jacobian_df_dpoint=std::nullopt, mrpt::optional_ref< mrpt::math::CMatrixDouble36 > out_jacobian_df_dpose=std::nullopt, mrpt::optional_ref< mrpt::math::CMatrixDouble36 > out_jacobian_df_dse3=std::nullopt) const
Computes the 3D point L such as .
CQuaternion< double > CQuaternionDouble
A quaternion of data type "double".
void test_copy(double x1, double y1, double z1, double yaw1, double pitch1, double roll1)
void sphericalCoordinates(const mrpt::math::TPoint3D &point, double &out_range, double &out_yaw, double &out_pitch, mrpt::math::CMatrixFixed< double, 3, 3 > *out_jacob_dryp_dpoint=nullptr, mrpt::math::CMatrixFixed< double, 3, 7 > *out_jacob_dryp_dpose=nullptr) const
Computes the spherical coordinates of a 3D point as seen from the 6D pose specified by this object...
static void func_normalizeJacob(const CVectorFixedDouble< 4 > &x, const double &dummy, CVectorFixedDouble< 4 > &Y)
static void func_compose_point(const CVectorFixedDouble< 7+3 > &x, const double &dummy, CVectorFixedDouble< 3 > &Y)
void getAsQuaternion(mrpt::math::CQuaternionDouble &q, mrpt::optional_ref< mrpt::math::CMatrixDouble43 > out_dq_dr=std::nullopt) const
Returns the quaternion associated to the rotation of this object (NOTE: XYZ translation is ignored) ...
void composePoint(const double lx, const double ly, const double lz, double &gx, double &gy, double &gz, mrpt::math::CMatrixFixed< double, 3, 3 > *out_jacobian_df_dpoint=nullptr, mrpt::math::CMatrixFixed< double, 3, 7 > *out_jacobian_df_dpose=nullptr) const
Computes the 3D point G such as .
This base provides a set of functions for maths stuff.
T r() const
Return r (real part) coordinate of the quaternion.
void inverseComposePoint(const double gx, const double gy, const double gz, double &lx, double &ly, double &lz, mrpt::math::CMatrixFixed< double, 3, 3 > *out_jacobian_df_dpoint=nullptr, mrpt::math::CMatrixFixed< double, 3, 7 > *out_jacobian_df_dpose=nullptr) const
Computes the 3D point L such as .
TEST(QuatTests, Quat_vs_YPR)
auto block(int start_row, int start_col)
non-const block(): Returns an Eigen::Block reference to the block
void sphericalCoordinates(const mrpt::math::TPoint3D &point, double &out_range, double &out_yaw, double &out_pitch) const
Computes the spherical coordinates of a 3D point as seen from the 6D pose specified by this object...
void test_invComposePoint(double x1, double y1, double z1, double yaw1, double pitch1, double roll1, double x, double y, double z)
void test_composeAndInvComposePoint(double x1, double y1, double z1, double yaw1, double pitch1, double roll1, double x, double y, double z)
TPoint3D_< double > TPoint3D
Lightweight 3D point.
bool fromMatlabStringFormat(const std::string &s, mrpt::optional_ref< std::ostream > dump_errors_here=std::nullopt)
Reads a matrix from a string in Matlab-like format, for example: "[1 0 2; 0 4 -1]" The string must st...
double x() const
Common members of all points & poses classes.
A class used to store a 3D pose as a translation (x,y,z) and a quaternion (qr,qx,qy,qz).
static void func_inv_compose_point(const CVectorFixedDouble< 7+3 > &x, const double &dummy, CVectorFixedDouble< 3 > &Y)
A class used to store a 3D point.
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
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...
constexpr size_type rows() const
Number of rows in the matrix.
void test_invComposePointJacob(double x1, double y1, double z1, double yaw1, double pitch1, double roll1, double x, double y, double z)
return_t square(const num_t x)
Inline function for the square of a number.
void test_compose(double x1, double y1, double z1, double yaw1, double pitch1, double roll1, double x2, double y2, double z2, double yaw2, double pitch2, double roll2)
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
T x() const
Return x coordinate of the quaternion.
void normalizationJacobian(MATRIXLIKE &J) const
Calculate the 4x4 Jacobian of the normalization operation of this quaternion.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
void test_invComposePoint_vs_CPose3D(double x1, double y1, double z1, double yaw1, double pitch1, double roll1, double x, double y, double z)
void test_normalizeJacob(double yaw1, double pitch1, double roll1)
EXPECT_EQ(out.image_pair_was_used.size(), NUM_IMGS)
EIGEN_MAP asEigen()
Get as an Eigen-compatible Eigen::Map object.
void test_composePoint_vs_CPose3D(double x1, double y1, double z1, double yaw1, double pitch1, double roll1, double x, double y, double z)
void composePoint(double lx, double ly, double lz, double &gx, double &gy, double &gz, mrpt::optional_ref< mrpt::math::CMatrixDouble33 > out_jacobian_df_dpoint=std::nullopt, mrpt::optional_ref< mrpt::math::CMatrixDouble36 > out_jacobian_df_dpose=std::nullopt, mrpt::optional_ref< mrpt::math::CMatrixDouble36 > out_jacobian_df_dse3=std::nullopt, bool use_small_rot_approx=false) const
An alternative, slightly more efficient way of doing with G and L being 3D points and P this 6D pose...
constexpr size_type cols() const
Number of columns in the matrix.
MATRIX44 getHomogeneousMatrixVal() const
Returns the corresponding 4x4 homogeneous transformation matrix for the point(translation) or pose (t...
EXPECT_NEAR(out.cam_params.rightCameraPose.x, 0.1194, 0.005)
A quaternion, which can represent a 3D rotation as pair , with a real part "r" and a 3D vector ...
void getRotationMatrix(mrpt::math::CMatrixDouble33 &ROT) const
Get the 3x3 rotation matrix.
T z() const
Return z coordinate of the quaternion.
CRandomGenerator & getRandomGenerator()
A static instance of a CRandomGenerator class, for use in single-thread applications.
EIGEN_MAP asEigen()
Get as an Eigen-compatible Eigen::Map object.
T w() const
Return w (real part) coordinate of the quaternion.
void test_unaryInverse(double x1, double y1, double z1, double yaw1, double pitch1, double roll1)
void test_composePoint(double x1, double y1, double z1, double yaw1, double pitch1, double roll1, double x, double y, double z)
TEST_F(Pose3DQuatTests, FromYPRAndBack)
vector_t asVectorVal() const
Return the pose or point as a 1xN vector with all the components (see derived classes for each implem...
#define MRPT_UNUSED_PARAM(a)
Determines whether this is an X86 or AMD64 platform.