test_SOn.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 Dynamic SO(n) unit tests.
9 Author: Frank Dellaert
10 """
11 # pylint: disable=no-name-in-module, import-error
12 import unittest
13 
14 import numpy as np
15 from gtsam import SOn
16 
17 I4 = SOn(4)
18 v1 = np.array([0, 0, 0, .1, 0, 0])
19 v2 = np.array([0, 0, 0, 0.01, 0.02, 0.03])
20 Q1 = I4.retract(v1)
21 Q2 = I4.retract(v2)
22 
23 
24 class TestSO4(unittest.TestCase):
25  """Test selected SOn methods."""
26 
27  def test_constructor(self):
28  """Construct from matrix."""
29  matrix = np.eye(4)
30  so4 = SOn.FromMatrix(matrix)
31  self.assertIsInstance(so4, SOn)
32 
33  def test_retract(self):
34  """Test retraction to manifold."""
35  v = np.zeros((6,), float)
36  actual = I4.retract(v)
37  self.assertTrue(actual.equals(I4, 1e-9))
38 
39  def test_local(self):
40  """Check localCoordinates for trivial case."""
41  v0 = np.zeros((6,), float)
42  actual = I4.localCoordinates(I4)
43  np.testing.assert_array_almost_equal(actual, v0)
44 
45  def test_compose(self):
46  """Check compose works in subgroup."""
47  expected = I4.retract(2*v1)
48  actual = Q1.compose(Q1)
49  self.assertTrue(actual.equals(expected, 1e-3)) # not exmap so only approximate
50 
51  def test_vec(self):
52  """Check wrapping of vec."""
53  expected = np.array([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1])
54  actual = I4.vec()
55  np.testing.assert_array_equal(actual, expected)
56 
57 
58 if __name__ == "__main__":
59  unittest.main()
test_SOn.TestSO4.test_vec
def test_vec(self)
Definition: test_SOn.py:51
gtsam::SOn
SO< Eigen::Dynamic > SOn
Definition: SOn.h:342
test_SOn.TestSO4
Definition: test_SOn.py:24
test_SOn.TestSO4.test_retract
def test_retract(self)
Definition: test_SOn.py:33
test_SOn.TestSO4.test_local
def test_local(self)
Definition: test_SOn.py:39
test_SOn.TestSO4.test_constructor
def test_constructor(self)
Definition: test_SOn.py:27
test_SOn.TestSO4.test_compose
def test_compose(self)
Definition: test_SOn.py:45


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:07:08