forked from compas-teaching/COMPAS-II-FS2021
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path08_plan_pick_trajectory.py
34 lines (24 loc) · 977 Bytes
/
08_plan_pick_trajectory.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
import os
import helpers
from compas_fab.backends import RosClient
from compas_fab.robots import PlanningScene
import compas
HERE = os.path.dirname(__file__)
MAX_STEP = 0.01
# Load assembly
filename = os.path.join(HERE, 'assembly.json')
assembly = compas.json_load(filename)
with RosClient() as client:
robot = client.load_robot()
scene = PlanningScene(robot)
# Prepare scene for planning
helpers.attach_vacuum_gripper(scene)
helpers.add_static_objects(scene)
trajectory = robot.plan_cartesian_motion(assembly.pick_t0cf_frames(),
start_configuration=assembly.attributes['home_config'],
options=dict(max_step=MAX_STEP))
if trajectory and trajectory.fraction < 1.0:
raise Exception('Incomplete trajectory. Fraction={}'.format(trajectory.fraction))
assembly.pick_trajectory = trajectory
# Save assembly
compas.json_dump(assembly, filename)