Skip to content

Commit 770f12a

Browse files
committed
Fixed example
1 parent a856e18 commit 770f12a

File tree

4 files changed

+42
-18
lines changed

4 files changed

+42
-18
lines changed

examples/baur.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,17 @@
3232
n = 7
3333

3434
# Set the desired end-effector pose
35-
Tep = panda.fkine() * sm.SE3(0.3, 0.2, 0.3)
35+
Tep = panda.fkine(panda.q) * sm.SE3(0.3, 0.2, 0.3)
3636

3737
arrived = False
3838

3939
while not arrived:
4040

4141
# The pose of the Panda's end-effector
42-
Te = panda.fkine()
42+
Te = panda.fkine(panda.q)
4343

4444
# The manipulator Jacobian in the end-effecotr frame
45-
Je = panda.jacobe()
45+
Je = panda.jacobe(panda.q)
4646

4747
# Calulate the required end-effector spatial velocity for the robot
4848
# to approach the goal. Gain is set to 1.0
@@ -52,7 +52,7 @@
5252
Y = 0.01
5353

5454
# The manipulability Jacobian
55-
Jm = panda.jacobm()
55+
Jm = panda.jacobm(panda.q)
5656

5757
# The minimum angle (in radians) in which the joint is allowed to approach
5858
# to its limit

examples/mmc.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@
3131
n = 7
3232

3333
# Set the desired end-effector pose
34-
Tep = panda.fkine() * sm.SE3(0.3, 0.2, 0.3)
34+
Tep = panda.fkine(panda.q) * sm.SE3(0.3, 0.2, 0.3)
3535

3636
arrived = False
3737

3838
while not arrived:
3939

4040
# The pose of the Panda's end-effector
41-
Te = panda.fkine()
41+
Te = panda.fkine(panda.q)
4242

4343
# Transform from the end-effector to desired pose
4444
eTep = Te.inv() * Tep
@@ -63,7 +63,7 @@
6363
Q[n:, n:] = (1 / e) * np.eye(6)
6464

6565
# The equality contraints
66-
Aeq = np.c_[panda.jacobe(), np.eye(6)]
66+
Aeq = np.c_[panda.jacobe(panda.q), np.eye(6)]
6767
beq = v.reshape((6,))
6868

6969
# The inequality constraints for joint limit avoidance

examples/swifty.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -209,11 +209,16 @@ def rand_v():
209209

210210
x = []
211211
y = []
212+
rands = 100
213+
v = np.zeros((rands, 6))
214+
215+
for i in range(rands):
216+
v[i, :] = rand_v()
212217

213218
for i in range(10000000):
214219

215220
q = rand_q()
216-
v = rand_v()
221+
# v = rand_v()
217222

218223
J = r.jacob0(q)
219224
Jt = J[:3, :]
@@ -222,15 +227,16 @@ def rand_v():
222227

223228
q_n = [10000, 0]
224229
q_m = [10000, 0]
230+
q_mn = 0
225231

226232
# cond = np.linalg.cond(J[:3, :])
227233
m = r.manipulability(J=J, axes='trans')
228234
# infn = np.linalg.norm(Jt, 2)
229235
psi = (np.cbrt(np.linalg.det(Jt @ np.transpose(Jt)))) / \
230236
(np.trace(Jt @ np.transpose(Jt)) / 3)
231237

232-
for j in range(1000):
233-
qd = np.linalg.pinv(J) @ v
238+
for j in range(rands):
239+
qd = np.linalg.pinv(J) @ v[j, :]
234240

235241
if np.max(qd) > q_m[1]:
236242
q_m[1] = np.max(qd)
@@ -243,12 +249,16 @@ def rand_v():
243249
elif np.linalg.norm(qd) < q_n[0]:
244250
q_n[0] = np.linalg.norm(qd)
245251

252+
q_mn += np.linalg.norm(qd)
253+
254+
q_mn /= rands
255+
246256
# # ax.plot(m, np.log10(cond), 'o', color='black')
247257
# ax.plot(m, infn, 'o', color='black')
248258
# # ax.plot(1, 0.002, 'o', color='black')
249259

250-
x.append(psi)
251-
y.append(np.log10(q_m[1]))
260+
x.append(m)
261+
y.append(np.log10(q_n[0]))
252262
# y.append(psi)
253263

254264
# ax.plot(m, np.log10(q_m[1]), 'o', color='black')

roboticstoolbox/robot/ERobot.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def __init__(
9797
if len(tool) > 0:
9898
elinks.append(ELink(tool, parent=elinks[-1], name="ee"))
9999
elif isinstance(elinks, list):
100-
# were passed a list of ELinks
100+
# we're passed a list of ELinks
101101

102102
# check all the incoming ELink objects
103103
n = 0
@@ -1183,14 +1183,26 @@ def _getlink(self, link, default=None):
11831183
if link is None:
11841184
link = default
11851185

1186+
# print(link)
1187+
1188+
# for link in self.links:
1189+
# print(link)
1190+
11861191
if isinstance(link, str):
1187-
if link not in self.link_dict:
1188-
raise ValueError(f'no link named {link}')
1189-
return self.link_dict[link]
1192+
if link in self.link_dict:
1193+
return self.link_dict[link]
1194+
1195+
raise ValueError(f'no link named {link}')
1196+
11901197
elif isinstance(link, ELink):
1191-
if link not in self.links:
1198+
if link in self.links:
1199+
return link
1200+
else:
1201+
for gripper in self.grippers:
1202+
if link in gripper.links:
1203+
return link
1204+
11921205
raise ValueError('link not in robot links')
1193-
return link
11941206
else:
11951207
raise TypeError('unknown argument')
11961208

@@ -1614,6 +1626,8 @@ def jacobm(self, q=None, J=None, H=None, endlink=None, startlink=None):
16141626
else:
16151627
verifymatrix(H, (6, n, n))
16161628

1629+
print(q)
1630+
16171631
manipulability = self.manipulability(
16181632
q, J=J, startlink=startlink, endlink=endlink)
16191633
b = np.linalg.inv(J @ np.transpose(J))

0 commit comments

Comments
 (0)