Skip to content

Commit 651f7c5

Browse files
committed
fix bug with SE2 to SE3 conversion
1 parent 2e15eaf commit 651f7c5

3 files changed

Lines changed: 29 additions & 3 deletions

File tree

docs/source/intro.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ The classes ``SE3``, ``SO3``, ``SE2`` and ``SO2`` can provide colorized text out
263263
with rotational elements in red, translational elements in blue and constants in grey.
264264

265265
The foreground and background colors can be controlled using the following
266-
class variables for the ``SMPose`` subclasses
266+
class variables for the ``BasePoseMatrix`` subclasses
267267

268268
=============== =================== ============================================
269269
Variable Default Description

spatialmath/pose3d.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@ def __init__(self, x=None, y=None, z=None, *, check=True):
738738
return
739739
elif isinstance(x, SO3):
740740
self.data = [base.r2t(_x) for _x in x.data]
741-
elif isinstance(x, SE2):
741+
elif type(x).__name__ == 'SE2':
742742
def convert(x):
743743
# convert SE(2) to SE(3)
744744
out = np.identity(4, dtype=x.dtype)

tests/test_pose3d.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
we will assume that the primitives rotx,trotx, etc. all work
77
"""
88
from math import pi
9-
from spatialmath.pose3d import *
9+
from spatialmath import SE3, SO3, SE2
10+
import numpy as np
1011
# from spatialmath import super_pose as sp
1112
from spatialmath.base import *
1213
from spatialmath.base import argcheck
@@ -777,12 +778,37 @@ def test_constructor(self):
777778
nt.assert_equal(len(R), 1)
778779
self.assertIsInstance(R, SE3)
779780

781+
# random
782+
T = SE3.Rand()
783+
R = T.R
784+
t = T.t
785+
T = SE3.Rt(R, t)
786+
self.assertIsInstance(T, SE3)
787+
self.assertEqual(T.A.shape, (4,4))
788+
789+
nt.assert_equal(T.R, R)
790+
nt.assert_equal(T.t, t)
791+
792+
780793
# copy constructor
781794
R = SE3.Rx(pi / 2)
782795
R2 = SE3(R)
783796
R = SE3.Ry(pi / 2)
784797
array_compare(R2, trotx(pi / 2))
785798

799+
# SO3
800+
T = SE3(SO3())
801+
nt.assert_equal(len(T), 1)
802+
self.assertIsInstance(T, SE3)
803+
nt.assert_equal(T.A, np.eye(4))
804+
805+
# SE2
806+
T = SE3(SE2(1, 2, 0.4))
807+
nt.assert_equal(len(T), 1)
808+
self.assertIsInstance(T, SE3)
809+
self.assertEqual(T.A.shape, (4,4))
810+
nt.assert_equal(T.t, [1, 2, 0])
811+
786812
def test_shape(self):
787813
a = SE3()
788814
self.assertEqual(a._A.shape, a.shape)

0 commit comments

Comments
 (0)