Skip to content

Commit c7af1e0

Browse files
committed
Update example
1 parent d0e69b5 commit c7af1e0

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

examples/readme.py

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,30 @@
55
print(robot)
66
T = robot.fkine(robot.qz)
77
print(T)
8-
qt = rtb.trajectory.jtraj(robot.qz, robot.qr, 50)
9-
robot.plot(qt.q, movie="panda1.gif")
108

119
# IK
1210
from spatialmath import SE3
1311

14-
T = SE3(0.1, 0.2, 0.5) * SE3.OA([0, 1, 0], [0, 0, -1])
15-
q, *_ = robot.ikunc(T)
16-
print(q)
17-
print(robot.fkine(q))
12+
T = SE3(0.8, 0.2, 0.1) * SE3.OA([0, 1, 0], [0, 0, -1])
13+
q_pickup, *_ = robot.ikine(T) # solve IK, ignore additional outputs
14+
print(q_pickup)# display joint angles
15+
print(robot.fkine(q_pickup)) # FK shows that desired end-effector pose was achieved
16+
1817

19-
# URDF model
18+
qt = rtb.trajectory.jtraj(robot.qz, q_pickup, 50)
19+
robot.plot(qt.q, movie="panda1.gif")
20+
21+
# URDF + Swift version
22+
dt = 0.050 # simulation timestep in seconds
2023
robot = rtb.models.URDF.Panda()
2124
print(robot)
22-
env = rtb.backend.Swift()
23-
env.launch()
24-
env.add(robot)
25-
for qk in qt.q:
26-
robot.q = qk
27-
env.step()
25+
env = rtb.backend.Swift() # instantiate 3D browser-based visualizer
26+
env.launch("chrome") # activate it
27+
env.add(robot) # add robot to the 3D scene
28+
env.start_recording("panda2", 1 / dt)
29+
for qk in qt.q: # for each joint configuration on trajectory
30+
robot.q = qk # update the robot state
31+
env.step() # update visualization
32+
env.stop_recording()
33+
34+
# ffmpeg -i panda2.webm -vf "scale=iw*.5:ih*.5" panda2.gif

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