2 GTSAM Copyright 2010-2019, Georgia Tech Research Corporation, 3 Atlanta, Georgia 30332-0415 6 See LICENSE for the license information 9 Author: Frank Dellaert & Duy Nguyen Ta & John Lambert 17 from gtsam
import Point2, Point2Pairs, Pose2
21 """Test selected Pose2 methods.""" 24 """Test adjoint method.""" 25 xi = np.array([1, 2, 3])
26 expected = np.dot(Pose2.adjointMap_(xi), xi)
27 actual = Pose2.adjoint_(xi, xi)
28 np.testing.assert_array_equal(actual, expected)
31 """Test transformTo method.""" 32 pose =
Pose2(2, 4, -math.pi / 2)
33 actual = pose.transformTo(
Point2(3, 2))
39 actual_array = pose.transformTo(points)
40 self.assertEqual(actual_array.shape, (2, 2))
41 expected_array = np.stack([expected, expected]).T
42 np.testing.assert_allclose(actual_array, expected_array, atol=1e-6)
45 """Test transformFrom method.""" 46 pose =
Pose2(2, 4, -math.pi / 2)
47 actual = pose.transformFrom(
Point2(2, 1))
53 actual_array = pose.transformFrom(points)
54 self.assertEqual(actual_array.shape, (2, 2))
55 expected_array = np.stack([expected, expected]).T
56 np.testing.assert_allclose(actual_array, expected_array, atol=1e-6)
59 """Ensure estimation of the Pose2 element to align two 2d point clouds succeeds. 61 Two point clouds represent horseshoe-shapes of the same size, just rotated and translated: 87 ab_pairs =
list(zip(pts_a, pts_b))
88 aTb = Pose2.Align(ab_pairs)
89 self.assertIsNotNone(aTb)
91 for pt_a, pt_b
in zip(pts_a, pts_b):
92 pt_a_ = aTb.transformFrom(pt_b)
93 np.testing.assert_allclose(pt_a, pt_a_)
98 aTb = Pose2.Align(A, B)
99 self.assertIsNotNone(aTb)
101 for pt_a, pt_b
in zip(pts_a, pts_b):
102 pt_a_ = aTb.transformFrom(pt_b)
103 np.testing.assert_allclose(pt_a, pt_a_)
106 if __name__ ==
"__main__":
def test_transformTo(self)
def test_transformFrom(self)
def gtsamAssertEquals(self, actual, expected, tol=1e-9)