-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathpybullet_robot_interface.py
More file actions
executable file
·69 lines (59 loc) · 1.8 KB
/
Copy pathpybullet_robot_interface.py
File metadata and controls
executable file
·69 lines (59 loc) · 1.8 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env python
import argparse
import sys
import time
import numpy as np
import skrobot
from skrobot.interfaces._pybullet import _check_available
def main():
if _check_available() is False:
sys.exit(0)
import pybullet
parser = argparse.ArgumentParser(
description='Scikit-robot pybullet interface example.')
parser.add_argument(
'--no-interactive',
action='store_true',
help="Run in non-interactive mode (do not wait for user input)"
)
args = parser.parse_args()
# 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.arm.link_list,
move_target=robot.arm_end_coords,
rotation_mask=True,
stop=1000,
)
interface.angle_vector(robot.angle_vector(), realtime_simulation=True)
interface.wait_interpolation()
if not args.no_interactive:
# wait
while pybullet.isConnected():
time.sleep(0.01)
if __name__ == '__main__':
main()