3434from predicators .spot_utils .skills .spot_place import place_at_relative_position
3535from predicators .spot_utils .skills .spot_stow_arm import stow_arm
3636from predicators .spot_utils .skills .spot_sweep import sweep
37+ from predicators .spot_utils .skills .spot_wipe_table import wipe_multiple_strokes
3738from predicators .spot_utils .spot_localization import SpotLocalizer
3839from predicators .spot_utils .utils import DEFAULT_HAND_DROP_OBJECT_POSE , \
3940 DEFAULT_HAND_LOOK_STRAIGHT_DOWN_POSE , DEFAULT_HAND_POST_DUMP_POSE , \
@@ -440,22 +441,22 @@ def _sweep_objects_into_container_policy(name: str, robot_obj_idx: int,
440441 ) * middle_bottom_surface_pose
441442 # Now, compute the actual pose the hand should start sweeping from by
442443 # clamping it between the surface poses.
443- start_x = np .clip (middle_bottom_surface_rel_pose .x , mean_x + 0.175 ,
444+ start_x = np .clip (middle_bottom_surface_rel_pose .x , mean_x + 0.275 ,
444445 upper_left_surface_rel_pose .x )
445446 start_y = np .clip (middle_bottom_surface_rel_pose .y , mean_y + 0.41 ,
446447 upper_left_surface_rel_pose .y )
447448 # use absolute value so that we don't get messed up by noise in the
448449 # perception height estimate.
449- start_z = 0.14
450+ start_z = 0.17
450451 pitch = math_helpers .Quat .from_pitch (np .pi / 2 )
451452 yaw = math_helpers .Quat .from_yaw (np .pi / 4 )
452453 rot = pitch * yaw
453- sweep_start_pose = math_helpers .SE3Pose (x = start_x ,
454- y = start_y ,
454+ sweep_start_pose = math_helpers .SE3Pose (x = start_x + 1.0 ,
455+ y = start_y + 0.4 ,
455456 z = start_z ,
456457 rot = rot )
457458 sweep_move_dx = 0.0
458- sweep_move_dy = - 0.8
459+ sweep_move_dy = - 1.0
459460 sweep_move_dz = 0.0
460461
461462 # Execute the sweep. Note simulation fn and args not implemented yet.
@@ -496,13 +497,19 @@ def _pick_and_dump_policy(name: str, robot_obj_idx: int, target_obj_idx: int,
496497
497498 def _fn () -> None :
498499 for action in actions :
499- assert isinstance (action .extra_info , (list , tuple ))
500- _ , _ , action_fn , action_fn_args , _ , _ = action .extra_info
501- action_fn (* action_fn_args )
500+ if isinstance (action .extra_info , (list , tuple )):
501+ _ , _ , action_fn , action_fn_args , _ , _ = action .extra_info
502+ action_fn (* action_fn_args )
503+ continue
504+ else :
505+ action_fn = action .extra_info .real_world_fn
506+ action_fn_args = action .extra_info .real_world_fn_args
507+ action_fn (* action_fn_args )
508+ continue
502509
503510 # Note simulation fn and args not implemented yet.
504- action_extra_info = SpotActionExtraInfo (name , objects , _fn , tuple (), None ,
505- tuple ())
511+ action_extra_info = SpotActionExtraInfo (name , objects , _fn , tuple (), None , tuple ())
512+
506513 return utils .create_spot_env_action (action_extra_info )
507514
508515
@@ -595,7 +602,7 @@ def _pick_object_to_drag_policy(state: State, memory: Dict,
595602 params : Array ) -> Action :
596603 name = "PickObjectToDrag"
597604 target_obj_idx = 1
598- if objects [target_obj_idx ].name == 'green_handle' :
605+ if objects [target_obj_idx ].name == 'green_handle' or 'chair' in objects [ target_obj_idx ]. name :
599606 return _grasp_policy (name , target_obj_idx , state , memory , objects , params , do_not_stow = True )
600607 return _grasp_policy (name , target_obj_idx , state , memory , objects , params )
601608
@@ -892,7 +899,7 @@ def _prepare_container_for_sweeping_policy(state: State, memory: Dict,
892899 rot = math_helpers .Quat .from_pitch (np .pi / 2 )
893900 place_rel_pose = math_helpers .SE3Pose (x = 0.6 ,
894901 y = 0.0 ,
895- z = container_z - 0.15 ,
902+ z = container_z , # TODO - 0.15,
896903 rot = rot )
897904
898905 # Push towards the target a little bit after placing.
@@ -917,7 +924,7 @@ def _move_to_ready_sweep_policy(state: State, memory: Dict,
917924 name = "MoveToReadySweep"
918925
919926 # Always approach from the same angle.
920- yaw = np .pi / 2.0
927+ yaw = 0.0 # np.pi / 2.0
921928 # Make up new params.
922929 distance = 0.8
923930 params = np .array ([distance , yaw ])
@@ -931,6 +938,55 @@ def _move_to_ready_sweep_policy(state: State, memory: Dict,
931938 state , memory , objects , params )
932939
933940
941+ def _wipe_table_policy (state : State , memory : Dict ,
942+ objects : Sequence [Object ],
943+ params : Array ) -> Action :
944+ del memory # not used
945+
946+ robot , _ , _ = get_robot ()
947+ name = "WipeTable"
948+
949+ robot_obj = objects [0 ]
950+ surface_obj = objects [2 ]
951+
952+ robot_pose = utils .get_se3_pose_from_state (state , robot_obj )
953+ surface_pose = utils .get_se3_pose_from_state (state , surface_obj )
954+ surface_height = state .get (surface_obj , "height" )
955+ if surface_obj .name == "wooden_table" :
956+ surface_height -= 1.0
957+
958+ # Compute relative pose for wiping start position
959+ surface_rel_pose = robot_pose .inverse () * surface_pose
960+
961+ # Extract parameters
962+ stroke_dx , stroke_dy , num_strokes_float , duration = params
963+ num_strokes = max (1 , int (num_strokes_float ))
964+
965+ # Define wipe start pose relative to robot
966+ pitch = math_helpers .Quat .from_pitch (np .pi / 2 )
967+ wipe_start_pose = math_helpers .SE3Pose (
968+ x = surface_rel_pose .x ,
969+ y = surface_rel_pose .y - 0.2 ,
970+ z = surface_height + 0.05 ,
971+ rot = pitch )
972+
973+ # End look pose after wiping
974+ end_look_pose = math_helpers .SE3Pose (
975+ x = surface_rel_pose .x - 0.1 ,
976+ y = surface_rel_pose .y ,
977+ z = surface_height + 0.3 ,
978+ rot = math_helpers .Quat .from_pitch (np .pi / 2.5 ))
979+
980+ # Delta between strokes
981+ delta_between_strokes = (0.05 , 0.0 )
982+
983+ action_extra_info = SpotActionExtraInfo (
984+ name , objects , wipe_multiple_strokes ,
985+ (robot , wipe_start_pose , end_look_pose , stroke_dx , stroke_dy ,
986+ delta_between_strokes , num_strokes , duration ), None , ())
987+ return utils .create_spot_env_action (action_extra_info )
988+
989+
934990###############################################################################
935991# Parameterized option factory #
936992###############################################################################
@@ -963,6 +1019,7 @@ def _move_to_ready_sweep_policy(state: State, memory: Dict,
9631019 "PrepareContainerForSweeping" : Box (- np .inf , np .inf , (3 , )), # dx, dy, dyaw
9641020 "DropNotPlaceableObject" : Box (0 , 1 , (0 , )), # empty
9651021 "MoveToReadySweep" : Box (0 , 1 , (0 , )), # empty
1022+ "WipeTable" : Box (- np .inf , np .inf , (4 , )), # stroke_dx, stroke_dy, num_strokes, duration
9661023}
9671024
9681025# NOTE: the policies MUST be unique because they output actions with extra info
@@ -988,6 +1045,7 @@ def _move_to_ready_sweep_policy(state: State, memory: Dict,
9881045 "PrepareContainerForSweeping" : _prepare_container_for_sweeping_policy ,
9891046 "DropNotPlaceableObject" : _drop_not_placeable_object_policy ,
9901047 "MoveToReadySweep" : _move_to_ready_sweep_policy ,
1048+ "WipeTable" : _wipe_table_policy ,
9911049}
9921050
9931051
@@ -1034,7 +1092,10 @@ def get_env_names(cls) -> Set[str]:
10341092 "spot_brush_shelf_env" ,
10351093 "lis_spot_block_floor_env" ,
10361094 "lis_spot_block_drawer_env" ,
1037- "lis_spot_collect_misplaced_items_env"
1095+ "lis_spot_collect_misplaced_items_env" ,
1096+ "lis_spot_balls_yellow_table_env" ,
1097+ "lis_spot_bear_panda_bucket_sweep_env" ,
1098+ "lis_spot_wipe_table_env"
10381099 }
10391100
10401101 @classmethod
0 commit comments