8000 Major update · suddrey-qut/spatialmath-python@43dfeb7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 43dfeb7

Browse files
committed
Major update
moved tests to own folders and update __main__ code in each module major polish of twist code and doco, 2d and 3d minor polish of other code and doco lgtm pragmas added
1 parent 45daa55 commit 43dfeb7

33 files changed

+1421
-841
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Spatial Maths for Python
22

3-
[![PyPI pyversions](https://img.shields.io/pypi/pyversions/spatialmath-python.svg)](https://pypi.python.org/pypi/spatialmath-python/)
3+
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/roboticstoolbox-python.svg)
44
[![pypi downloads](https://img.shields.io/pypi/dw/spatialmath-python)
55
![PyPI version](https://badge.fury.io/py/spatialmath-python.svg)](https://badge.fury.io/py/spatialmath-python)
66
[![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/petercorke/spatialmath-python.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/petercorke/spatialmath-python/context:python)

docs/source/2d_pose_twist.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
se(2) twist
22
^^^^^^^^^^^
33

4-
.. automodule:: spatialmath.Twist2
4+
.. autoclass:: spatialmath.Twist2
55
:members:
66
:undoc-members:
77
:show-inheritance:
88
:inherited-members:
9-
:special-members: __mul__, __truediv__, __add__, __sub__, __eq__, __ne__, __pow__, __init__
10-
:exclude-members: count, copy, index, sort, remove
9+
:special-members: __mul__, __truediv__, __add__, __sub__, __eq__, __ne__, __pow__, __init__
10+
:exclude-members: count, copy, index, sort, remove, arghandler, binop, unop, __add__,

docs/source/3d_pose_twist.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
se(3) twist
22
^^^^^^^^^^^
33

4-
.. automodule:: spatialmath.Twist3
4+
.. autoclass:: spatialmath.Twist3
55
:members:
66
:undoc-members:
77
:show-inheritance:
88
:inherited-members:
9-
:special-members: __mul__, __truediv__, __add__, __sub__, __eq__, __ne__, __pow__, __init__
10-
:exclude-members: count, copy, index, sort, remove
9+
:special-members: __mul__, __truediv__, __add__, __sub__, __eq__, __ne__, __pow__, __init__
10+
:exclude-members: count, copy, index, sort, remove, arghandler, binop, unop, __add__,

docs/source/classes-2d.rst

Lines changed: 0 additions & 41 deletions
16
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,3 @@
1-
2D-space
2-
========
3-
4-
Pose in 2D
5-
----------
6-
7-
SE(2) matrix
8-
^^^^^^^^^^^^
9-
10-
.. autclass:: spatialmath.pose2d.SE2
11-
:members:
12-
:undoc-members:
13-
:show-inheritance:
14-
:inherited-members:
15-
:special-members: __mul__, __truediv__, __add__, __sub__, __eq__, __ne__, __pow__, __init__
-
:exclude-members: count, copy, index, sort, remove
17-
18-
se(2) twist
19-
^^^^^^^^^^^
20-
21-
.. automodule:: spatialmath.Twist2
22-
:members:
23-
:undoc-members:
24-
:show-inheritance:
25-
:inherited-members:
26-
:special-members: __mul__, __truediv__, __add__, __sub__, __eq__, __ne__, __pow__, __init__
27-
:exclude-members: count, copy, index, sort, remove
28-
29-
Orientation in 2D
30-
-----------------
31-
32-
SO(2) matrix
33-
^^^^^^^^^^^^
34-
35-
.. autclass:: spatialmath.pose2d.SO2
36-
:members:
37-
:undoc-members:
38-
:show-inheritance:
39-
:inherited-members:
40-
:special-members: __mul__, __truediv__, __add__, __sub__, __eq__, __ne__, __pow__, __init__
41-
:exclude-members: count, copy, index, sort, remove
421

432

443

docs/source/classes-3d.rst

Lines changed: 0 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1 @@
1-
3D-space
2-
========
31

4-
Pose in 3D
5-
----------
6-
7-
SE(3) matrix
8-
^^^^^^^^^^^^
9-
10-
.. autoclass:: spatialmath.pose3d.SE3
11-
:members:
12-
:undoc-members:
13-
:show-inheritance:
14-
:inherited-members:
15-
:special-members: __mul__, __truediv__, __add__, __sub__, __eq__, __ne__, __pow__, __init__
16-
:exclude-members: count, copy, index, sort, remove, arghandler, binop, unop
17-
18-
se(3) twist
19-
^^^^^^^^^^^
20-
21-
.. automodule:: spatialmath.Twist3
22-
:members:
23-
:undoc-members:
24-
:show-inheritance:
25-
:inherited-members:
26-
:special-members: __mul__, __truediv__, __add__, __sub__, __eq__, __ne__, __pow__, __init__
27-
:exclude-members: count, copy, index, sort, remove
28-
29-
Orientation in 3D
30-
-----------------
31-
32-
SO(3) matrix
33-
^^^^^^^^^^^^
34-
35-
.. autoclass:: spatialmath.pose3d.SO3
36-
:members:
37-
:undoc-members:
38-
:show-inheritance:
39-
:inherited-members:
40-
:special-members: __mul__, __truediv__, __add__, __sub__, __eq__, __ne__, __pow__, __init__
41-
:exclude-members: count, copy, index, sort, remove
42-
43-
Unit quaternion
44-
^^^^^^^^^^^^^^^
45-
46-
.. autoclass:: spatialmath.quaternion.UnitQuaternion
47-
:members:
48-
:undoc-members:
49-
:show-inheritance:
50-
:inherited-members:
51-
:special-members: __mul__, __truediv__, __add__, __sub__, __eq__, __ne__, __pow__, __init__
52-
:exclude-members: count, copy, index, sort, remove
53-
54-
55-
6D spatial vectors
56-
------------------
57-
58-
.. automodule:: spatialmath.spatialvector
59-
:members:
60-
:undoc-members:
61-
:show-inheritance:
62-
:inherited-members:
63-
:special-members: __mul__, __truediv__, __add__, __sub__, __eq__, __ne__, __pow__, __init__
64-
:exclude-members: count, copy, index, sort, remove
65-
66-
67-
General quaternions
68-
-------------------
69-
70-
.. autoclass:: spatialmath.quaternion.Quaternion
71-
:members:
72-
:undoc-members:
73-
:show-inheritance:
74-
:inherited-members:
75-
:special-members: __mul__, __truediv__, __add__, __sub__, __eq__, __ne__, __pow__, __init__
76-
:exclude-members: count, copy, index, sort, remove
77-
78-
Geometry
79-
--------
80-
81-
.. automodule:: spatialmath.geom3d
82-
:members:
83-
:undoc-members:
84-
:show-inheritance:
85-
:inherited-members:
86-
:special-members: __mul__, __rmul__, __eq__, __ne__, __init__, __or__, __xor__

spatialmath/base/argcheck.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ def isvector(v, dim=None):
397397
return False
398398

399399

400-
def getunit(v, unit):
400+
def getunit(v, unit='rad'):
401401
"""
402402
Convert value according to angular units
403403
@@ -528,4 +528,4 @@ def islistof(value, what, n=None):
528528
if __name__ == '__main__':
529529
import pathlib
530530

531-
exec(open(pathlib.Path(__file__).parent.absolute() / "test_argcheck.py").read()) # pylint: disable=exec-used
531+
exec(open(pathlib.Path(__file__).parent.absolute() / "test" / "test_argcheck.py").read()) # pylint: disable=exec-used

spatialmath/base/quaternions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -814,4 +814,4 @@ def qprint(q, delim=('<', '>'), fmt='{: .4f}', file=sys.stdout):
814814
if __name__ == '__main__': # pragma: no cover
815815
import pathlib
816816

817-
exec(open(pathlib.Path(__file__).parent.absolute() / "test_quaternions.py").read()) # pylint: disable=exec-used
817+
exec(open(pathlib.Path(__file__).parent.absolute() / "test" / "test_quaternions.py").read()) # pylint: disable=exec-used

spatialmath/base/transforms2d.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,21 @@ def trexp2(S, theta=None, check=True):
392392
else:
393393
raise ValueError(" First argument must be SO(2), 1-vector, SE(2) or 3-vector")
394394

395+
def adjoint2(T):
396+
# http://ethaneade.com/lie.pdf
397+
Z = np.zeros((2,2), dtype=T.dtype)
398+
if T.shape == (3,3):
399+
# SO(2) adjoint
400+
return np.identity(2)
401+
elif T.shape == (3,3):
402+
# SE(2) adjoint
403+
(R, t) = base.tr2rt(T)
404+
return np.block([
405+
[R, np.c_[t[1], -t[0]].T],
406+
[0, 0, 1]
407+
])
408+
else:
409+
raise ValueError('bad argument')
395410

396411
def trinterp2(start, end, s=None):
397412
"""
@@ -719,4 +734,4 @@ def tranimate2(T, **kwargs):
719734
# trplot2( transl2(4, 3)@trot2(math.pi/3), color='green', frame='c')
720735
# plt.grid(True)
721736

722-
exec(open(pathlib.Path(__file__).parent.absolute() / "test_transforms2d.py").read()) # pylint: disable=exec-used
737+
exec(open(pathlib.Path(__file__).parent.absolute() / "test" / "test_transforms2d.py").read()) # pylint: disable=exec-used

spatialmath/base/transforms3d.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1534,6 +1534,25 @@ def tr2jac(T, samebody=False):
15341534
R = base.t2r(T)
15351535
return np.block([[R.T, Z], [Z, R.T]])
15361536

1537+
def adjoint(T):
1538+
# http://ethaneade.com/lie.pdf
1539+
Z = np.zeros((3, 3), dtype=T.dtype)
1540+
if T.shape == (3,3):
1541+
# SO(3) adjoint
1542+
return np.block([
1543+
[R, Z],
1544+
[Z, R]
1545+
])
1546+
elif T.shape == (4,4):
1547+
# SE(3) adjoint
1548+
(R, t) = base.tr2rt(T)
1549+
return np.block([
1550+
[R, base.skew(t) @ R],
1551+
[Z, R]
1552+
])
1553+
else:
1554+
raise ValueError('bad argument')
1555+
15371556

15381557
def trprint(T, orient='rpy/zyx', label=None, file=sys.stdout, fmt='{:8.2g}', degsym=True, unit='deg'):
15391558
"""
@@ -1837,6 +1856,6 @@ def tranimate(T, **kwargs):
18371856
a,b,c = base.sym.symbol('a,b,c')
18381857
T = rpy2r(a,b,c)
18391858

1840-
exec(open(pathlib.Path(__file__).parent.absolute() / "test_transforms3d.py").read()) # pylint: disable=exec-used
1859+
exec(open(pathlib.Path(__file__).parent.absolute() / "test" / "test_transforms3d.py").read()) # pylint: disable=exec-used
18411860

18421861

spatialmath/base/transformsNd.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -424,18 +424,19 @@ def skew(v):
424424
"""
425425
v = base.getvector(v, None, 'sequence')
426426
if len(v) == 1:
427-
s = np.array([
428-
[0, -v[0]],
429-
[v[0], 0]])
427+
return np.array([
428+
[ 0, -v[0] ],
429+
[ v[0], 0] ]
430+
)
430431
elif len(v) == 3:
431-
s = np.array([
432-
[0, -v[2], v[1]],
433-
[v[2], 0, -v[0]],
434-
[-v[1], v[0], 0]])
432+
return np.array([
433+
[ 0, -v[2], v[1] ],
434+
[ v[2], 0, -v[0] ],
435+
[-v[1], v[ BE5C 0], 0] ]
436+
)
435437
else:
436438
raise ValueError("argument must be a 1- or 3-vector")
437439

438-
return s
439440

440441
# ---------------------------------------------------------------------------------------#
441442

@@ -745,4 +746,4 @@ def homtrans(T, p):
745746
if __name__ == '__main__': # pragma: no cover
746747
import pathlib
747748

748-
exec(open(pathlib.Path(__file__).parent.absolute() / "test_transformsNd.py").read()) # pylint: disable=exec-used
749+
exec(open(pathlib.Path(__file__).parent.absolute() / "test" / "test_transformsNd.py").read()) # pylint: disable=exec-used

spatialmath/pose2d.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,4 +493,4 @@ def Twist2(self):
493493

494494
import pathlib
495495

496-
exec(open(pathlib.Path(__file__).parent.absolute() / "test_pose2d.py").read()) # pylint: disable=exec-used
496+
exec(open(pathlib.Path(__file__).parent.absolute() / "test" / "test_pose2d.py").read()) # pylint: disable=exec-used

0 commit comments

Comments
 (0)
0