2222 HandWrapperSim ,
2323 PickCubeSuccessWrapper ,
2424 RandomCubePos ,
25+ RandomObjectPos ,
2526 RobotSimWrapper ,
2627 SimWrapper ,
2728)
2829from rcs .envs .utils import default_sim_gripper_cfg , default_sim_robot_cfg
30+ from functools import partial
2931
3032import rcs
3133from rcs import sim
@@ -135,6 +137,7 @@ def __call__( # type: ignore
135137 cameras : dict [str , SimCameraConfig ] | None = None ,
136138 hand_cfg : rcs .sim .SimTilburgHandConfig | None = None ,
137139 gripper_cfg : rcs .sim .SimGripperConfig | None = None ,
140+ random_pos_args : dict = {}
138141 ) -> gym .Env :
139142 mode = "gripper"
140143 if gripper_cfg is None and hand_cfg is None :
@@ -152,6 +155,15 @@ def __call__( # type: ignore
152155 _hand_cfg = None
153156 logger .info ("Using gripper configuration." )
154157
158+ random_env = RandomCubePos
159+ if random_pos_args :
160+ # check that all the keys are there
161+ required_keys = ["joint_name" , "init_object_pose" ]
162+ if not all (key in random_pos_args for key in required_keys ):
163+ missing_keys = [key for key in required_keys if key not in random_pos_args ]
164+ logger .warning (f"Missing random position arguments: { missing_keys } ; Defaulting to RandomCubePos" )
165+ random_env = partial (RandomObjectPos , ** random_pos_args )
166+
155167 env_rel = SimEnvCreator ()(
156168 control_mode = control_mode ,
157169 robot_cfg = robot_cfg ,
@@ -161,7 +173,7 @@ def __call__( # type: ignore
161173 cameras = cameras ,
162174 max_relative_movement = (0.2 , np .deg2rad (45 )) if delta_actions else None ,
163175 relative_to = RelativeTo .LAST_STEP ,
164- sim_wrapper = RandomCubePos ,
176+ sim_wrapper = random_env ,
165177 )
166178 if mode == "gripper" :
167179 env_rel = PickCubeSuccessWrapper (env_rel )
0 commit comments