forked from stepjam/RLBench
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathput_item_in_drawer.py
36 lines (30 loc) · 1.35 KB
/
put_item_in_drawer.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
from typing import List
from pyrep.objects.dummy import Dummy
from pyrep.objects.joint import Joint
from pyrep.objects.shape import Shape
from pyrep.objects.proximity_sensor import ProximitySensor
from rlbench.backend.task import Task
from rlbench.backend.conditions import DetectedCondition
OPTIONS = ['bottom', 'middle', 'top']
class PutItemInDrawer(Task):
def init_task(self) -> None:
self.anchors = [Dummy('waypoint_anchor_%s' % opt)
for opt in OPTIONS]
self.joints = [Joint('drawer_joint_%s' % opt)
for opt in OPTIONS]
self.waypoint1 = Dummy('waypoint1')
self.item = Shape('item')
self.register_graspable_objects([self.item])
def init_episode(self, index) -> List[str]:
option = OPTIONS[index]
anchor = self.anchors[index]
self.waypoint1.set_position(anchor.get_position())
success_sensor = ProximitySensor('success_' + option)
self.register_success_conditions(
[DetectedCondition(self.item, success_sensor)])
return ['put item in %s drawer' % option,
'put the block away in the %s drawer' % option,
'open the %s drawer and place the block inside of it' % option,
'leave the block in the %s drawer' % option]
def variation_count(self) -> int:
return 3