@@ -185,7 +185,7 @@ def test_default_tolerances(self, robot_scene):
185185 cfg = _make_config (robot )
186186 assert cfg .move_to_pose_tol == pytest .approx (1e-4 )
187187 assert cfg .max_vel_norm == pytest .approx (0.05 )
188- assert cfg .grasp_tol == pytest .approx (1e-3 )
188+ assert cfg .grasp_tol == pytest .approx (5e-4 )
189189 assert cfg .collision_bodies == ()
190190 assert cfg .ik_validate is True
191191 assert cfg .robot_init_tilt == pytest .approx (0.0 )
@@ -232,7 +232,7 @@ def dummy_target(state, objects, params, cfg):
232232 assert phase .name == "TestMove"
233233 assert phase .action_type == PhaseAction .MOVE_TO_POSE
234234 assert phase .terminal_fn is None
235- assert phase .use_motion_planning is True # default
235+ assert phase .use_motion_planning is False # default from CFG
236236
237237 def test_change_fingers_phase (self ):
238238 def dummy_target (state , objects , params , cfg ):
@@ -745,7 +745,7 @@ def test_returns_phase_with_move_action_type(self):
745745 assert isinstance (phase , Phase )
746746 assert phase .action_type == PhaseAction .MOVE_TO_POSE
747747 assert phase .name == "MoveTest"
748- assert phase .use_motion_planning is True # default
748+ assert phase .use_motion_planning is False # default from CFG
749749
750750 def test_explicit_open_finger_status (self , robot_scene ):
751751 _ , robot = robot_scene
@@ -865,18 +865,19 @@ def test_policy_returns_valid_action(self, robot_scene):
865865
866866class TestCreatePickSkill :
867867
868- def _make_pick (self , robot , with_grasp_terminal = False ):
869- config = _make_config (robot )
870- grasp_fn = (lambda s , o , p_ , c : True ) if with_grasp_terminal else None
868+ def _make_pick (self , robot ):
869+ config = SkillConfig (
870+ robot = robot ,
871+ open_fingers_joint = robot .open_fingers ,
872+ closed_fingers_joint = robot .closed_fingers ,
873+ fingers_state_to_joint = _fingers_state_to_joint ,
874+ transport_z = 0.8 ,
875+ )
871876 return create_pick_skill (
872877 name = "Pick" ,
873878 types = [_ROBOT_TYPE , _OBJ_TYPE ],
874- params_space = Box (0 , 1 , (0 ,)),
875879 config = config ,
876880 get_target_pose_fn = lambda s , o , p_ , c : (1.35 , 0.75 , 0.4 , 0.0 ),
877- transport_z = 0.8 ,
878- grasp_z_offset = 0.02 ,
879- grasp_terminal_fn = grasp_fn ,
880881 )
881882
882883 def test_returns_parameterized_option (self , robot_scene ):
@@ -888,18 +889,12 @@ def test_returns_parameterized_option(self, robot_scene):
888889 def test_pick_policy_returns_valid_action (self , robot_scene ):
889890 _ , robot = robot_scene
890891 utils .reset_config ({"seed" : 123 })
891- config = _make_config (robot )
892892 robot_obj = _make_robot_obj ()
893893 obj = _make_obj ()
894- opt = create_pick_skill (
895- name = "Pick" ,
896- types = [_ROBOT_TYPE , _OBJ_TYPE ],
897- params_space = Box (0 , 1 , (0 ,)),
898- config = config ,
899- get_target_pose_fn = lambda s , o , p_ , c : (1.35 , 0.75 , 0.4 , 0.0 ),
900- transport_z = 0.8 ,
901- )
902- grounded = opt .ground ([robot_obj , obj ], np .zeros (0 ))
894+ opt = self ._make_pick (robot )
895+ # Pick params: (grasp_z_offset,) — use 0.02
896+ grounded = opt .ground ([robot_obj , obj ], np .array ([0.02 ],
897+ dtype = np .float32 ))
903898 state = _make_home_state (robot_obj , robot , obj = obj ,
904899 obj_xyz = (1.35 , 0.75 , 0.4 ))
905900 grounded .initiable (state )
@@ -915,15 +910,17 @@ def test_pick_policy_returns_valid_action(self, robot_scene):
915910class TestCreatePlaceSkill :
916911
917912 def _make_place (self , robot ):
918- config = _make_config (robot )
913+ config = SkillConfig (
914+ robot = robot ,
915+ open_fingers_joint = robot .open_fingers ,
916+ closed_fingers_joint = robot .closed_fingers ,
917+ fingers_state_to_joint = _fingers_state_to_joint ,
918+ transport_z = 0.8 ,
919+ )
919920 return create_place_skill (
920921 name = "Place" ,
921922 types = [_ROBOT_TYPE ],
922- params_space = Box (0 , 1 , (0 ,)),
923923 config = config ,
924- get_target_pose_fn = lambda s , o , p_ , c : (1.35 , 0.75 , 0.4 , 0.0 ),
925- transport_z = 0.8 ,
926- drop_z = 0.45 ,
927924 )
928925
929926 def test_returns_parameterized_option (self , robot_scene ):
@@ -935,18 +932,11 @@ def test_returns_parameterized_option(self, robot_scene):
935932 def test_place_policy_returns_valid_action (self , robot_scene ):
936933 _ , robot = robot_scene
937934 utils .reset_config ({"seed" : 123 })
938- config = _make_config (robot )
939935 robot_obj = _make_robot_obj ()
940- opt = create_place_skill (
941- name = "Place" ,
942- types = [_ROBOT_TYPE ],
943- params_space = Box (0 , 1 , (0 ,)),
944- config = config ,
945- get_target_pose_fn = lambda s , o , p_ , c : (1.35 , 0.75 , 0.4 , 0.0 ),
946- transport_z = 0.8 ,
947- drop_z = 0.45 ,
948- )
949- grounded = opt .ground ([robot_obj ], np .zeros (0 ))
936+ opt = self ._make_place (robot )
937+ # Place params: (x, y, yaw, drop_z) — within bounds
938+ grounded = opt .ground ([robot_obj ], np .array ([0.75 , 1.35 , 0.0 , 0.45 ],
939+ dtype = np .float32 ))
950940 state = _make_home_state (robot_obj , robot )
951941 grounded .initiable (state )
952942 action = grounded .policy (state )
@@ -962,50 +952,42 @@ class TestCreatePushSkill:
962952
963953 @staticmethod
964954 def _make_push_config (robot ):
965- config = _make_config (robot )
966955 # robot_home_pos is required for create_push_skill
967956 return SkillConfig (
968- robot = config . robot ,
969- open_fingers_joint = config . open_fingers_joint ,
970- closed_fingers_joint = config . closed_fingers_joint ,
971- fingers_state_to_joint = config . fingers_state_to_joint ,
957+ robot = robot ,
958+ open_fingers_joint = robot . open_fingers ,
959+ closed_fingers_joint = robot . closed_fingers ,
960+ fingers_state_to_joint = _fingers_state_to_joint ,
972961 robot_home_pos = _EE_HOME ,
962+ transport_z = 0.8 ,
973963 )
974964
975- def test_returns_parameterized_option (self , robot_scene ):
976- _ , robot = robot_scene
965+ def _make_push (self , robot ):
977966 config = self ._make_push_config (robot )
978- opt = create_push_skill (
967+ return create_push_skill (
979968 name = "Push" ,
980969 types = [_ROBOT_TYPE , _OBJ_TYPE ],
981- params_space = Box (0 , 1 , (0 ,)),
982970 config = config ,
983971 get_target_pose_fn = lambda s , o , p_ , c : (1.35 , 0.75 , 0.4 , 0.0 ),
984- offset_x = 0.05 ,
985- offset_z = 0.02 ,
986- transport_z = 0.8 ,
987972 )
973+
974+ def test_returns_parameterized_option (self , robot_scene ):
975+ _ , robot = robot_scene
976+ opt = self ._make_push (robot )
988977 assert isinstance (opt , ParameterizedOption )
989978 assert opt .name == "Push"
990979
991980 def test_push_policy_close_fingers_returns_valid_action (self , robot_scene ):
992981 """First call lands in CloseFingers phase -> action within bounds."""
993982 _ , robot = robot_scene
994983 utils .reset_config ({"seed" : 123 })
995- config = self ._make_push_config (robot )
996984 robot_obj = _make_robot_obj ()
997985 obj = _make_obj ()
998- opt = create_push_skill (
999- name = "Push" ,
1000- types = [_ROBOT_TYPE , _OBJ_TYPE ],
1001- params_space = Box (0 , 1 , (0 ,)),
1002- config = config ,
1003- get_target_pose_fn = lambda s , o , p_ , c : (1.35 , 0.75 , 0.4 , 0.0 ),
1004- offset_x = 0.05 ,
1005- offset_z = 0.02 ,
1006- transport_z = 0.8 ,
1007- )
1008- grounded = opt .ground ([robot_obj , obj ], np .zeros (0 ))
986+ opt = self ._make_push (robot )
987+ # Push params: (offset_x, offset_z, offset_rot, push_through_frac)
988+ grounded = opt .ground ([robot_obj , obj ],
989+ np .array ([0.05 , 0.02 , 0.0 , 0.25 ],
990+ dtype = np .float32 ))
1009991 state = _build_state (robot_obj , robot , * _EE_HOME ,
1010992 finger_state = _OPEN_STATE , obj = obj ,
1011993 obj_xyz = (1.35 , 0.75 , 0.4 ))
0 commit comments