Skip to content

Commit 4130de1

Browse files
committed
add unit tests for trlog and trexp
1 parent 9402b2a commit 4130de1

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

tests/base/test_transforms3d.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from scipy.linalg import logm, expm
1717

1818
from spatialmath.base.transforms3d import *
19-
from spatialmath.base.transformsNd import isR, t2r, r2t, rt2tr
19+
from spatialmath.base.transformsNd import isR, t2r, r2t, rt2tr, skew
2020
class Test3D(unittest.TestCase):
2121
def test_checks(self):
2222
# 2D case, with rotation matrix
@@ -293,6 +293,34 @@ def test_angvec2tr(self):
293293
nt.assert_array_almost_equal(angvec2r(pi / 4, [1, 0, 0]), rotx(pi / 4))
294294
nt.assert_array_almost_equal(angvec2r(-pi / 4, [1, 0, 0]), rotx(-pi / 4))
295295

296+
def test_trlog(self):
297+
R = rotx(0.5)
298+
nt.assert_array_almost_equal(trlog(R), skew([0.5, 0, 0]))
299+
R = roty(0.5)
300+
nt.assert_array_almost_equal(trlog(R), skew([0, 0.5, 0]))
301+
R = rotz(0.5)
302+
nt.assert_array_almost_equal(trlog(R), skew([0, 0, 0.5]))
303+
304+
R = rpy2r(0.1, 0.2, 0.3)
305+
nt.assert_array_almost_equal(logm(R), trlog(R))
306+
307+
T = transl(1, 2, 3) @ rpy2tr(0.1, 0.2, 0.3)
308+
nt.assert_array_almost_equal(logm(T), trlog(T))
309+
310+
def test_trexp(self):
311+
R = trexp(skew([0.5, 0, 0]))
312+
nt.assert_array_almost_equal(R, rotx(0.5))
313+
R = trexp(skew([0, 0.5, 0]))
314+
nt.assert_array_almost_equal(R, roty(0.5))
315+
R = trexp(skew([0, 0, 0.5]))
316+
nt.assert_array_almost_equal(R, rotz(0.5))
317+
318+
R = rpy2r(0.1, 0.2, 0.3)
319+
nt.assert_array_almost_equal(trexp(logm(R)), R)
320+
321+
T = transl(1, 2, 3) @ rpy2tr(0.1, 0.2, 0.3)
322+
nt.assert_array_almost_equal(trexp(logm(T)), T)
323+
296324
def test_exp2r(self):
297325

298326
r2d = 180 / pi

0 commit comments

Comments
 (0)