-
Notifications
You must be signed in to change notification settings - Fork 248
/
Copy pathtake_item_out_of_drawer.py
47 lines (40 loc) · 1.93 KB
/
take_item_out_of_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
41
42
43
44
45
46
47
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 TakeItemOutOfDrawer(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])
self.register_success_conditions(
[DetectedCondition(self._item, ProximitySensor('success'))])
def init_episode(self, index: int) -> List[str]:
option = self._options[index]
anchor = self._anchors[index]
self._waypoint1.set_position(anchor.get_position())
_, _, z_target = anchor.get_position()
x, y, z = self._item.get_position()
self._item.set_position([x, y, z_target])
return ['take item out of the %s drawer' % option,
'open the %s drawer and take the cube out' % option,
'grasp the %s handle on the drawers, pull the drawer open, and'
' take out what you find inside' % option,
'clear out the %s drawer' % option,
'make sure the %s drawer is empty' % option,
'lift the block out of the %s drawer' % option,
'using the handle, open the %s drawer, and remove any items #'
'inside' % 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]