| 
									
										
										
										
											2010-10-14 12:54:38 +08:00
										 |  |  | /* ----------------------------------------------------------------------------
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |  * GTSAM Copyright 2010, Georgia Tech Research Corporation,  | 
					
						
							|  |  |  |  * Atlanta, Georgia 30332-0415 | 
					
						
							|  |  |  |  * All Rights Reserved | 
					
						
							|  |  |  |  * Authors: Frank Dellaert, et al. (see THANKS for the full author list) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |  * See LICENSE for the license information | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |  * -------------------------------------------------------------------------- */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * @file   testPose3.cpp | 
					
						
							|  |  |  |  * @brief  Unit tests for Pose3 class | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-03-03 01:56:26 +08:00
										 |  |  | #include <math.h>
 | 
					
						
							| 
									
										
										
										
											2010-08-20 01:23:19 +08:00
										 |  |  | #include <gtsam/CppUnitLite/TestHarness.h>
 | 
					
						
							|  |  |  | #include <gtsam/base/numericalDerivative.h>
 | 
					
						
							| 
									
										
										
										
											2010-08-27 03:55:40 +08:00
										 |  |  | #include <gtsam/base/lieProxies.h>
 | 
					
						
							| 
									
										
										
										
											2010-08-20 01:23:19 +08:00
										 |  |  | #include <gtsam/geometry/Pose3.h>
 | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-03-03 01:56:26 +08:00
										 |  |  | using namespace std; | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | using namespace gtsam; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-03-03 01:56:26 +08:00
										 |  |  | static Point3 P(0.2,0.7,-2); | 
					
						
							| 
									
										
										
										
											2010-08-20 04:03:06 +08:00
										 |  |  | static Rot3 R = Rot3::rodriguez(0.3,0,0); | 
					
						
							| 
									
										
										
										
											2010-03-03 01:56:26 +08:00
										 |  |  | static Pose3 T(R,Point3(3.5,-8.2,4.2)); | 
					
						
							| 
									
										
										
										
											2010-08-20 04:03:06 +08:00
										 |  |  | static Pose3 T2(Rot3::rodriguez(0.3,0.2,0.1),Point3(3.5,-8.2,4.2)); | 
					
						
							|  |  |  | static Pose3 T3(Rot3::rodriguez(-90, 0, 0), Point3(1, 2, 3)); | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* ************************************************************************* */ | 
					
						
							|  |  |  | TEST( Pose3, equals) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-03-03 01:56:26 +08:00
										 |  |  |   Pose3 pose2 = T3; | 
					
						
							|  |  |  |   CHECK(T3.equals(pose2)); | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  |   Pose3 origin; | 
					
						
							| 
									
										
										
										
											2010-03-03 01:56:26 +08:00
										 |  |  |   CHECK(!T3.equals(origin)); | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* ************************************************************************* */ | 
					
						
							| 
									
										
										
										
											2010-01-08 08:40:17 +08:00
										 |  |  | TEST( Pose3, expmap_a) | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | { | 
					
						
							|  |  |  |   Pose3 id; | 
					
						
							|  |  |  |   Vector v(6); | 
					
						
							|  |  |  |   fill(v.begin(), v.end(), 0); | 
					
						
							|  |  |  |   v(0) = 0.3; | 
					
						
							| 
									
										
										
										
											2010-08-27 03:55:40 +08:00
										 |  |  |   CHECK(assert_equal(id.expmap(v), Pose3(R, Point3()))); | 
					
						
							| 
									
										
										
										
											2010-03-13 03:16:53 +08:00
										 |  |  | #ifdef CORRECT_POSE3_EXMAP
 | 
					
						
							| 
									
										
										
										
											2010-03-12 05:52:24 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   v(3)=0.2;v(4)=0.394742;v(5)=-2.08998; | 
					
						
							|  |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  |   v(3)=0.2;v(4)=0.7;v(5)=-2; | 
					
						
							| 
									
										
										
										
											2010-03-12 05:52:24 +08:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2010-08-27 03:55:40 +08:00
										 |  |  |   CHECK(assert_equal(Pose3(R, P),id.expmap(v),1e-5)); | 
					
						
							| 
									
										
										
										
											2010-01-08 08:40:17 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-08-20 04:03:06 +08:00
										 |  |  | /* ************************************************************************* */ | 
					
						
							| 
									
										
										
										
											2010-01-08 08:40:17 +08:00
										 |  |  | TEST(Pose3, expmap_b) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   Pose3 p1(Rot3(), Point3(100, 0, 0)); | 
					
						
							| 
									
										
										
										
											2010-08-27 03:55:40 +08:00
										 |  |  |   Pose3 p2 = p1.expmap(Vector_(6,0.0, 0.0, 0.1,  0.0, 0.0, 0.0)); | 
					
						
							| 
									
										
										
										
											2010-08-20 04:03:06 +08:00
										 |  |  |   Pose3 expected(Rot3::rodriguez(0.0, 0.0, 0.1), Point3(100.0, 0.0, 0.0)); | 
					
						
							| 
									
										
										
										
											2010-01-08 08:40:17 +08:00
										 |  |  |   CHECK(assert_equal(expected, p2)); | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-03-13 03:16:53 +08:00
										 |  |  | #ifdef CORRECT_POSE3_EXMAP
 | 
					
						
							| 
									
										
										
										
											2010-03-12 05:52:24 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-03-03 01:56:26 +08:00
										 |  |  | /* ************************************************************************* */ | 
					
						
							| 
									
										
										
										
											2010-03-02 10:25:27 +08:00
										 |  |  | // test case for screw motion in the plane
 | 
					
						
							|  |  |  | namespace screw { | 
					
						
							|  |  |  |   double a=0.3, c=cos(a), s=sin(a), w=0.3; | 
					
						
							| 
									
										
										
										
											2010-03-03 01:56:26 +08:00
										 |  |  | 	Vector xi = Vector_(6, 0.0, 0.0, w, w, 0.0, 1.0); | 
					
						
							| 
									
										
										
										
											2010-03-02 10:25:27 +08:00
										 |  |  | 	Rot3 expectedR(c, -s, 0, s, c, 0, 0, 0, 1); | 
					
						
							| 
									
										
										
										
											2010-03-03 01:56:26 +08:00
										 |  |  | 	Point3 expectedT(0.29552, 0.0446635, 1); | 
					
						
							| 
									
										
										
										
											2010-03-02 10:25:27 +08:00
										 |  |  | 	Pose3 expected(expectedR, expectedT); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST(Pose3, expmap_c) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   CHECK(assert_equal(screw::expected, expm<Pose3>(screw::xi),1e-6)); | 
					
						
							| 
									
										
										
										
											2010-08-27 03:55:40 +08:00
										 |  |  |   CHECK(assert_equal(screw::expected, Pose3::Expmap(screw::xi),1e-6)); | 
					
						
							| 
									
										
										
										
											2010-03-02 10:25:27 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-03-03 01:56:26 +08:00
										 |  |  | /* ************************************************************************* */ | 
					
						
							|  |  |  | // assert that T*exp(xi)*T^-1 is equal to exp(Ad_T(xi))
 | 
					
						
							| 
									
										
										
										
											2010-03-02 10:25:27 +08:00
										 |  |  | TEST(Pose3, Adjoint) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-08-27 03:55:40 +08:00
										 |  |  | 	Pose3 expected = T * Pose3::Expmap(screw::xi) * inverse(T); | 
					
						
							| 
									
										
										
										
											2010-03-02 10:25:27 +08:00
										 |  |  | 	Vector xiprime = Adjoint(T, screw::xi); | 
					
						
							| 
									
										
										
										
											2010-08-27 03:55:40 +08:00
										 |  |  | 	CHECK(assert_equal(expected, Pose3::Expmap(xiprime), 1e-6)); | 
					
						
							| 
									
										
										
										
											2010-03-03 01:56:26 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-08-27 03:55:40 +08:00
										 |  |  | 	Pose3 expected2 = T2 * Pose3::Expmap(screw::xi) * inverse(T2); | 
					
						
							| 
									
										
										
										
											2010-03-03 01:56:26 +08:00
										 |  |  | 	Vector xiprime2 = Adjoint(T2, screw::xi); | 
					
						
							| 
									
										
										
										
											2010-08-27 03:55:40 +08:00
										 |  |  | 	CHECK(assert_equal(expected2, Pose3::Expmap(xiprime2), 1e-6)); | 
					
						
							| 
									
										
										
										
											2010-03-03 01:56:26 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-08-27 03:55:40 +08:00
										 |  |  | 	Pose3 expected3 = T3 * Pose3::Expmap(screw::xi) * inverse(T3); | 
					
						
							| 
									
										
										
										
											2010-03-03 01:56:26 +08:00
										 |  |  | 	Vector xiprime3 = Adjoint(T3, screw::xi); | 
					
						
							| 
									
										
										
										
											2010-08-27 03:55:40 +08:00
										 |  |  | 	CHECK(assert_equal(expected3, Pose3::Expmap(xiprime3), 1e-6)); | 
					
						
							| 
									
										
										
										
											2010-03-02 10:25:27 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | /* ************************************************************************* */ | 
					
						
							| 
									
										
										
										
											2010-03-03 01:56:26 +08:00
										 |  |  | /** Agrawal06iros version */ | 
					
						
							|  |  |  | using namespace boost::numeric::ublas; | 
					
						
							|  |  |  | Pose3 Agrawal06iros(const Vector& xi) { | 
					
						
							|  |  |  | 	Vector w = vector_range<const Vector>(xi, range(0,3)); | 
					
						
							|  |  |  | 	Vector v = vector_range<const Vector>(xi, range(3,6)); | 
					
						
							|  |  |  | 	double t = norm_2(w); | 
					
						
							|  |  |  | 	if (t < 1e-5) | 
					
						
							|  |  |  | 		return Pose3(Rot3(), expmap<Point3> (v)); | 
					
						
							|  |  |  | 	else { | 
					
						
							|  |  |  | 		Matrix W = skewSymmetric(w/t); | 
					
						
							|  |  |  | 		Matrix A = eye(3) + ((1 - cos(t)) / t) * W + ((t - sin(t)) / t) * (W * W); | 
					
						
							| 
									
										
										
										
											2010-08-27 03:55:40 +08:00
										 |  |  | 		return Pose3(Rot3::Expmap (w), expmap<Point3> (A * v)); | 
					
						
							| 
									
										
										
										
											2010-03-03 01:56:26 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* ************************************************************************* */ | 
					
						
							|  |  |  | TEST(Pose3, expmaps_galore) | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2010-03-03 01:56:26 +08:00
										 |  |  | 	Vector xi; Pose3 actual; | 
					
						
							|  |  |  | 	xi = Vector_(6,0.1,0.2,0.3,0.4,0.5,0.6); | 
					
						
							| 
									
										
										
										
											2010-08-27 03:55:40 +08:00
										 |  |  | 	actual = Pose3::Expmap(xi); | 
					
						
							| 
									
										
										
										
											2010-03-03 01:56:26 +08:00
										 |  |  |   CHECK(assert_equal(expm<Pose3>(xi), actual,1e-6)); | 
					
						
							|  |  |  |   CHECK(assert_equal(Agrawal06iros(xi), actual,1e-6)); | 
					
						
							|  |  |  |   CHECK(assert_equal(xi, logmap(actual),1e-6)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	xi = Vector_(6,0.1,-0.2,0.3,-0.4,0.5,-0.6); | 
					
						
							|  |  |  | 	for (double theta=1.0;0.3*theta<=M_PI;theta*=2) { | 
					
						
							|  |  |  | 		Vector txi = xi*theta; | 
					
						
							| 
									
										
										
										
											2010-08-27 03:55:40 +08:00
										 |  |  | 		actual = Pose3::Expmap(txi); | 
					
						
							| 
									
										
										
										
											2010-03-03 01:56:26 +08:00
										 |  |  | 		CHECK(assert_equal(expm<Pose3>(txi,30), actual,1e-6)); | 
					
						
							|  |  |  | 		CHECK(assert_equal(Agrawal06iros(txi), actual,1e-6)); | 
					
						
							|  |  |  | 		Vector log = logmap(actual); | 
					
						
							| 
									
										
										
										
											2010-08-27 03:55:40 +08:00
										 |  |  | 		CHECK(assert_equal(actual, Pose3::Expmap(log),1e-6)); | 
					
						
							| 
									
										
										
										
											2010-03-03 01:56:26 +08:00
										 |  |  | 		CHECK(assert_equal(txi,log,1e-6)); // not true once wraps
 | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // Works with large v as well, but expm needs 10 iterations!
 | 
					
						
							|  |  |  | 	xi = Vector_(6,0.2,0.3,-0.8,100.0,120.0,-60.0); | 
					
						
							| 
									
										
										
										
											2010-08-27 03:55:40 +08:00
										 |  |  | 	actual = Pose3::Expmap(xi); | 
					
						
							| 
									
										
										
										
											2010-03-03 01:56:26 +08:00
										 |  |  |   CHECK(assert_equal(expm<Pose3>(xi,10), actual,1e-5)); | 
					
						
							|  |  |  |   CHECK(assert_equal(Agrawal06iros(xi), actual,1e-6)); | 
					
						
							|  |  |  |   CHECK(assert_equal(xi, logmap(actual),1e-6)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* ************************************************************************* */ | 
					
						
							|  |  |  | TEST(Pose3, Adjoint_compose) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	// To debug derivatives of compose, assert that
 | 
					
						
							|  |  |  | 	// T1*T2*exp(Adjoint(inv(T2),x) = T1*exp(x)*T2
 | 
					
						
							|  |  |  | 	const Pose3& T1 = T; | 
					
						
							|  |  |  | 	Vector x = Vector_(6,0.1,0.1,0.1,0.4,0.2,0.8); | 
					
						
							| 
									
										
										
										
											2010-08-27 03:55:40 +08:00
										 |  |  | 	Pose3 expected = T1 * Pose3::Expmap(x) * T2; | 
					
						
							| 
									
										
										
										
											2010-03-03 01:56:26 +08:00
										 |  |  | 	Vector y = Adjoint(inverse(T2), x); | 
					
						
							| 
									
										
										
										
											2010-08-27 03:55:40 +08:00
										 |  |  | 	Pose3 actual = T1 * T2 * Pose3::Expmap(y); | 
					
						
							| 
									
										
										
										
											2010-03-03 01:56:26 +08:00
										 |  |  | 	CHECK(assert_equal(expected, actual, 1e-6)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | #endif // SLOW_BUT_CORRECT_EXMAP
 | 
					
						
							| 
									
										
										
										
											2010-01-08 11:38:05 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-03-03 01:56:26 +08:00
										 |  |  | /* ************************************************************************* */ | 
					
						
							|  |  |  | TEST( Pose3, compose ) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-08-20 23:17:13 +08:00
										 |  |  | 	Matrix actual = (T2*T2).matrix(); | 
					
						
							|  |  |  | 	Matrix expected = T2.matrix()*T2.matrix(); | 
					
						
							|  |  |  | 	CHECK(assert_equal(actual,expected,1e-8)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Matrix actualDcompose1, actualDcompose2; | 
					
						
							| 
									
										
										
										
											2010-08-27 03:55:40 +08:00
										 |  |  | 	T2.compose(T2, actualDcompose1, actualDcompose2); | 
					
						
							| 
									
										
										
										
											2010-01-08 08:40:17 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-08-27 03:55:40 +08:00
										 |  |  | 	Matrix numericalH1 = numericalDerivative21(testing::compose<Pose3>, T2, T2, 1e-5); | 
					
						
							| 
									
										
										
										
											2010-03-12 05:52:24 +08:00
										 |  |  | 	CHECK(assert_equal(numericalH1,actualDcompose1,5e-5)); | 
					
						
							| 
									
										
										
										
											2010-01-08 08:40:17 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-08-27 03:55:40 +08:00
										 |  |  | 	Matrix numericalH2 = numericalDerivative22(testing::compose<Pose3>, T2, T2, 1e-5); | 
					
						
							| 
									
										
										
										
											2010-03-03 01:56:26 +08:00
										 |  |  | 	CHECK(assert_equal(numericalH2,actualDcompose2)); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-03-03 01:56:26 +08:00
										 |  |  | /* ************************************************************************* */ | 
					
						
							|  |  |  | TEST( Pose3, compose2 ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	const Pose3& T1 = T; | 
					
						
							| 
									
										
										
										
											2010-08-20 23:17:13 +08:00
										 |  |  | 	Matrix actual = (T1*T2).matrix(); | 
					
						
							|  |  |  | 	Matrix expected = T1.matrix()*T2.matrix(); | 
					
						
							|  |  |  | 	CHECK(assert_equal(actual,expected,1e-8)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Matrix actualDcompose1, actualDcompose2; | 
					
						
							| 
									
										
										
										
											2010-08-27 03:55:40 +08:00
										 |  |  | 	T1.compose(T2, actualDcompose1, actualDcompose2); | 
					
						
							| 
									
										
										
										
											2010-03-03 01:56:26 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-08-27 03:55:40 +08:00
										 |  |  | 	Matrix numericalH1 = numericalDerivative21(testing::compose<Pose3>, T1, T2, 1e-5); | 
					
						
							| 
									
										
										
										
											2010-03-12 05:52:24 +08:00
										 |  |  | 	CHECK(assert_equal(numericalH1,actualDcompose1,5e-5)); | 
					
						
							| 
									
										
										
										
											2010-03-03 01:56:26 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-08-27 03:55:40 +08:00
										 |  |  | 	Matrix numericalH2 = numericalDerivative22(testing::compose<Pose3>, T1, T2, 1e-5); | 
					
						
							| 
									
										
										
										
											2010-03-03 01:56:26 +08:00
										 |  |  | 	CHECK(assert_equal(numericalH2,actualDcompose2)); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2010-08-20 04:03:06 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | /* ************************************************************************* */ | 
					
						
							|  |  |  | TEST( Pose3, inverse) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-08-20 23:17:13 +08:00
										 |  |  | 	Matrix actualDinverse; | 
					
						
							| 
									
										
										
										
											2010-08-27 03:55:40 +08:00
										 |  |  | 	Matrix actual = T.inverse(actualDinverse).matrix(); | 
					
						
							| 
									
										
										
										
											2010-08-20 23:17:13 +08:00
										 |  |  | 	Matrix expected = inverse(T.matrix()); | 
					
						
							|  |  |  | 	CHECK(assert_equal(actual,expected,1e-8)); | 
					
						
							| 
									
										
										
										
											2010-01-08 08:40:17 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-08-27 03:55:40 +08:00
										 |  |  | 	Matrix numericalH = numericalDerivative11(testing::inverse<Pose3>, T, 1e-5); | 
					
						
							| 
									
										
										
										
											2010-02-28 17:08:47 +08:00
										 |  |  | 	CHECK(assert_equal(numericalH,actualDinverse)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* ************************************************************************* */ | 
					
						
							|  |  |  | TEST( Pose3, inverseDerivatives2) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-08-20 04:03:06 +08:00
										 |  |  | 	Rot3 R = Rot3::rodriguez(0.3,0.4,-0.5); | 
					
						
							| 
									
										
										
										
											2010-02-28 17:08:47 +08:00
										 |  |  | 	Point3 t(3.5,-8.2,4.2); | 
					
						
							|  |  |  | 	Pose3 T(R,t); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-08-27 03:55:40 +08:00
										 |  |  | 	Matrix numericalH = numericalDerivative11(testing::inverse<Pose3>, T, 1e-5); | 
					
						
							| 
									
										
										
										
											2010-08-20 23:17:13 +08:00
										 |  |  | 	Matrix actualDinverse; | 
					
						
							| 
									
										
										
										
											2010-08-27 03:55:40 +08:00
										 |  |  | 	T.inverse(actualDinverse); | 
					
						
							| 
									
										
										
										
											2010-03-12 05:52:24 +08:00
										 |  |  | 	CHECK(assert_equal(numericalH,actualDinverse,5e-5)); | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* ************************************************************************* */ | 
					
						
							|  |  |  | TEST( Pose3, compose_inverse) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-08-27 03:55:40 +08:00
										 |  |  | 	Matrix actual = (T*T.inverse()).matrix(); | 
					
						
							| 
									
										
										
										
											2010-08-20 23:17:13 +08:00
										 |  |  | 	Matrix expected = eye(4,4); | 
					
						
							|  |  |  | 	CHECK(assert_equal(actual,expected,1e-8)); | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* ************************************************************************* */ | 
					
						
							| 
									
										
										
										
											2010-08-23 05:45:53 +08:00
										 |  |  | Point3 transform_from_(const Pose3& pose, const Point3& point) { return pose.transform_from(point); } | 
					
						
							| 
									
										
										
										
											2010-01-08 08:40:17 +08:00
										 |  |  | TEST( Pose3, Dtransform_from1_a) | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2010-08-20 23:17:13 +08:00
										 |  |  | 	Matrix actualDtransform_from1; | 
					
						
							| 
									
										
										
										
											2010-08-23 05:45:53 +08:00
										 |  |  | 	T.transform_from(P, actualDtransform_from1, boost::none); | 
					
						
							|  |  |  | 	Matrix numerical = numericalDerivative21(transform_from_,T,P); | 
					
						
							| 
									
										
										
										
											2010-08-20 23:17:13 +08:00
										 |  |  | 	CHECK(assert_equal(numerical,actualDtransform_from1,1e-8)); | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-08 08:40:17 +08:00
										 |  |  | TEST( Pose3, Dtransform_from1_b) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	Pose3 origin; | 
					
						
							| 
									
										
										
										
											2010-08-20 23:17:13 +08:00
										 |  |  | 	Matrix actualDtransform_from1; | 
					
						
							| 
									
										
										
										
											2010-08-23 05:45:53 +08:00
										 |  |  | 	origin.transform_from(P, actualDtransform_from1, boost::none); | 
					
						
							|  |  |  | 	Matrix numerical = numericalDerivative21(transform_from_,origin,P); | 
					
						
							| 
									
										
										
										
											2010-08-20 23:17:13 +08:00
										 |  |  | 	CHECK(assert_equal(numerical,actualDtransform_from1,1e-8)); | 
					
						
							| 
									
										
										
										
											2010-01-08 08:40:17 +08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-08 08:40:17 +08:00
										 |  |  | TEST( Pose3, Dtransform_from1_c) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	Point3 origin; | 
					
						
							|  |  |  | 	Pose3 T0(R,origin); | 
					
						
							| 
									
										
										
										
											2010-08-20 23:17:13 +08:00
										 |  |  | 	Matrix actualDtransform_from1; | 
					
						
							| 
									
										
										
										
											2010-08-23 05:45:53 +08:00
										 |  |  | 	T0.transform_from(P, actualDtransform_from1, boost::none); | 
					
						
							|  |  |  | 	Matrix numerical = numericalDerivative21(transform_from_,T0,P); | 
					
						
							| 
									
										
										
										
											2010-08-20 23:17:13 +08:00
										 |  |  | 	CHECK(assert_equal(numerical,actualDtransform_from1,1e-8)); | 
					
						
							| 
									
										
										
										
											2010-01-08 08:40:17 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TEST( Pose3, Dtransform_from1_d) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	Rot3 I; | 
					
						
							|  |  |  | 	Point3 t0(100,0,0); | 
					
						
							|  |  |  | 	Pose3 T0(I,t0); | 
					
						
							| 
									
										
										
										
											2010-08-20 23:17:13 +08:00
										 |  |  | 	Matrix actualDtransform_from1; | 
					
						
							| 
									
										
										
										
											2010-08-23 05:45:53 +08:00
										 |  |  | 	T0.transform_from(P, actualDtransform_from1, boost::none); | 
					
						
							| 
									
										
										
										
											2010-08-20 23:17:13 +08:00
										 |  |  | 	//print(computed, "Dtransform_from1_d computed:");
 | 
					
						
							| 
									
										
										
										
											2010-08-23 05:45:53 +08:00
										 |  |  | 	Matrix numerical = numericalDerivative21(transform_from_,T0,P); | 
					
						
							| 
									
										
										
										
											2010-08-20 23:17:13 +08:00
										 |  |  | 	//print(numerical, "Dtransform_from1_d numerical:");
 | 
					
						
							|  |  |  | 	CHECK(assert_equal(numerical,actualDtransform_from1,1e-8)); | 
					
						
							| 
									
										
										
										
											2010-01-08 08:40:17 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* ************************************************************************* */ | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | TEST( Pose3, Dtransform_from2) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-08-20 23:17:13 +08:00
										 |  |  | 	Matrix actualDtransform_from2; | 
					
						
							| 
									
										
										
										
											2010-08-23 05:45:53 +08:00
										 |  |  | 	T.transform_from(P, boost::none, actualDtransform_from2); | 
					
						
							|  |  |  | 	Matrix numerical = numericalDerivative22(transform_from_,T,P); | 
					
						
							| 
									
										
										
										
											2010-08-20 23:17:13 +08:00
										 |  |  | 	CHECK(assert_equal(numerical,actualDtransform_from2,1e-8)); | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-08 08:40:17 +08:00
										 |  |  | /* ************************************************************************* */ | 
					
						
							| 
									
										
										
										
											2010-08-23 05:45:53 +08:00
										 |  |  | Point3 transform_to_(const Pose3& pose, const Point3& point) { return pose.transform_to(point); } | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | TEST( Pose3, Dtransform_to1) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-08-20 23:17:13 +08:00
										 |  |  | 	Matrix computed; | 
					
						
							| 
									
										
										
										
											2010-08-23 05:45:53 +08:00
										 |  |  | 	T.transform_to(P, computed, boost::none); | 
					
						
							|  |  |  | 	Matrix numerical = numericalDerivative21(transform_to_,T,P); | 
					
						
							| 
									
										
										
										
											2010-08-20 23:17:13 +08:00
										 |  |  | 	CHECK(assert_equal(numerical,computed,1e-8)); | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-08 08:40:17 +08:00
										 |  |  | /* ************************************************************************* */ | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | TEST( Pose3, Dtransform_to2) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-08-20 23:17:13 +08:00
										 |  |  | 	Matrix computed; | 
					
						
							| 
									
										
										
										
											2010-08-23 05:45:53 +08:00
										 |  |  | 	T.transform_to(P, boost::none, computed); | 
					
						
							|  |  |  | 	Matrix numerical = numericalDerivative22(transform_to_,T,P); | 
					
						
							| 
									
										
										
										
											2010-08-20 23:17:13 +08:00
										 |  |  | 	CHECK(assert_equal(numerical,computed,1e-8)); | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2010-01-08 08:40:17 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-05-18 22:51:09 +08:00
										 |  |  | /* ************************************************************************* */ | 
					
						
							|  |  |  | TEST( Pose3, transform_to_with_derivatives) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	Matrix actH1, actH2; | 
					
						
							| 
									
										
										
										
											2010-08-23 05:45:53 +08:00
										 |  |  | 	T.transform_to(P,actH1,actH2); | 
					
						
							|  |  |  | 	Matrix expH1 = numericalDerivative21(transform_to_, T,P), | 
					
						
							|  |  |  | 		   expH2 = numericalDerivative22(transform_to_, T,P); | 
					
						
							| 
									
										
										
										
											2010-05-18 22:51:09 +08:00
										 |  |  | 	CHECK(assert_equal(expH1, actH1, 1e-8)); | 
					
						
							|  |  |  | 	CHECK(assert_equal(expH2, actH2, 1e-8)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* ************************************************************************* */ | 
					
						
							|  |  |  | TEST( Pose3, transform_from_with_derivatives) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	Matrix actH1, actH2; | 
					
						
							| 
									
										
										
										
											2010-08-23 05:45:53 +08:00
										 |  |  | 	T.transform_from(P,actH1,actH2); | 
					
						
							|  |  |  | 	Matrix expH1 = numericalDerivative21(transform_from_, T,P), | 
					
						
							|  |  |  | 		   expH2 = numericalDerivative22(transform_from_, T,P); | 
					
						
							| 
									
										
										
										
											2010-05-18 22:51:09 +08:00
										 |  |  | 	CHECK(assert_equal(expH1, actH1, 1e-8)); | 
					
						
							|  |  |  | 	CHECK(assert_equal(expH2, actH2, 1e-8)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | /* ************************************************************************* */ | 
					
						
							|  |  |  | TEST( Pose3, transform_to_translate) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-08-23 05:45:53 +08:00
										 |  |  | 		Point3 actual = Pose3(Rot3(), Point3(1, 2, 3)).transform_to(Point3(10.,20.,30.)); | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | 		Point3 expected(9.,18.,27.); | 
					
						
							| 
									
										
										
										
											2010-08-20 04:03:06 +08:00
										 |  |  | 		CHECK(assert_equal(expected, actual)); | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2010-01-08 08:40:17 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* ************************************************************************* */ | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | TEST( Pose3, transform_to_rotate) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-08-20 04:03:06 +08:00
										 |  |  | 		Pose3 transform(Rot3::rodriguez(0,0,-1.570796), Point3()); | 
					
						
							| 
									
										
										
										
											2010-08-23 05:45:53 +08:00
										 |  |  | 		Point3 actual = transform.transform_to(Point3(2,1,10)); | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | 		Point3 expected(-1,2,10); | 
					
						
							| 
									
										
										
										
											2010-08-20 04:03:06 +08:00
										 |  |  | 		CHECK(assert_equal(expected, actual, 0.001)); | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2010-01-08 08:40:17 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* ************************************************************************* */ | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | TEST( Pose3, transform_to) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-08-20 04:03:06 +08:00
										 |  |  | 		Pose3 transform(Rot3::rodriguez(0,0,-1.570796), Point3(2,4, 0)); | 
					
						
							| 
									
										
										
										
											2010-08-23 05:45:53 +08:00
										 |  |  | 		Point3 actual = transform.transform_to(Point3(3,2,10)); | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | 		Point3 expected(2,1,10); | 
					
						
							| 
									
										
										
										
											2010-08-20 04:03:06 +08:00
										 |  |  | 		CHECK(assert_equal(expected, actual, 0.001)); | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* ************************************************************************* */ | 
					
						
							|  |  |  | TEST( Pose3, transform_from) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-08-23 05:45:53 +08:00
										 |  |  | 		Point3 actual = T3.transform_from(Point3()); | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | 		Point3 expected = Point3(1.,2.,3.); | 
					
						
							|  |  |  | 		CHECK(assert_equal(expected, actual)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* ************************************************************************* */ | 
					
						
							|  |  |  | TEST( Pose3, transform_roundtrip) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-08-23 05:45:53 +08:00
										 |  |  | 		Point3 actual = T3.transform_from(T3.transform_to(Point3(12., -0.11,7.0))); | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | 		Point3 expected(12., -0.11,7.0); | 
					
						
							|  |  |  | 		CHECK(assert_equal(expected, actual)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* ************************************************************************* */ | 
					
						
							|  |  |  | TEST( Pose3, transformPose_to_origin) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 		// transform to origin
 | 
					
						
							| 
									
										
										
										
											2010-03-03 01:56:26 +08:00
										 |  |  | 		Pose3 actual = T3.transform_to(Pose3()); | 
					
						
							| 
									
										
										
										
											2010-03-12 05:52:24 +08:00
										 |  |  | 		CHECK(assert_equal(T3, actual, 1e-8)); | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2010-01-08 08:40:17 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* ************************************************************************* */ | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | TEST( Pose3, transformPose_to_itself) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 		// transform to itself
 | 
					
						
							| 
									
										
										
										
											2010-03-03 01:56:26 +08:00
										 |  |  | 		Pose3 actual = T3.transform_to(T3); | 
					
						
							| 
									
										
										
										
											2010-03-12 05:52:24 +08:00
										 |  |  | 		CHECK(assert_equal(Pose3(), actual, 1e-8)); | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2010-01-08 08:40:17 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* ************************************************************************* */ | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | TEST( Pose3, transformPose_to_translation) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 		// transform translation only
 | 
					
						
							| 
									
										
										
										
											2010-08-20 04:03:06 +08:00
										 |  |  | 		Rot3 r = Rot3::rodriguez(-1.570796,0,0); | 
					
						
							|  |  |  | 		Pose3 pose2(r, Point3(21.,32.,13.)); | 
					
						
							| 
									
										
										
										
											2009-12-18 13:36:53 +08:00
										 |  |  | 		Pose3 actual = pose2.transform_to(Pose3(Rot3(), Point3(1,2,3))); | 
					
						
							| 
									
										
										
										
											2010-08-20 04:03:06 +08:00
										 |  |  | 		Pose3 expected(r, Point3(20.,30.,10.)); | 
					
						
							| 
									
										
										
										
											2010-03-12 05:52:24 +08:00
										 |  |  | 		CHECK(assert_equal(expected, actual, 1e-8)); | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2010-01-08 08:40:17 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* ************************************************************************* */ | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | TEST( Pose3, transformPose_to_simple_rotate) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 		// transform translation only
 | 
					
						
							| 
									
										
										
										
											2010-08-20 04:03:06 +08:00
										 |  |  | 		Rot3 r = Rot3::rodriguez(0,0,-1.570796); | 
					
						
							|  |  |  | 		Pose3 pose2(r, Point3(21.,32.,13.)); | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | 		Pose3 transform(r, Point3(1,2,3)); | 
					
						
							| 
									
										
										
										
											2009-12-18 13:36:53 +08:00
										 |  |  | 		Pose3 actual = pose2.transform_to(transform); | 
					
						
							| 
									
										
										
										
											2010-08-20 04:03:06 +08:00
										 |  |  | 		Pose3 expected(Rot3(), Point3(-30.,20.,10.)); | 
					
						
							|  |  |  | 		CHECK(assert_equal(expected, actual, 0.001)); | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2010-01-08 08:40:17 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* ************************************************************************* */ | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | TEST( Pose3, transformPose_to) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 		// transform to
 | 
					
						
							| 
									
										
										
										
											2010-08-20 04:03:06 +08:00
										 |  |  | 		Rot3 r = Rot3::rodriguez(0,0,-1.570796); //-90 degree yaw
 | 
					
						
							|  |  |  | 		Rot3 r2 = Rot3::rodriguez(0,0,0.698131701); //40 degree yaw
 | 
					
						
							|  |  |  | 		Pose3 pose2(r2, Point3(21.,32.,13.)); | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | 		Pose3 transform(r, Point3(1,2,3)); | 
					
						
							| 
									
										
										
										
											2009-12-18 13:36:53 +08:00
										 |  |  | 		Pose3 actual = pose2.transform_to(transform); | 
					
						
							| 
									
										
										
										
											2010-08-20 04:03:06 +08:00
										 |  |  | 		Pose3 expected(Rot3::rodriguez(0,0,2.26892803), Point3(-30.,20.,10.)); | 
					
						
							|  |  |  | 		CHECK(assert_equal(expected, actual, 0.001)); | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-08 08:40:17 +08:00
										 |  |  | /* ************************************************************************* */ | 
					
						
							| 
									
										
										
										
											2010-01-10 20:26:31 +08:00
										 |  |  | TEST(Pose3, manifold) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	//cout << "manifold" << endl;
 | 
					
						
							| 
									
										
										
										
											2010-01-08 08:40:17 +08:00
										 |  |  | 	Pose3 t1 = T; | 
					
						
							| 
									
										
										
										
											2010-03-03 01:56:26 +08:00
										 |  |  | 	Pose3 t2 = T3; | 
					
						
							| 
									
										
										
										
											2010-01-08 08:40:17 +08:00
										 |  |  | 	Pose3 origin; | 
					
						
							| 
									
										
										
										
											2010-08-27 03:55:40 +08:00
										 |  |  | 	Vector d12 = t1.logmap(t2); | 
					
						
							|  |  |  | 	CHECK(assert_equal(t2, t1.expmap(d12))); | 
					
						
							| 
									
										
										
										
											2010-01-08 08:40:17 +08:00
										 |  |  | 	// todo: richard - commented out because this tests for "compose-style" (new) expmap
 | 
					
						
							| 
									
										
										
										
											2010-01-10 20:26:31 +08:00
										 |  |  | 	// CHECK(assert_equal(t2, expmap(origin,d12)*t1));
 | 
					
						
							| 
									
										
										
										
											2010-08-27 03:55:40 +08:00
										 |  |  | 	Vector d21 = t2.logmap(t1); | 
					
						
							|  |  |  | 	CHECK(assert_equal(t1, t2.expmap(d21))); | 
					
						
							| 
									
										
										
										
											2010-01-10 20:26:31 +08:00
										 |  |  | 	// todo: richard - commented out because this tests for "compose-style" (new) expmap
 | 
					
						
							|  |  |  | 	// CHECK(assert_equal(t1, expmap(origin,d21)*t2));
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// Check that log(t1,t2)=-log(t2,t1) - this holds even for incorrect expmap :-)
 | 
					
						
							|  |  |  | 	CHECK(assert_equal(d12,-d21)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-03-13 03:16:53 +08:00
										 |  |  | #ifdef CORRECT_POSE3_EXMAP
 | 
					
						
							| 
									
										
										
										
											2010-03-12 05:52:24 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-10 20:26:31 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// todo: Frank - Below only works for correct "Agrawal06iros style expmap
 | 
					
						
							|  |  |  | 	// lines in canonical coordinates correspond to Abelian subgroups in SE(3)
 | 
					
						
							|  |  |  | 	 Vector d = Vector_(6,0.1,0.2,0.3,0.4,0.5,0.6); | 
					
						
							|  |  |  | 	// exp(-d)=inverse(exp(d))
 | 
					
						
							| 
									
										
										
										
											2010-08-27 03:55:40 +08:00
										 |  |  | 	 CHECK(assert_equal(Pose3::Expmap(-d),inverse(Pose3::Expmap(d)))); | 
					
						
							| 
									
										
										
										
											2010-01-10 20:26:31 +08:00
										 |  |  | 	// exp(5d)=exp(2*d+3*d)=exp(2*d)exp(3*d)=exp(3*d)exp(2*d)
 | 
					
						
							| 
									
										
										
										
											2010-08-27 03:55:40 +08:00
										 |  |  | 	 Pose3 T2 = Pose3::Expmap(2*d); | 
					
						
							|  |  |  | 	 Pose3 T3 = Pose3::Expmap(3*d); | 
					
						
							|  |  |  | 	 Pose3 T5 = Pose3::Expmap(5*d); | 
					
						
							| 
									
										
										
										
											2010-01-10 20:26:31 +08:00
										 |  |  | 	 CHECK(assert_equal(T5,T2*T3)); | 
					
						
							|  |  |  | 	 CHECK(assert_equal(T5,T3*T2)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2010-01-08 08:40:17 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* ************************************************************************* */ | 
					
						
							|  |  |  | TEST( Pose3, between ) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2010-08-27 03:55:40 +08:00
										 |  |  | 	Pose3 expected = T2.inverse() * T3; | 
					
						
							| 
									
										
										
										
											2010-02-28 17:08:47 +08:00
										 |  |  | 	Matrix actualDBetween1,actualDBetween2; | 
					
						
							| 
									
										
										
										
											2010-08-27 03:55:40 +08:00
										 |  |  | 	Pose3 actual = T2.between(T3, actualDBetween1,actualDBetween2); | 
					
						
							| 
									
										
										
										
											2010-01-08 08:40:17 +08:00
										 |  |  | 	CHECK(assert_equal(expected,actual)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-08-27 03:55:40 +08:00
										 |  |  | 	Matrix numericalH1 = numericalDerivative21(testing::between<Pose3> , T2, T3, 1e-5); | 
					
						
							| 
									
										
										
										
											2010-03-12 05:52:24 +08:00
										 |  |  | 	CHECK(assert_equal(numericalH1,actualDBetween1,5e-5)); | 
					
						
							| 
									
										
										
										
											2010-01-08 08:40:17 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-08-27 03:55:40 +08:00
										 |  |  | 	Matrix numericalH2 = numericalDerivative22(testing::between<Pose3> , T2, T3, 1e-5); | 
					
						
							| 
									
										
										
										
											2010-02-28 17:08:47 +08:00
										 |  |  | 	CHECK(assert_equal(numericalH2,actualDBetween2)); | 
					
						
							| 
									
										
										
										
											2009-08-22 06:23:24 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* ************************************************************************* */ | 
					
						
							|  |  |  | int main(){ TestResult tr; return TestRegistry::runAllTests(tr);} | 
					
						
							|  |  |  | /* ************************************************************************* */ |