-
Notifications
You must be signed in to change notification settings - Fork 80
Expand file tree
/
Copy pathsphere_cage_example_capt.py
More file actions
87 lines (69 loc) · 2.2 KB
/
sphere_cage_example_capt.py
File metadata and controls
87 lines (69 loc) · 2.2 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import numpy as np
from viser import transforms as tf
import os
from viser_utils import (
setup_viser_with_robot,
add_point_cloud,
add_spheres,
add_trajectory,
)
from pathlib import Path
import vamp
import vamp.pointcloud
from fire import Fire
# Starting configuration
a = [0.0, -0.785, 0.0, -2.356, 0.0, 1.571, 0.785]
# Goal configuration
b = [2.35, 1.0, 0.0, -0.8, 0, 2.5, 0.785]
# Problem specification: a list of sphere centers
problem = [
[0.55, 0, 0.25],
[0.35, 0.35, 0.25],
[0, 0.55, 0.25],
[-0.55, 0, 0.25],
[-0.35, -0.35, 0.25],
[0, -0.55, 0.25],
[0.35, -0.35, 0.25],
[0.35, 0.35, 0.8],
[0, 0.55, 0.8],
[-0.35, 0.35, 0.8],
[-0.55, 0, 0.8],
[-0.35, -0.35, 0.8],
[0, -0.55, 0.8],
[0.35, -0.35, 0.8],
]
def main(
obstacle_radius: float = 0.2,
points_per_sphere: int = 1000,
attachment_radius: float = 0.07,
attachment_offset: float = 0.02,
planner: str = "rrtc",
**kwargs,
):
point_cloud = np.vstack(
[
vamp.pointcloud.sphere_sample_surface(center, obstacle_radius, points_per_sphere, 0.0)
for center in problem
]
).astype(np.float32)
point_cloud_colors = np.random.randint(100, 200, (point_cloud.shape[0], 3))
(vamp_module, planner_func, plan_settings,
simp_settings) = (vamp.configure_robot_and_planner_with_kwargs("panda", planner, **kwargs))
robot_dir = Path(__file__).parents[1] / "resources" / "panda"
server, robot = setup_viser_with_robot(robot_dir, "panda_spherized.urdf")
robot.update_cfg(a)
e = vamp.Environment()
r_min, r_max = vamp_module.min_max_radii()
e.add_pointcloud(point_cloud.tolist(), r_min, r_max, 0.01)
_problem_point_cloud_handles = add_point_cloud(server, point_cloud, point_cloud_colors)
# Plan and display
sampler = vamp_module.halton()
result = planner_func(a, b, e, plan_settings, sampler)
simple = vamp_module.simplify(result.path, e, simp_settings, sampler)
simple.path.interpolate_to_resolution(vamp.panda.resolution())
add_trajectory(server, simple.path.numpy(), robot, [], [[]])
# display
while True:
continue
if __name__ == "__main__":
Fire(main)