test_Pose3.py
Go to the documentation of this file.
1 """
2 GTSAM Copyright 2010-2019, Georgia Tech Research Corporation,
3 Atlanta, Georgia 30332-0415
4 All Rights Reserved
5 
6 See LICENSE for the license information
7 
8 Pose3 unit tests.
9 Author: Frank Dellaert, Duy Nguyen Ta
10 """
11 # pylint: disable=no-name-in-module
12 import math
13 import unittest
14 
15 import numpy as np
16 
17 import gtsam
18 from gtsam import Point3, Pose3, Rot3
19 from gtsam.utils.test_case import GtsamTestCase
20 
21 
23  """Test selected Pose3 methods."""
24 
25  def test_between(self):
26  """Test between method."""
27  T2 = Pose3(Rot3.Rodrigues(0.3, 0.2, 0.1), Point3(3.5, -8.2, 4.2))
28  T3 = Pose3(Rot3.Rodrigues(-90, 0, 0), Point3(1, 2, 3))
29  expected = T2.inverse().compose(T3)
30  actual = T2.between(T3)
31  self.gtsamAssertEquals(actual, expected, 1e-6)
32 
33  def test_transform_to(self):
34  """Test transformTo method."""
35  transform = Pose3(Rot3.Rodrigues(0, 0, -1.570796), Point3(2, 4, 0))
36  actual = transform.transformTo(Point3(3, 2, 10))
37  expected = Point3(2, 1, 10)
38  self.gtsamAssertEquals(actual, expected, 1e-6)
39 
40  def test_range(self):
41  """Test range method."""
42  l1 = Point3(1, 0, 0)
43  l2 = Point3(1, 1, 0)
44  x1 = Pose3()
45 
46  xl1 = Pose3(Rot3.Ypr(0.0, 0.0, 0.0), Point3(1, 0, 0))
47  xl2 = Pose3(Rot3.Ypr(0.0, 1.0, 0.0), Point3(1, 1, 0))
48 
49  # establish range is indeed zero
50  self.assertEqual(1, x1.range(point=l1))
51 
52  # establish range is indeed sqrt2
53  self.assertEqual(math.sqrt(2.0), x1.range(point=l2))
54 
55  # establish range is indeed zero
56  self.assertEqual(1, x1.range(pose=xl1))
57 
58  # establish range is indeed sqrt2
59  self.assertEqual(math.sqrt(2.0), x1.range(pose=xl2))
60 
61  def test_adjoint(self):
62  """Test adjoint method."""
63  xi = np.array([1, 2, 3, 4, 5, 6])
64  expected = np.dot(Pose3.adjointMap_(xi), xi)
65  actual = Pose3.adjoint_(xi, xi)
66  np.testing.assert_array_equal(actual, expected)
67 
68  def test_serialization(self):
69  """Test if serialization is working normally"""
70  expected = Pose3(Rot3.Ypr(0.0, 1.0, 0.0), Point3(1, 1, 0))
71  actual = Pose3()
72  serialized = expected.serialize()
73  actual.deserialize(serialized)
74  self.gtsamAssertEquals(expected, actual, 1e-10)
75 
76 
77 if __name__ == "__main__":
78  unittest.main()
def test_adjoint(self)
Definition: test_Pose3.py:61
def test_range(self)
Definition: test_Pose3.py:40
def gtsamAssertEquals(self, actual, expected, tol=1e-9)
Definition: test_case.py:18
def test_serialization(self)
Definition: test_Pose3.py:68
def test_transform_to(self)
Definition: test_Pose3.py:33
T compose(const T &t1, const T &t2)
Definition: lieProxies.h:39
def test_between(self)
Definition: test_Pose3.py:25
Vector3 Point3
Definition: Point3.h:35


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:46:04