-
Notifications
You must be signed in to change notification settings - Fork 240
/
meat_off_grill.py
40 lines (34 loc) · 1.53 KB
/
meat_off_grill.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
from pyrep.objects.dummy import Dummy
from pyrep.objects.proximity_sensor import ProximitySensor
from pyrep.objects.shape import Shape
from rlbench.backend.conditions import NothingGrasped, DetectedCondition
from rlbench.backend.task import Task
MEAT = ['chicken', 'steak']
class MeatOffGrill(Task):
def init_task(self) -> None:
self._steak = Shape('steak')
self._chicken = Shape('chicken')
self._success_sensor = ProximitySensor('success')
self.register_graspable_objects([self._chicken, self._steak])
self._w1 = Dummy('waypoint1')
self._w1z= self._w1.get_position()[2]
def init_episode(self, index: int) -> List[str]:
conditions = [NothingGrasped(self.robot.gripper)]
if index == 0:
x, y, _ = self._chicken.get_position()
self._w1.set_position([x, y, self._w1z])
conditions.append(
DetectedCondition(self._chicken, self._success_sensor))
else:
x, y, _ = self._steak.get_position()
self._w1.set_position([x, y, self._w1z])
conditions.append(
DetectedCondition(self._steak, self._success_sensor))
self.register_success_conditions(conditions)
return ['take the %s off the grill' % MEAT[index],
'pick up the %s and place it next to the grill' % MEAT[index],
'remove the %s from the grill and set it down to the side'
% MEAT[index]]
def variation_count(self) -> int:
return 2