8
8
from spatialmath import base as tr
9
9
from spatialmath import super_pose as sp
10
10
11
+ """
12
+ Classes to abstract 3D pose and orientation using matrices in SO(3) and SE(3)
13
+
14
+ To use::
15
+
16
+ from spatialmath.pose3d import *
17
+ T = SE3.Rx(0.3)
18
+
19
+ import spatialmath as sm
20
+ T = sm.SE3.Rx(0.3)
21
+
22
+
23
+ .. inheritance-diagram:: spatialmath.pose3d
24
+ :top-classes: collections.UserList
25
+ :parts: 1
26
+ """
27
+
11
28
# ============================== SO3 =====================================#
12
29
13
30
@@ -18,7 +35,9 @@ class SO3(sp.SMPose):
18
35
This subclass represents rotations in 3D space. Internally it is a 3x3 orthogonal matrix belonging
19
36
to the group SO(3).
20
37
21
- .. inheritance-diagram::
38
+ .. inheritance-diagram:: spatialmath.pose3d.SO3
39
+ :top-classes: collections.UserList
40
+ :parts: 1
22
41
"""
23
42
24
43
def __init__ (self , arg = None , * , check = True ):
@@ -186,6 +205,36 @@ def rpy(self, unit='deg', order='zyx'):
186
205
else :
187
206
return np .array ([tr .tr2rpy (x , unit = unit , order = order ) for x in self .A ]).T
188
207
208
+ def angvec (self , unit = 'rad' ):
209
+ r"""
210
+ SO(3) or SE(3) as angle and rotation vector
211
+
212
+ :param unit: angular units: 'rad' [default], or 'deg'
213
+ :type unit: str
214
+ :param check: check that rotation matrix is valid
215
+ :type check: bool
216
+ :return: :math:`(\theta, {\bf v})`
217
+ :rtype: float, numpy.ndarray, shape=(3,)
218
+
219
+ ``q.angvec()`` is a tuple :math:`(\theta, v)` containing the rotation
220
+ angle and a rotation axis which is equivalent to the rotation of
221
+ the unit quaternion ``q``.
222
+
223
+ By default the angle is in radians but can be changed setting `unit='deg'`.
224
+
225
+ Notes:
226
+
227
+ - If the input is SE(3) the translation component is ignored.
228
+
229
+ Example::
230
+
231
+ >>> UnitQuaternion.Rz(0.3).angvec()
232
+ (0.3, array([0., 0., 1.]))
233
+
234
+ :seealso: :func:`~spatialmath.quaternion.AngVec`, :func:`~angvec2r`
235
+ """
236
+ return tr .tr2angvec (self .R , unit = unit )
237
+
189
238
def Ad (self ):
190
239
"""
191
240
Adjoint of SO(3)
@@ -486,6 +535,16 @@ def Exp(cls, S, check=True, so3=True):
486
535
487
536
488
537
class SE3 (SO3 ):
538
+ """
539
+ SE(3) subclass
540
+
541
+ This subclass represents rigid-body motion in 3D space. Internally it is a 4x4 homogeneous transformation matrix belonging
542
+ to the group SE(3).
543
+
544
+ .. inheritance-diagram:: spatialmath.pose3d.SE3
545
+ :top-classes: collections.UserList
546
+ :parts: 1
547
+ """
489
548
490
549
def __init__ (self , x = None , y = None , z = None , * , check = True ):
491
550
"""
@@ -914,6 +973,5 @@ def Delta(cls, d):
914
973
if __name__ == '__main__' : # pragma: no cover
915
974
916
975
import pathlib
917
- import os .path
918
976
919
977
exec (open (os .path .join (pathlib .Path (__file__ ).parent .absolute (), "test_pose3d.py" )).read ())
0 commit comments