Skip to content

Commit cb61c87

Browse files
committed
new ik example
1 parent 114038e commit cb61c87

File tree

1 file changed

+24
-0
lines changed
  • roboticstoolbox/examples

1 file changed

+24
-0
lines changed

roboticstoolbox/examples/ik.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import swift # instantiate 3D browser-based visualizer
2+
import roboticstoolbox as rtb
3+
from spatialmath import SE3
4+
import numpy as np
5+
6+
env = swift.Swift()
7+
env.launch(realtime=True) # activate it
8+
9+
robot = rtb.models.Panda()
10+
robot.q = robot.qr
11+
12+
T = SE3(0.5, 0.2, 0.1) * SE3.OA([0, 1, 0], [0, 0, -1])
13+
sol = robot.ikine_LM(T) # solve IK
14+
q_pickup = sol.q
15+
qt = rtb.jtraj(robot.qr, q_pickup, 50)
16+
17+
env.add(robot) # add robot to the 3D scene
18+
for qk in qt.q: # for each joint configuration on trajectory
19+
robot.q = qk # update the robot state
20+
# robot.q = robot.qr
21+
env.step(0.05) # update visualization
22+
23+
24+
env.hold()

0 commit comments

Comments
 (0)