From d6f403b698b2e5f7ffb6987a8593d6415131ac95 Mon Sep 17 00:00:00 2001 From: Michael Pickett Date: Thu, 2 Nov 2023 13:37:57 -0400 Subject: [PATCH 1/3] Check fix for eulervec and tr2angvec --- spatialmath/base/transforms3d.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spatialmath/base/transforms3d.py b/spatialmath/base/transforms3d.py index ff555b09..81e05069 100644 --- a/spatialmath/base/transforms3d.py +++ b/spatialmath/base/transforms3d.py @@ -1023,7 +1023,7 @@ def tr2angvec( if not isrot(R, check=check): raise ValueError("argument is not SO(3)") - v = vex(trlog(cast(SO3Array, R))) + v = vex(trlog(cast(SO3Array, R), check=check)) try: theta = norm(v) From 5ea9d991a60d85d01ac2c34a7e642b35d6b25947 Mon Sep 17 00:00:00 2001 From: Michael Pickett Date: Thu, 2 Nov 2023 16:31:29 -0400 Subject: [PATCH 2/3] Unit test --- tests/test_transforms3d.py | 50 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100755 tests/test_transforms3d.py diff --git a/tests/test_transforms3d.py b/tests/test_transforms3d.py new file mode 100755 index 00000000..46aa9b35 --- /dev/null +++ b/tests/test_transforms3d.py @@ -0,0 +1,50 @@ +import numpy.testing as nt +import matplotlib.pyplot as plt +import unittest + +""" +we will assume that the primitives rotx,trotx, etc. all work +""" +from math import pi +from spatialmath import SE3, SO3, SE2 +import numpy as np +# from spatialmath import super_pose as sp +from spatialmath.base import * +from spatialmath.base import argcheck +import spatialmath as sm +from spatialmath.baseposematrix import BasePoseMatrix +from spatialmath.twist import BaseTwist +import spatialmath.base.transforms3d as t3d + + +class TestTransforms3D(unittest.TestCase): + @classmethod + def tearDownClass(cls): + pass + + def test_tr2angvec(self): + true_ang = 1.51 + true_vec = np.array([0., 1., 0.]) + eps = 1e-08 + + # show that tr2angvec works on true rotation matrix + R = SO3.Ry(true_ang) + ang, vec = t3d.tr2angvec(R.A, check=True) + nt.assert_equal(ang, true_ang) + nt.assert_equal(vec, true_vec) + + # check a rotation matrix that should fail + badR = SO3.Ry(true_ang).A[:, :] + eps + with self.assertRaises(ValueError): + t3d.tr2angvec(badR, check=True) + + # run without check + ang, vec = t3d.tr2angvec(badR, check=False) + nt.assert_almost_equal(ang, true_ang) + nt.assert_equal(vec, true_vec) + + +# ---------------------------------------------------------------------------------------# +if __name__ == '__main__': + + unittest.main() From a8973218d5e5acb9201baf1030a9f61b2d7c4ca8 Mon Sep 17 00:00:00 2001 From: Michael Pickett Date: Thu, 2 Nov 2023 16:32:53 -0400 Subject: [PATCH 3/3] clean up --- tests/test_transforms3d.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/tests/test_transforms3d.py b/tests/test_transforms3d.py index 46aa9b35..100b9a99 100755 --- a/tests/test_transforms3d.py +++ b/tests/test_transforms3d.py @@ -1,19 +1,11 @@ import numpy.testing as nt -import matplotlib.pyplot as plt import unittest """ we will assume that the primitives rotx,trotx, etc. all work """ -from math import pi from spatialmath import SE3, SO3, SE2 import numpy as np -# from spatialmath import super_pose as sp -from spatialmath.base import * -from spatialmath.base import argcheck -import spatialmath as sm -from spatialmath.baseposematrix import BasePoseMatrix -from spatialmath.twist import BaseTwist import spatialmath.base.transforms3d as t3d