@@ -1072,6 +1072,15 @@ def _holding_classifier(state: State, objects: Sequence[Object]) -> bool:
10721072 return False
10731073 return state .get (obj , "held" ) > 0.5
10741074
1075+ def _open_classifier (state : State , objects : Sequence [Object ]) -> bool :
1076+ obj = objects [0 ]
1077+ return False
1078+
1079+ def _not_open_classifier (state : State , objects : Sequence [Object ]) -> bool :
1080+ obj = objects [0 ]
1081+ if not obj .is_instance (_movable_object_type ):
1082+ return True
1083+ return not _open_classifier (state , objects )
10751084
10761085def _not_holding_classifier (state : State , objects : Sequence [Object ]) -> bool :
10771086 _ , obj = objects
@@ -1395,6 +1404,10 @@ def _get_sweeping_surface_for_container(container: Object,
13951404 return None
13961405
13971406
1407+ _Open = Predicate ("Open" , [_movable_object_type ],
1408+ _open_classifier )
1409+ _NotOpen = Predicate ("NotOpen" , [_movable_object_type ],
1410+ _not_open_classifier )
13981411_NEq = Predicate ("NEq" , [_base_object_type , _base_object_type ],
13991412 _neq_classifier )
14001413_On = Predicate ("On" , [_movable_object_type , _base_object_type ],
@@ -1448,7 +1461,7 @@ def _get_sweeping_surface_for_container(container: Object,
14481461 _HandEmpty , _Holding , _NotHolding , _InHandView , _InView , _Reachable ,
14491462 _Blocking , _NotBlocked , _ContainerReadyForSweeping , _IsPlaceable ,
14501463 _IsNotPlaceable , _IsSweeper , _HasFlatTopSurface , _RobotReadyForSweeping ,
1451- _IsSemanticallyGreaterThan
1464+ _IsSemanticallyGreaterThan , _Open , _NotOpen
14521465}
14531466_NONPERCEPT_PREDICATES : Set [Predicate ] = set ()
14541467
@@ -1685,6 +1698,44 @@ def _create_operators() -> Iterator[STRIPSOperator]:
16851698 ignore_effs = {_InHandView , _Reachable , _RobotReadyForSweeping , _Blocking }
16861699 yield STRIPSOperator ("DragToBlockObject" , parameters , preconds , add_effs ,
16871700 del_effs , ignore_effs )
1701+
1702+ # DragToOpenObject
1703+ robot = Variable ("?robot" , _robot_type )
1704+ obj = Variable ("?obj" , _movable_object_type )
1705+ parameters = [robot , obj ]
1706+ preconds = {
1707+ LiftedAtom (_Holding , [robot , obj ]),
1708+ }
1709+ add_effs = {
1710+ LiftedAtom (_HandEmpty , [robot ]),
1711+ LiftedAtom (_NotHolding , [robot , obj ]),
1712+ LiftedAtom (_Open , [obj ]),
1713+ }
1714+ del_effs = {
1715+ LiftedAtom (_Holding , [robot , obj ]),
1716+ }
1717+ ignore_effs = {_InHandView , _Reachable , _RobotReadyForSweeping , _Blocking }
1718+ yield STRIPSOperator ("DragToOpenObject" , parameters , preconds , add_effs ,
1719+ del_effs , ignore_effs )
1720+
1721+ # DragToCloseObject
1722+ robot = Variable ("?robot" , _robot_type )
1723+ obj = Variable ("?obj" , _movable_object_type )
1724+ parameters = [robot , obj ]
1725+ preconds = {
1726+ LiftedAtom (_Holding , [robot , obj ]),
1727+ }
1728+ add_effs = {
1729+ LiftedAtom (_HandEmpty , [robot ]),
1730+ LiftedAtom (_NotHolding , [robot , obj ]),
1731+ LiftedAtom (_NotOpen , [obj ]),
1732+ }
1733+ del_effs = {
1734+ LiftedAtom (_Holding , [robot , obj ]),
1735+ }
1736+ ignore_effs = {_InHandView , _Reachable , _RobotReadyForSweeping , _Blocking }
1737+ yield STRIPSOperator ("DragToCloseObject" , parameters , preconds , add_effs ,
1738+ del_effs , ignore_effs )
16881739
16891740 # MoveToReadySweep
16901741 robot = Variable ("?robot" , _robot_type )
@@ -3062,10 +3113,10 @@ def _detection_id_to_obj(self) -> Dict[ObjectDetectionID, Object]:
30623113
30633114 detection_id_to_obj : Dict [ObjectDetectionID , Object ] = {}
30643115
3065- red_block = Object ("red_block " , _movable_object_type )
3066- red_block_detection = LanguageObjectDetectionID (
3067- "red block/orange block/yellow block" )
3068- detection_id_to_obj [red_block_detection ] = red_block
3116+ blue_block = Object ("blue_block " , _movable_object_type )
3117+ blue_block_detection = LanguageObjectDetectionID (
3118+ "blue block/blue-ish block/blue-green block" )
3119+ detection_id_to_obj [blue_block_detection ] = blue_block
30693120
30703121 for obj , pose in get_known_immovable_objects ().items ():
30713122 detection_id = KnownStaticObjectDetectionID (obj .name , pose )
@@ -3074,8 +3125,61 @@ def _detection_id_to_obj(self) -> Dict[ObjectDetectionID, Object]:
30743125 return detection_id_to_obj
30753126
30763127 def _generate_goal_description (self ) -> GoalDescription :
3077- return "pick up the red block"
3128+ return "pick up the blue block"
30783129
30793130 def _get_dry_task (self , train_or_test : str ,
30803131 task_idx : int ) -> EnvironmentTask :
30813132 raise NotImplementedError ("Dry task generation not implemented." )
3133+
3134+
3135+ class LISSpotBlockDrawerEnv (SpotRearrangementEnv ):
3136+ """An extremely basic environment where a block needs to be picked up and
3137+ is specifically used for testing in the LIS Spot room.
3138+
3139+ Very simple and mostly just for testing.
3140+ """
3141+
3142+ def __init__ (self , use_gui : bool = True ) -> None :
3143+ super ().__init__ (use_gui )
3144+
3145+ op_to_name = {o .name : o for o in _create_operators ()}
3146+ op_names_to_keep = {
3147+ "MoveToReachObject" ,
3148+ "MoveToHandViewObject" ,
3149+ "PickObjectToDrag" ,
3150+ "DragToOpenObject" ,
3151+ "DragToCloseObject" ,
3152+ }
3153+ self ._strips_operators = {op_to_name [o ] for o in op_names_to_keep }
3154+
3155+ @classmethod
3156+ def get_name (cls ) -> str :
3157+ return "lis_spot_block_drawer_env"
3158+
3159+ @property
3160+ def _detection_id_to_obj (self ) -> Dict [ObjectDetectionID , Object ]:
3161+
3162+ detection_id_to_obj : Dict [ObjectDetectionID , Object ] = {}
3163+
3164+ blue_block = Object ("blue_block" , _movable_object_type )
3165+ blue_block_detection = LanguageObjectDetectionID (
3166+ "blue block/blue-ish block/blue-green block" )
3167+ detection_id_to_obj [blue_block_detection ] = blue_block
3168+
3169+ green_handle = Object ("green_handle" , _movable_object_type )
3170+ green_handle_detection = LanguageObjectDetectionID (
3171+ "green duct tape/green handle/green object" )
3172+ detection_id_to_obj [green_handle_detection ] = green_handle
3173+
3174+ for obj , pose in get_known_immovable_objects ().items ():
3175+ detection_id = KnownStaticObjectDetectionID (obj .name , pose )
3176+ detection_id_to_obj [detection_id ] = obj
3177+
3178+ return detection_id_to_obj
3179+
3180+ def _generate_goal_description (self ) -> GoalDescription :
3181+ return "open the drawer"
3182+
3183+ def _get_dry_task (self , train_or_test : str ,
3184+ task_idx : int ) -> EnvironmentTask :
3185+ raise NotImplementedError ("Dry task generation not implemented." )
0 commit comments