-
Notifications
You must be signed in to change notification settings - Fork 241
/
reach_and_drag.py
32 lines (27 loc) · 1.26 KB
/
reach_and_drag.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
from typing import List
from rlbench.backend.task import Task
from rlbench.const import colors
from rlbench.backend.conditions import NothingGrasped, DetectedCondition
from pyrep.objects.shape import Shape
from pyrep.objects.proximity_sensor import ProximitySensor
class ReachAndDrag(Task):
def init_task(self) -> None:
self.stick = Shape('stick')
self.register_graspable_objects([self.stick])
self.cube = Shape('cube')
self.target = Shape('target0')
def init_episode(self, index: int) -> List[str]:
self.register_success_conditions([
DetectedCondition(self.cube, ProximitySensor('success0'))])
color_name, color_rgb = colors[index]
self.target.set_color(color_rgb)
return ['use the stick to drag the cube onto the %s target'
% color_name,
'pick up the stick and use it to push or pull the cube '
'onto the %s target' % color_name,
'drag the block towards the %s square on the table top'
% color_name,
'grasping the stick by one end, pick it up and use the its '
'other end to move the block onto the %s target' % color_name]
def variation_count(self) -> int:
return len(colors)