-
Notifications
You must be signed in to change notification settings - Fork 248
/
Copy pathput_knife_in_knife_block.py
43 lines (37 loc) · 1.72 KB
/
put_knife_in_knife_block.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
from typing import List, Tuple
from pyrep.objects.dummy import Dummy
from pyrep.objects.proximity_sensor import ProximitySensor
from pyrep.objects.shape import Shape
from rlbench.backend.conditions import ConditionSet, DetectedCondition, \
NothingGrasped
from rlbench.backend.spawn_boundary import SpawnBoundary
from rlbench.backend.task import Task
class PutKnifeInKnifeBlock(Task):
def init_task(self) -> None:
knife = Shape('knife')
self._knife_base = Dummy('knife_base')
self._knife_block = Shape('knife_block')
self._chopping_board = Shape('chopping_board')
self._boundary = SpawnBoundary([Shape('boundary')])
self._knife_bound = SpawnBoundary([Shape('knife_boundary')])
self.register_graspable_objects([knife])
self.register_success_conditions([
ConditionSet([
DetectedCondition(knife, ProximitySensor('success')),
NothingGrasped(self.robot.gripper)],
order_matters=True)])
def init_episode(self, index: int) -> List[str]:
self._knife_bound.clear()
self._boundary.clear()
self._boundary.sample(self._knife_block)
self._boundary.sample(self._chopping_board)
self._knife_bound.sample(self._knife_base)
return ['put the knife in the knife block',
'slide the knife into its slot in the knife block',
'place the knife in the knife block',
'pick up the knife and leave it in its holder',
'move the knife from the chopping board to the holder']
def variation_count(self) -> int:
return 1
def base_rotation_bounds(self) -> Tuple[List[float], List[float]]:
return [0, 0, 0], [0, 0, 0]