forked from NVlabs/curobo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpose_sequence_example.py
79 lines (71 loc) · 2.85 KB
/
pose_sequence_example.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#
# Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
# property and proprietary rights in and to this material, related
# documentation and any modifications thereto. Any use, reproduction,
# disclosure or distribution of this material and related documentation
# without an express license agreement from NVIDIA CORPORATION or
# its affiliates is strictly prohibited.
#
" This example moves the robot through a sequence of poses and dumps an animated usd."
# CuRobo
from curobo.types.math import Pose
from curobo.types.robot import JointState
from curobo.wrap.reacher.motion_gen import MotionGen, MotionGenConfig, MotionGenPlanConfig
def pose_sequence_ur5e():
# load ur5e motion gen:
world_file = "collision_table.yml"
robot_file = "ur5e.yml"
motion_gen_config = MotionGenConfig.load_from_robot_config(
robot_file,
world_file,
interpolation_dt=(1 / 30),
)
motion_gen = MotionGen(motion_gen_config)
motion_gen.warmup(parallel_finetune=True)
retract_cfg = motion_gen.get_retract_config()
start_state = JointState.from_position(retract_cfg.view(1, -1))
# poses for ur5e:
home_pose = [-0.431, 0.172, 0.348, 0, 1, 0, 0]
pose_1 = [0.157, -0.443, 0.427, 0, 1, 0, 0]
pose_2 = [0.126, -0.443, 0.729, 0, 0, 1, 0]
pose_3 = [-0.449, 0.339, 0.414, -0.681, -0.000, 0.000, 0.732]
pose_4 = [-0.449, 0.339, 0.414, 0.288, 0.651, -0.626, -0.320]
pose_5 = [-0.218, 0.508, 0.670, 0.529, 0.169, 0.254, 0.792]
pose_6 = [-0.865, 0.001, 0.411, 0.286, 0.648, -0.628, -0.321]
pose_list = [home_pose, pose_1, pose_2, pose_3, pose_4, pose_5, pose_6, home_pose]
trajectory = start_state
motion_time = 0
for i, pose in enumerate(pose_list):
goal_pose = Pose.from_list(pose, q_xyzw=False)
start_state = trajectory[-1].unsqueeze(0).clone()
start_state.velocity[:] = 0.0
start_state.acceleration[:] = 0.0
result = motion_gen.plan_single(
start_state.clone(),
goal_pose,
plan_config=MotionGenPlanConfig(parallel_finetune=True, max_attempts=1),
)
if result.success.item():
plan = result.get_interpolated_plan()
trajectory = trajectory.stack(plan.clone())
motion_time += result.motion_time
else:
print(i, "fail", result.status)
print("Motion Time (s):", motion_time)
# CuRobo
from curobo.util.usd_helper import UsdHelper
UsdHelper.write_trajectory_animation(
robot_file,
motion_gen.world_model,
start_state,
trajectory,
save_path="ur5e_sequence.usd",
base_frame="/grid_world_1",
flatten_usd=True,
visualize_robot_spheres=False,
dt=1.0 / 30.0,
)
if __name__ == "__main__":
pose_sequence_ur5e()