-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsweeping_piles.py
More file actions
48 lines (40 loc) · 1.73 KB
/
Copy pathsweeping_piles.py
File metadata and controls
48 lines (40 loc) · 1.73 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
"""Sweeping task."""
import numpy as np
from cliport.tasks import primitives
from cliport.tasks.grippers import Spatula
from cliport.tasks.task import Task
from cliport.utils import utils
class SweepingPiles(Task):
"""Sweeping task."""
def __init__(self):
super().__init__()
self.ee = Spatula
self.max_steps = 20
self.primitive = primitives.push
self.lang_template = "push the pile of blocks into the green square"
self.task_completed_desc = "done sweeping."
def reset(self, env):
super().reset(env)
# Add goal zone.
zone_size = (0.12, 0.12, 0)
zone_pose = self.get_random_pose(env, zone_size)
env.add_object('zone/zone.urdf', zone_pose, 'fixed')
# Add pile of small blocks.
obj_pts = {}
obj_ids = []
for _ in range(50):
rx = self.bounds[0, 0] + 0.15 + np.random.rand() * 0.2
ry = self.bounds[1, 0] + 0.4 + np.random.rand() * 0.2
xyz = (rx, ry, 0.01)
theta = np.random.rand() * 2 * np.pi
xyzw = utils.eulerXYZ_to_quatXYZW((0, 0, theta))
obj_id = env.add_object('block/small.urdf', (xyz, xyzw))
obj_pts[obj_id] = self.get_box_object_points(obj_id)
obj_ids.append((obj_id, (0, None)))
# Goal: all small blocks must be in zone.
# goal = Goal(list(obj_pts.keys()), [0] * len(obj_pts), [zone_pose])
# metric = Metric('zone', (obj_pts, [(zone_pose, zone_size)]), 1.)
# self.goals.append((goal, metric))
self.goals.append((obj_ids, np.ones((50, 1)), [zone_pose], True, False,
'zone', (obj_pts, [(zone_pose, zone_size)]), 1))
self.lang_goals.append(self.lang_template)