forked from stepjam/RLBench
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathput_knife_on_chopping_board.py
35 lines (30 loc) · 1.44 KB
/
put_knife_on_chopping_board.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
from typing import List, Tuple
from pyrep.objects.shape import Shape
from pyrep.objects.proximity_sensor import ProximitySensor
from rlbench.backend.task import Task
from rlbench.backend.spawn_boundary import SpawnBoundary
from rlbench.backend.conditions import ConditionSet, DetectedCondition, \
NothingGrasped
class PutKnifeOnChoppingBoard(Task):
def init_task(self) -> None:
knife = Shape('knife')
success = ProximitySensor('success')
self.knife_block = Shape('knife_block')
self.chopping_board = Shape('chopping_board')
self.register_graspable_objects([knife])
cond_set = ConditionSet([DetectedCondition(knife, success),
NothingGrasped(self.robot.gripper)],
order_matters=True)
self.register_success_conditions([cond_set])
self.boundary = SpawnBoundary([Shape('boundary')])
def init_episode(self, index: int) -> List[str]:
self.boundary.clear()
self.boundary.sample(self.knife_block)
return ['put the knife on the chopping board',
'slide the knife out of the knife block and put it down on the '
'chopping board',
'place the knife on the chopping board',
'pick up the knife and leave it on the chopping board',
'move the knife from the holder to the chopping board']
def variation_count(self) -> int:
return 1