8000 Merge pull request #88 from bdaiinstitute/mpickett/check_fix · andybarry/spatialmath-python@57ae2c8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 57ae2c8

Browse files
Merge pull request bdaiinstitute#88 from bdaiinstitute/mpickett/check_fix
[N/A] Check fix for eulervec and tr2angvec
2 parents 328b65c + a897321 commit 57ae2c8

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

spatialmath/base/transforms3d.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1023,7 +1023,7 @@ def tr2angvec(
10231023
if not isrot(R, check=check):
10241024
raise ValueError("argument is not SO(3)")
10251025

1026-
v = vex(trlog(cast(SO3Array, R)))
1026+
v = vex(trlog(cast(SO3Array, R), check=check))
10271027

10281028
try:
10291029
theta = norm(v)

tests/test_transforms3d.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import numpy.testing as nt
2+
import unittest
3+
4+
"""
5+
we will assume that the primitives rotx,trotx, etc. all work
6+
"""
7+
from spatialmath import SE3, SO3, SE2
8+
import numpy as np
9+
import spatialmath.base.transforms3d as t3d
10+
11+
12+
class TestTransforms3D(unittest.TestCase):
13+
@classmethod
14+
def tearDownClass(cls):
15+
pass
16+
17+
def test_tr2angvec(self):
18+
true_ang = 1.51
19+
true_vec = np.array([0., 1., 0.])
20+
eps = 1e-08
21+
22+
# show that tr2angvec works on true rotation matrix
23+
R = SO3.Ry(true_ang)
24+
ang, vec = t3d.tr2angvec(R.A, check=True)
25+
nt.assert_equal(ang, true_ang)
26+
nt.assert_equal(vec, true_vec)
27+
28+
# check a rotation matrix that should fail
29+
badR = SO3.Ry(true_ang).A[:, :] + eps
30+
with self.assertRaises(ValueError):
31+
t3d.tr2angvec(badR, check=True)
32+
33+
# run without check
34+
ang, vec = t3d.tr2angvec(badR, check=False)
35+
nt.assert_almost_equal(ang, true_ang)
36+
nt.assert_equal(vec, true_vec)
37+
38+
39+
# ---------------------------------------------------------------------------------------#
40+
if __name__ == '__main__':
41+
42+
unittest.main()

0 commit comments

Comments
 (0)
0