Skip to content

Commit ce4baf6

Browse files
committed
Merge branch 'future' of github.com:petercorke/robotics-toolbox-python into future
# Conflicts: # roboticstoolbox/models/DH/AL5D.py
2 parents 6f7b30e + 2ce1ce9 commit ce4baf6

File tree

8 files changed

+82
-51
lines changed

8 files changed

+82
-51
lines changed

.github/workflows/future_testing.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
strategy:
1212
matrix:
1313
os: [windows-latest, ubuntu-latest, macos-latest]
14-
python-version: [3.7, 3.8, 3.9]
14+
python-version: [3.7, 3.8, 3.9, '3.10']
1515

1616
steps:
1717
- name: Set up Python ${{ matrix.python-version }}
@@ -28,18 +28,21 @@ jobs:
2828
- name: Checkout Swift
2929
uses: actions/checkout@v2
3030
with:
31+
ref: future
3132
repository: jhavl/swift
3233
path: swift
3334

3435
- name: Checkout Spatialmath
3536
uses: actions/checkout@v2
3637
with:
38+
ref: future
3739
repository: petercorke/spatialmath-python
3840
path: sm
3941

4042
- name: Checkout Spatialgeometry
4143
uses: actions/checkout@v2
4244
with:
45+
ref: future
4346
repository: jhavl/spatialgeometry
4447
path: sg
4548

roboticstoolbox/core/linalg.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,9 @@ extern "C"
150150
else
151151
{
152152
// a = np.pi / 2 * (np.diag(R) + 1);
153-
e[3] = M_PI_2 * (R[0] + 1);
154-
e[4] = M_PI_2 * (R[4] + 1);
155-
e[5] = M_PI_2 * (R[8] + 1);
153+
e[3] = PI_2 * (R[0] + 1);
154+
e[4] = PI_2 * (R[4] + 1);
155+
e[5] = PI_2 * (R[8] + 1);
156156
}
157157
}
158158
else

roboticstoolbox/core/linalg.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ extern "C"
1515
{
1616
#endif /* __cplusplus */
1717

18+
#define PI_2 1.57079632679489661923132169163975144
19+
1820
#define Matrix4dc Eigen::Matrix4d
1921
#define Matrix4dr Eigen::Matrix<double, 4, 4, Eigen::RowMajor>
2022

roboticstoolbox/models/DH/AL5D.py

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from roboticstoolbox import DHRobot, RevoluteMDH
77
from spatialmath import SE3
88

9+
910
class AL5D(DHRobot):
1011
"""
1112
Class that models a Lynxmotion AL5D manipulator
@@ -41,48 +42,50 @@ def __init__(self, symbolic=False):
4142

4243
if symbolic:
4344
import spatialmath.base.symbolic as sym
45+
4446
zero = sym.zero()
4547
pi = sym.pi()
4648
else:
4749
from math import pi
50+
4851
zero = 0.0
4952

5053
# robot length values (metres)
5154
a = [0, 0.002, 0.14679, 0.17751]
5255
d = [-0.06858, 0, 0, 0]
5356

54-
alpha = [pi, pi/2, pi, pi]
55-
offset = [pi/2, pi, -0.0427, -0.0427-pi/2]
57+
alpha = [pi, pi / 2, pi, pi]
58+
offset = [pi / 2, pi, -0.0427, -0.0427 - pi / 2]
5659

5760
# mass data as measured
5861
mass = [0.187, 0.044, 0.207, 0.081]
5962

6063
# center of mass as calculated through CAD model
6164
center_of_mass = [
62-
[0.01724, -0.00389, 0.00468],
63-
[0.07084, 0.00000, 0.00190],
64-
[0.05615, -0.00251, -0.00080],
65-
[0.04318, 0.00735, -0.00523],
66-
]
65+
[0.01724, -0.00389, 0.00468],
66+
[0.07084, 0.00000, 0.00190],
67+
[0.05615, -0.00251, -0.00080],
68+
[0.04318, 0.00735, -0.00523],
69+
]
6770

6871
# moments of inertia are practically zero
6972
moments_of_inertia = [
70-
[0, 0, 0, 0, 0, 0],
71-
[0, 0, 0, 0, 0, 0],
72-
[0, 0, 0, 0, 0, 0],
73-
[0, 0, 0, 0, 0, 0]
74-
]
73+
[0, 0, 0, 0, 0, 0],
74+
[0, 0, 0, 0, 0, 0],
75+
[0, 0, 0, 0, 0, 0],
76+
[0, 0, 0, 0, 0, 0],
77+
]
7578

7679
joint_limits = [
77-
[-pi/2, pi/2],
78-
[-pi/2, pi/2],
79-
[-pi/2, pi/2],
80-
[-pi/2, pi/2],
81-
]
80+
[-pi / 2, pi / 2],
81+
[-pi / 2, pi / 2],
82+
[-pi / 2, pi / 2],
83+
[-pi / 2, pi / 2],
84+
]
8285

8386
links = []
8487

85-
for j in range(4):
88+
for j in range(3):
8689
link = RevoluteMDH(
8790
d=d[j],
8891
a=a[j],
@@ -92,27 +95,28 @@ def __init__(self, symbolic=False):
9295
I=moments_of_inertia[j],
9396
G=1,
9497
B=0,
95-
Tc=[0,0],
96-
qlim=joint_limits[j]
98+
Tc=[0, 0],
99+
qlim=joint_limits[j],
97100
)
98101
links.append(link)
99-
100-
tool=SE3(0.07719,0,0)
101-
102+
103+
tool = SE3(0.07719, 0, 0)
104+
102105
super().__init__(
103106
links,
104107
name="AL5D",
105108
manufacturer="Lynxmotion",
106-
keywords=('dynamics', 'symbolic'),
109+
keywords=("dynamics", "symbolic"),
107110
symbolic=symbolic,
108-
tool=tool
111+
tool=tool,
109112
)
110-
113+
111114
# zero angles
112-
self.addconfiguration("home", np.array([pi/2, pi/2, pi/2, pi/2]))
115+
self.addconfiguration("home", np.array([pi / 2, pi / 2, pi / 2, pi / 2]))
116+
113117

114-
if __name__ == '__main__': # pragma nocover
118+
if __name__ == "__main__": # pragma nocover
115119

116120
al5d = AL5D(symbolic=False)
117121
print(al5d)
118-
print(al5d.dyntable())
122+
# print(al5d.dyntable())

roboticstoolbox/robot/DHRobot.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,6 +1235,9 @@ def jacob0_analytical(self, q, representation=None, T=None):
12351235
# compute Jacobian in world frame
12361236
J0 = self.jacob0(q, T)
12371237

1238+
if representation is None:
1239+
return J0
1240+
12381241
# compute rotational transform if analytical Jacobian required
12391242

12401243
if representation == "rpy/xyz":
@@ -1385,10 +1388,10 @@ def rne(self, q, qd=None, qdd=None, gravity=None, fext=None, base_wrench=False):
13851388
"""
13861389

13871390
if base_wrench:
1388-
return self.rne_python(q, qd, qdd,
1389-
gravity=gravity, fext=fext,
1390-
base_wrench=base_wrench)
1391-
1391+
return self.rne_python(
1392+
q, qd, qdd, gravity=gravity, fext=fext, base_wrench=base_wrench
1393+
)
1394+
13921395
trajn = 1
13931396

13941397
try:

roboticstoolbox/robot/ETS.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"""
77

88
from collections import UserList
9-
from functools import lru_cache, cached_property
109
from numpy import (
1110
pi,
1211
where,
@@ -44,9 +43,19 @@
4443
from spatialmath.base import getvector
4544
from spatialmath import SE3
4645
from typing import Union, overload, List, Set
46+
from sys import version_info
4747

4848
ArrayLike = Union[list, ndarray, tuple, set]
4949

50+
py_ver = version_info
51+
52+
if version_info >= (3, 9):
53+
from functools import cached_property
54+
55+
c_property = cached_property
56+
else:
57+
c_property = property
58+
5059

5160
class BaseETS(UserList):
5261
def __init__(self, *args):
@@ -238,7 +247,7 @@ def jindex_set(self) -> Set[int]: #
238247
"""
239248
return set([self[j].jindex for j in self.joint_idx()]) # type: ignore
240249

241-
@cached_property
250+
@c_property
242251
def jindices(self) -> ndarray:
243252
"""
244253
Get an array of joint indices
@@ -255,7 +264,7 @@ def jindices(self) -> ndarray:
255264
"""
256265
return array([self[j].jindex for j in self.joints()]) # type: ignore
257266

258-
@cached_property
267+
@c_property
259268
def qlim(self):
260269
r"""
261270
Joint limits

tests/test_DHRobot.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ def test_isspherical(self):
390390
def test_payload(self):
391391
panda = rp.models.DH.Panda()
392392
nt.assert_array_almost_equal(panda.r[:, 6], np.zeros(3))
393-
nt.assert_array_almost_equal(panda.links[6].m, 0)
393+
# nt.assert_array_almost_equal(panda.links[6].m, 0)
394394

395395
m = 6
396396
p = [1, 2, 3]
@@ -1140,8 +1140,8 @@ def test_inertia_x(self):
11401140
[0.0000, -0.9652, -0.0000, 0.1941, 0.0000, 0.5791],
11411141
]
11421142

1143-
M0 = puma.inertia_x(q, representation="rpy/xyz")
1144-
M1 = puma.inertia_x(np.c_[q, q].T, representation="rpy/xyz")
1143+
M0 = puma.inertia_x(q, representation=None)
1144+
M1 = puma.inertia_x(np.c_[q, q].T, representation=None)
11451145

11461146
nt.assert_array_almost_equal(M0, Mr, decimal=4)
11471147
nt.assert_array_almost_equal(M1[0, :, :], Mr, decimal=4)
@@ -1252,7 +1252,7 @@ def test_jacob_dot(self):
12521252

12531253
from roboticstoolbox.tools import hessian_numerical
12541254

1255-
j0 = puma.jacob_dot(q, qd)
1255+
j0 = puma.jacob0_dot(q, qd)
12561256

12571257
H = hessian_numerical(lambda q: puma.jacob0(q), q)
12581258
Jd = np.zeros((6, puma.n))

tests/test_jacob.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,28 +42,36 @@ def test_jacob_analytical_eul(self):
4242
rep = "eul"
4343
q = self.q
4444
Ja = numjac(lambda q: tr2x(self.robot.fkine(q).A, representation=rep), q)
45-
nt.assert_array_almost_equal(self.robot.jacob0_analytic(q, analytic=rep), Ja)
45+
nt.assert_array_almost_equal(
46+
self.robot.jacob0_analytical(q, representation=rep), Ja
47+
)
4648

4749
def test_jacob_analytical_rpy_xyz(self):
4850
rep = "rpy/xyz"
4951
q = self.q
5052
Ja = numjac(lambda q: tr2x(self.robot.fkine(q).A, representation=rep), q)
51-
nt.assert_array_almost_equal(self.robot.jacob0_analytic(q, analytic=rep), Ja)
53+
nt.assert_array_almost_equal(
54+
self.robot.jacob0_analytical(q, representation=rep), Ja
55+
)
5256

5357
def test_jacob_analytical_rpy_zyx(self):
5458
rep = "rpy/zyx"
5559
q = self.q
5660
Ja = numjac(lambda q: tr2x(self.robot.fkine(q).A, representation=rep), q)
57-
nt.assert_array_almost_equal(self.robot.jacob0_analytic(q, analytic=rep), Ja)
61+
nt.assert_array_almost_equal(
62+
self.robot.jacob0_analytical(q, representation=rep), Ja
63+
)
5864

5965
def test_jacob_analytical_exp(self):
6066
rep = "exp"
6167
q = self.q
6268
Ja = numjac(lambda q: tr2x(self.robot.fkine(q).A, representation=rep), q)
63-
nt.assert_array_almost_equal(self.robot.jacob0_analytic(q, analytic=rep), Ja)
69+
nt.assert_array_almost_equal(
70+
self.robot.jacob0_analytical(q, representation=rep), Ja
71+
)
6472

6573
def test_jacob_dot(self):
66-
j0 = self.robot.jacob_dot(self.q, self.qd)
74+
j0 = self.robot.jacob0_dot(self.q, self.qd)
6775

6876
H = numhess(lambda q: self.robot.jacob0(q), self.q)
6977
Jd = np.zeros((6, self.robot.n))
@@ -74,9 +82,11 @@ def test_jacob_dot(self):
7482

7583
def test_jacob_dot_analytical_eul(self):
7684
rep = "eul"
77-
j0 = self.robot.jacob_dot(self.q, self.qd, analytical=rep)
85+
j0 = self.robot.jacob0_dot(self.q, self.qd, representation=rep)
7886

79-
H = numhess(lambda q: self.robot.jacob0_analytic(q, analytic=rep), self.q)
87+
H = numhess(
88+
lambda q: self.robot.jacob0_analytical(q, representation=rep), self.q
89+
)
8090
Jd = np.zeros((6, self.robot.n))
8191
for i in range(self.robot.n):
8292
Jd += H[i, :, :] * self.qd[i]

0 commit comments

Comments
 (0)