-
Notifications
You must be signed in to change notification settings - Fork 249
/
Copy pathput_item_in_drawer.py
40 lines (33 loc) · 1.54 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
37
38
39
40
from typing import List, Tuple
import numpy as np
from pyrep.objects.dummy import Dummy
from pyrep.objects.joint import Joint
from pyrep.objects.proximity_sensor import ProximitySensor
from pyrep.objects.shape import Shape
from rlbench.backend.conditions import DetectedCondition
from rlbench.backend.task import Task
class PutItemInDrawer(Task):
def init_task(self) -> None:
self._options = ['bottom', 'middle', 'top']
self._anchors = [Dummy('waypoint_anchor_%s' % opt)
for opt in self._options]
self._joints = [Joint('drawer_joint_%s' % opt)
for opt in self._options]
self._waypoint1 = Dummy('waypoint1')
self._item = Shape('item')
self.register_graspable_objects([self._item])
def init_episode(self, index) -> List[str]:
option = self._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
def base_rotation_bounds(self) -> Tuple[List[float], List[float]]:
return [0, 0, - np.pi / 8], [0, 0, np.pi / 8]