-
Notifications
You must be signed in to change notification settings - Fork 240
/
close_drawer.py
36 lines (29 loc) · 1.3 KB
/
close_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, Tuple
import numpy as np
from pyrep.objects.dummy import Dummy
from pyrep.objects.joint import Joint
from rlbench.backend.conditions import JointCondition
from rlbench.backend.task import Task
class CloseDrawer(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._waypoint0 = Dummy('waypoint0')
def init_episode(self, index: int) -> List[str]:
option = self._options[index]
self._joints[index].set_joint_position(0.1)
self.register_success_conditions(
[JointCondition(self._joints[index], 0.06)])
x, y, z = self._waypoint0.get_position()
_, _, target_z = self._anchors[index].get_position()
self._waypoint0.set_position([x, y, target_z])
return ['close %s drawer' % (option,),
'shut the %s drawer' % (option,),
'slide the %s drawer shut' % (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]