Skip to content

Commit

Permalink
Merge pull request #88 from bdaiinstitute/mpickett/check_fix
Browse files Browse the repository at this point in the history
[N/A] Check fix for eulervec and tr2angvec
  • Loading branch information
myeatman-bdai authored Nov 3, 2023
2 parents 328b65c + a897321 commit 57ae2c8
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion spatialmath/base/transforms3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
42 changes: 42 additions & 0 deletions tests/test_transforms3d.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import numpy.testing as nt
import unittest

"""
we will assume that the primitives rotx,trotx, etc. all work
"""
from spatialmath import SE3, SO3, SE2
import numpy as np
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()

0 comments on commit 57ae2c8

Please sign in to comment.