-
Notifications
You must be signed in to change notification settings - Fork 23
/
pybullet_robot_interface.py
executable file
·55 lines (45 loc) · 1.33 KB
/
pybullet_robot_interface.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env python
import time
import numpy as np
import pybullet
import skrobot
def main():
# initialize robot
robot = skrobot.models.Kuka()
interface = skrobot.interfaces.PybulletRobotInterface(robot)
pybullet.resetDebugVisualizerCamera(
cameraDistance=1.5,
cameraYaw=45,
cameraPitch=-45,
cameraTargetPosition=(0, 0, 0.5),
)
print('==> Initialized Kuka Robot on PyBullet')
for _ in range(100):
pybullet.stepSimulation()
time.sleep(3)
# reset pose
print('==> Moving to Reset Pose')
robot.reset_manip_pose()
interface.angle_vector(robot.angle_vector(), realtime_simulation=True)
interface.wait_interpolation()
time.sleep(3)
# ik
print('==> Solving Inverse Kinematics')
target_coords = skrobot.coordinates.Coordinates(
pos=[0.5, 0, 0]
).rotate(np.pi / 2.0, 'y', 'local')
skrobot.interfaces.pybullet.draw(target_coords)
robot.inverse_kinematics(
target_coords,
link_list=robot.rarm.link_list,
move_target=robot.rarm_end_coords,
rotation_axis=True,
stop=1000,
)
interface.angle_vector(robot.angle_vector(), realtime_simulation=True)
interface.wait_interpolation()
# wait
while pybullet.isConnected():
time.sleep(0.01)
if __name__ == '__main__':
main()