Skip to content

Commit 4e75c0c

Browse files
committed
Things working again
1 parent af83dbe commit 4e75c0c

File tree

6 files changed

+78
-56
lines changed

6 files changed

+78
-56
lines changed

examples/swifty.py

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,40 @@
99
import numpy as np
1010
import qpsolvers as qp
1111

12-
# Launch the simulator Swift
13-
env = rtb.backend.Swift()
14-
env.launch()
12+
# # Launch the simulator Swift
13+
# env = rtb.backend.Swift()
14+
# env.launch()
1515

1616
# Create a Panda robot object
17-
panda = rtb.models.Panda()
17+
panda = rtb.models.ETS.Panda()
1818

19-
# Set joint angles to ready configuration
20-
panda.q = panda.qr
19+
print(panda)
20+
print(panda.base_link)
21+
print(panda.ee_links)
22+
23+
path, n = panda.get_path(panda.base_link, panda.ee_links[0])
24+
25+
q1 = np.array([1.4, 0.2, 1.8, 0.7, 0.1, 3.1, 2.9])
26+
panda.q = q1
27+
28+
print(panda.fkine())
29+
30+
for link in path:
31+
print(link.name)
32+
33+
# print(panda.get_path(panda.base_link, panda.ee_links[0])[0])
34+
35+
# print(panda.links[5].A(0))
36+
37+
# # Set joint angles to ready configuration
38+
# panda.q = panda.qr
2139

2240
# Add the Panda to the simulator
23-
env.add(panda)
41+
# env.add(panda)
2442

2543

26-
while 1:
27-
pass
44+
# while 1:
45+
# pass
2846

2947

3048

roboticstoolbox/backend/urdf/urdf.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"""
66

77
import numpy as np
8+
from spatialmath import base
89
import roboticstoolbox as rtb
910
import copy
1011
import os
@@ -1611,10 +1612,9 @@ def __init__(self, name, links, joints=None,
16111612
# why arent the other things validated
16121613
try:
16131614
self._validate_transmissions()
1614-
except:
1615+
except BaseException:
16151616
pass
16161617

1617-
16181618
self.name = name
16191619
self.other_xml = other_xml
16201620

@@ -1624,20 +1624,20 @@ def __init__(self, name, links, joints=None,
16241624
self._transmissions = list(transmissions)
16251625
# self._materials = list(materials)
16261626

1627-
# check for duplicate names
1628-
1627+
# check for duplicate names
16291628
if len(self._links) > len(set([x.name for x in self._links])):
16301629
raise ValueError('Duplicate link names')
16311630
if len(self._joints) > len(set([x.name for x in self._joints])):
16321631
raise ValueError('Duplicate joint names')
1633-
if len(self._transmissions) > len(set([x.name for x in self._transmissions])):
1634-
raise ValueError('Duplicate transmission names')
1632+
if len(self._transmissions) > len(
1633+
set([x.name for x in self._transmissions])):
1634+
raise ValueError('Duplicate transmission names')
16351635

16361636
elinks = []
16371637
elinkdict = {}
1638-
jointdict = {}
1638+
# jointdict = {}
16391639

1640-
## build the list of links in URDF file order
1640+
# build the list of links in URDF file order
16411641
for link in self._links:
16421642
elink = rtb.ELink(name=link.name)
16431643
elinks.append(elink)
@@ -1660,7 +1660,7 @@ def __init__(self, name, links, joints=None,
16601660
except AttributeError: # pragma nocover
16611661
pass
16621662

1663-
## connect the links using joint info
1663+
# connect the links using joint info
16641664
for joint in self._joints:
16651665
# get references to joint's parent and child
16661666
childlink = elinkdict[joint.child]
@@ -1671,12 +1671,14 @@ def __init__(self, name, links, joints=None,
16711671

16721672
# constant part of link transform
16731673
trans = sm.SE3(joint.origin).t
1674-
# TODO, find where reverse is used and change it to [::-1] or do that here
1675-
rot = joint.rpy[::-1]
1674+
# TODO, find where reverse is used and change
1675+
# it to [::-1] or do that here
1676+
rot = joint.rpy
16761677
childlink._ets = rtb.ETS.SE3(trans, rot)
1678+
childlink._init_Ts()
16771679

16781680
# variable part of link transform
1679-
if joint.joint_type in ('revolute', 'continuous'): # pragma nocover
1681+
if joint.joint_type in ('revolute', 'continuous'): # pragma nocover # noqa
16801682
if joint.axis[0] == 1:
16811683
var = rtb.ETS.rx()
16821684
elif joint.axis[0] == -1:
@@ -1826,8 +1828,6 @@ def __init__(self, name, links, joints=None,
18261828
# )
18271829
# elinks_dict[elinks[-1].name] = elinks[-1]
18281830

1829-
1830-
18311831
# elinks.append(base_link)
18321832
# self.elinks = elinks
18331833

roboticstoolbox/models/ETS/Panda.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ def __init__(self):
118118
color = ""
119119
else:
120120
color = "<<blue>>"
121-
table.row(color + link.name,
122-
link.parent.name if link.parent is not None else "-",
121+
table.row(
122+
color + link.name,
123+
link.parent.name if link.parent is not None else "-",
123124
link.ets * link.v if link.v is not None else link.ets)
124-
table.print()
125+
table.print()

roboticstoolbox/robot/ELink.py

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
@author: Jesse Haviland
44
"""
55

6-
import numpy as np
6+
# import numpy as np
77
from spatialmath import SE3
8-
from spatialmath.base.argcheck import getvector, verifymatrix, isscalar
8+
# from spatialmath.base.argcheck import getvector, verifymatrix, isscalar
99
import roboticstoolbox as rp
1010
from roboticstoolbox.robot.ETS import ETS
1111
from roboticstoolbox.robot.Link import Link
@@ -83,23 +83,9 @@ def __init__(
8383
self._joint_name = None
8484
self._jindex = None
8585

86-
# Number of transforms in the ETS excluding the joint variable
87-
self._M = len(self._ets)
88-
89-
# Initialise joints
90-
if isinstance(ets, ETS):
91-
self._Ts = SE3()
92-
for i in range(self.M):
93-
if ets[i].isjoint:
94-
raise ValueError('The transforms in ets must be constant')
95-
96-
if not isinstance(ets[i].T(), SE3):
97-
self._Ts *= SE3(ets[i].T())
98-
else:
99-
self._Ts *= ets[i].T()
100-
101-
elif isinstance(ets, SE3):
102-
self._Ts = ets
86+
# Initialise the static transform representing the constant
87+
# component of the ETS
88+
self._init_Ts()
10389

10490
# Check the variable joint
10591
if v is None:
@@ -116,9 +102,28 @@ def __init__(
116102

117103
self._v = v
118104

105+
def _init_Ts(self):
106+
# Number of transforms in the ETS excluding the joint variable
107+
self._M = len(self._ets)
108+
109+
# Initialise joints
110+
if isinstance(self._ets, ETS):
111+
self._Ts = SE3()
112+
for i in range(self.M):
113+
if self._ets[i].isjoint:
114+
raise ValueError('The transforms in ets must be constant')
115+
116+
if not isinstance(self._ets[i].T(), SE3):
117+
self._Ts *= SE3(self._ets[i].T())
118+
else:
119+
self._Ts *= self._ets[i].T()
120+
121+
elif isinstance(self._ets, SE3):
122+
self._Ts = self._ets
123+
119124
def __repr__(self):
120125
name = self.__class__.__name__
121-
s = "ets=" + str(self.ets)
126+
s = "ets=" + str(self.ets())
122127
if self.parent is not None:
123128
s += ", parent=" + str(self.parent.name)
124129
args = [s] + super()._params()
@@ -131,12 +136,12 @@ def __str__(self):
131136
:return: Pretty print of the robot link
132137
:rtype: str
133138
"""
134-
name = self.__class__.__name__
139+
# name = self.__class__.__name__
135140
if self.parent is None:
136141
parent = ""
137142
else:
138143
parent = f" [{self.parent.name}]"
139-
return f"name[{self.name}({parent}): {self.ets}] "
144+
return f"name[{self.name}({parent}): {self.ets()}] "
140145

141146
@property
142147
def v(self):
@@ -190,7 +195,6 @@ def child(self):
190195
def M(self):
191196
return self._M
192197

193-
194198
@collision.setter
195199
def collision(self, coll):
196200
new_coll = []
@@ -272,7 +276,6 @@ def A(self, q=None, fast=False):
272276
else:
273277
return self.Ts
274278

275-
@property
276279
def ets(self):
277280
if self.v is None:
278281
return self._ets

roboticstoolbox/robot/ERobot.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ def __init__(
113113
# no, update children of this link's parent
114114
link._parent._child.append(link)
115115

116+
for link in elinks:
116117
# is this a leaf node?
117118
if ee_links is None and len(link.child) == 0:
118119
# no children, must be an end-effector
@@ -288,7 +289,7 @@ def to_dict(self):
288289
'collision': []
289290
}
290291

291-
for et in link.ets:
292+
for et in link.ets():
292293
li['axis'].append(et.axis)
293294
li['eta'].append(et.eta)
294295

@@ -618,8 +619,7 @@ def fkine(self, q=None, from_link=None, to_link=None):
618619
if to_link is None:
619620
to_link = self.ee_links[0]
620621

621-
if q is None:
622-
q = self.q
622+
q = self._getq(q)
623623

624624
path, _ = self.get_path(from_link, to_link)
625625
j = 0
@@ -1083,7 +1083,7 @@ def __str__(self):
10831083
Column("parent", headalign="^"),
10841084
Column("joint", headalign="^"),
10851085
Column("ETS", headalign="^", colalign=">"),
1086-
border="thin", color=self._color)
1086+
border="thin")
10871087
for k, link in enumerate(self):
10881088
color = "" if link.isjoint else "<<blue>>"
10891089
ee = "@" if link in self.ee_links else ""

tests/test_ERobot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,11 @@ def test_fkine_all(self):
133133
r2 = pm.fkine_all()
134134

135135
for i in range(7):
136-
nt.assert_array_almost_equal(p.ets[i]._fk.A, r2[i].A)
136+
nt.assert_array_almost_equal(p._ets[i]._fk.A, r2[i].A)
137137

138138
p.fkine_all(q)
139139
for i in range(7):
140-
nt.assert_array_almost_equal(p.ets[i]._fk.A, r2[i].A)
140+
nt.assert_array_almost_equal(p._ets[i]._fk.A, r2[i].A)
141141

142142
def test_jacob0(self):
143143
panda = rp.models.ETS.Panda()

0 commit comments

Comments
 (0)