Skip to content

Commit ddf0261

Browse files
committed
Fix icra example
1 parent ee5442c commit ddf0261

File tree

1 file changed

+33
-20
lines changed

1 file changed

+33
-20
lines changed

roboticstoolbox/examples/icra2021.py

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# This is the code for the examples in the paper published at ICRA2021.
66
#
77

8-
import swift.Swift
8+
from swift import Swift
99
import spatialmath.base.symbolic as sym
1010
from roboticstoolbox import ETS as ET
1111
from roboticstoolbox import *
@@ -17,19 +17,18 @@
1717
# # III.SPATIAL MATHEMATICS
1818

1919
from spatialmath.base import *
20-
T = transl(0.5, 0.0, 0.0) @ rpy2tr(0.1, 0.2,
21-
0.3, order='xyz') @ trotx(-90, 'deg')
20+
21+
T = transl(0.5, 0.0, 0.0) @ rpy2tr(0.1, 0.2, 0.3, order="xyz") @ trotx(-90, "deg")
2222
print(T)
2323

24-
T = SE3(0.5, 0.0, 0.0) * SE3.RPY([0.1, 0.2, 0.3],
25-
order='xyz') * SE3.Rx(-90, unit='deg')
24+
T = SE3(0.5, 0.0, 0.0) * SE3.RPY([0.1, 0.2, 0.3], order="xyz") * SE3.Rx(-90, unit="deg")
2625
print(T)
2726

2827
T.eul()
2928

3029
T.R
3130

32-
T.plot(color='red', label='2')
31+
T.plot(color="red", label="2")
3332

3433
UnitQuaternion.Rx(0.3)
3534
UnitQuaternion.AngVec(0.3, [1, 0, 0])
@@ -47,11 +46,14 @@
4746
d4 = 0.380
4847
d6 = 0.065
4948

50-
robot = DHRobot([
51-
RevoluteDH(d=d1, a=a1, alpha=-pi / 2),
52-
RevoluteDH(a=a2),
53-
RevoluteDH(alpha=pi / 2),
54-
], name="my IRB140")
49+
robot = DHRobot(
50+
[
51+
RevoluteDH(d=d1, a=a1, alpha=-pi / 2),
52+
RevoluteDH(a=a2),
53+
RevoluteDH(alpha=pi / 2),
54+
],
55+
name="my IRB140",
56+
)
5557

5658
print(robot)
5759

@@ -73,9 +75,20 @@
7375
l5 = 0.0837
7476
l6 = 0.4318
7577

76-
e = ET.tz(l1) * ET.rz() * ET.ty(l2) * ET.ry() \
77-
* ET.tz(l3) * ET.tx(l4) * ET.ty(l5) * ET.ry() \
78-
* ET.tz(l6) * ET.rz() * ET.ry() * ET.rz()
78+
e = (
79+
ET.tz(l1)
80+
* ET.rz()
81+
* ET.ty(l2)
82+
* ET.ry()
83+
* ET.tz(l3)
84+
* ET.tx(l4)
85+
* ET.ty(l5)
86+
* ET.ry()
87+
* ET.tz(l6)
88+
* ET.rz()
89+
* ET.ry()
90+
* ET.rz()
91+
)
7992

8093
robot = ERobot(e)
8194
print(robot)
@@ -99,7 +112,7 @@
99112

100113
# ## C. Symbolic manipulation
101114

102-
phi, theta, psi = sym.symbol('φ, ϴ, ψ')
115+
phi, theta, psi = sym.symbol("φ, ϴ, ψ")
103116
rpy2r(phi, theta, psi)
104117

105118
q = sym.symbol("q_:6") # q = (q_1, q_2, ... q_5)
@@ -145,10 +158,10 @@
145158

146159

147160
obstacle = Box([1, 1, 1], base=SE3(1, 0, 0))
148-
iscollision = panda.collided(obstacle) # boolean
161+
iscollision = panda.collided(panda.q, obstacle) # boolean
149162
iscollision = panda.links[0].collided(obstacle)
150163

151-
d, p1, p2 = panda.closest_point(obstacle)
164+
d, p1, p2 = panda.closest_point(panda.q, obstacle)
152165
print(d, p1, p2)
153166
d, p1, p2 = panda.links[0].closest_point(obstacle)
154167
print(d, p1, p2)
@@ -158,10 +171,10 @@
158171
panda.plot(panda.qr, block=False)
159172

160173
backend = Swift()
161-
backend.launch() # create graphical world
174+
backend.launch() # create graphical world
162175
backend.add(panda) # add robot to the world
163-
panda.q = panda.qr # update the robot
164-
backend.step() # display the world
176+
panda.q = panda.qr # update the robot
177+
backend.step() # display the world
165178

166179

167180
#

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy