Skip to content

Commit 3f06d5e

Browse files
authored
Test SE3 and SO3 construction from a stacked array
Add unit test for SE3 constructor with stacked array input.
1 parent 1057abf commit 3f06d5e

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

‎tests/test_pose3d.py‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,26 @@ class TestSE3(unittest.TestCase):
784784
def tearDownClass(cls):
785785
plt.close("all")
786786

787+
def test_constructor_stacked_array(self):
788+
# an (N, 4, 4) ndarray is a sequence of N poses, like a list of 4x4 arrays
789+
poses = [SE3.Rx(0.3), SE3(1, 2, 3) * SE3.Ry(0.4), SE3.Rz(-0.2)]
790+
stacked = np.array([T.A for T in poses])
791+
for check in (True, False):
792+
T = SE3(stacked, check=check)
793+
self.assertEqual(len(T), 3)
794+
for k in range(3):
795+
nt.assert_array_almost_equal(T[k].A, poses[k].A)
796+
self.assertEqual(len(SE3(np.empty((0, 4, 4)))), 0)
797+
self.assertEqual(len(SO3(np.array([SO3.Rx(0.1).A, SO3.Ry(0.2).A]))), 2)
798+
799+
# stacked matrices that are not valid poses are still rejected by check=True
800+
with self.assertRaises(ValueError):
801+
SE3(2 * stacked)
802+
# and a stack of matrices of the wrong size is rejected whatever the value of check
803+
for check in (True, False):
804+
with self.assertRaises(ValueError):
805+
SE3(np.ones((3, 3, 3)), check=check)
806+
787807
def test_constructor(self):
788808
# null constructor
789809
R = SE3()

0 commit comments

Comments
 (0)