|
8 | 8 | we will assume that the primitives rotx,trotx, etc. all work |
9 | 9 | """ |
10 | 10 | from math import pi |
11 | | -from spatialmath import SE3, SO3, SE2 |
| 11 | +from spatialmath import SE3, SO3, SE2, UnitQuaternion |
12 | 12 | import numpy as np |
13 | 13 | from spatialmath.base import * |
14 | 14 | from spatialmath.baseposematrix import BasePoseMatrix |
@@ -233,6 +233,20 @@ def test_constructor_TwoVec(self): |
233 | 233 | # x axis should equal normalized x vector |
234 | 234 | nt.assert_almost_equal(R.R[:, 0], v3 / np.linalg.norm(v3), 5) |
235 | 235 |
|
| 236 | + def test_conversion(self): |
| 237 | + R = SO3.AngleAxis(0.7, [1,2,3]) |
| 238 | + q = UnitQuaternion([11,7,3,-6]) |
| 239 | + |
| 240 | + R_from_q = SO3(q.R) |
| 241 | + q_from_R = UnitQuaternion(R) |
| 242 | + |
| 243 | + nt.assert_array_almost_equal(R.UnitQuaternion(), q_from_R) |
| 244 | + nt.assert_array_almost_equal(R.UnitQuaternion().SO3(), R) |
| 245 | + |
| 246 | + nt.assert_array_almost_equal(q.SO3(), R_from_q) |
| 247 | + nt.assert_array_almost_equal(q.SO3().UnitQuaternion(), q) |
| 248 | + |
| 249 | + |
236 | 250 | def test_shape(self): |
237 | 251 | a = SO3() |
238 | 252 | self.assertEqual(a._A.shape, a.shape) |
|
0 commit comments