Skip to content

Commit 4abfd8e

Browse files
committed
feat: add new env creator for diffpol evaluation, refactor existing one's camera creation logic
1 parent 7bb1dbb commit 4abfd8e

1 file changed

Lines changed: 49 additions & 38 deletions

File tree

python/rcs/envs/creators.py

Lines changed: 49 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -180,54 +180,65 @@ def __call__( # type: ignore
180180
resolution: tuple[int, int] | None = None,
181181
frame_rate: int = 0,
182182
delta_actions: bool = True,
183+
cam_list: list[str] = ["wrist", "bird_eye", "side", "right_side", "left_side", "front"]
183184
) -> gym.Env:
184185
if resolution is None:
185186
resolution = (256, 256)
186-
187187
cameras = {
188-
"wrist": SimCameraConfig(
189-
identifier="wrist_0",
190-
type=CameraType.fixed,
191-
resolution_height=resolution[1],
192-
resolution_width=resolution[0],
193-
frame_rate=frame_rate,
194-
),
195-
"bird_eye": SimCameraConfig(
196-
identifier="bird_eye_cam",
188+
cam: SimCameraConfig(
189+
identifier=cam,
197190
type=CameraType.fixed,
198191
resolution_height=resolution[1],
199192
resolution_width=resolution[0],
200193
frame_rate=frame_rate,
201-
),
202-
"side": SimCameraConfig(
203-
identifier="side_view",
204-
type=CameraType.fixed,
205-
resolution_height=resolution[1],
206-
resolution_width=resolution[0],
207-
frame_rate=frame_rate,
208-
),
209-
"right_side": SimCameraConfig(
210-
identifier="right_side",
211-
type=CameraType.fixed,
212-
resolution_height=resolution[1],
213-
resolution_width=resolution[0],
214-
frame_rate=frame_rate,
215-
),
216-
"left_side": SimCameraConfig(
217-
identifier="left_side",
218-
type=CameraType.fixed,
219-
resolution_height=resolution[1],
220-
resolution_width=resolution[0],
221-
frame_rate=frame_rate,
222-
),
223-
"front": SimCameraConfig(
224-
identifier="front",
194+
)
195+
for cam in cam_list
196+
}
197+
robot_cfg = default_sim_robot_cfg(scene="fr3_simple_pick_up")
198+
199+
return SimTaskEnvCreator()(robot_cfg, render_mode, control_mode, delta_actions, cameras)
200+
201+
class FR3LabDigitGripperPickUpSimEnvCreator(EnvCreator):
202+
def __call__( # type: ignore
203+
self,
204+
render_mode: str = "human",
205+
control_mode: ControlMode = ControlMode.CARTESIAN_TRPY,
206+
resolution: tuple[int, int] | None = None,
207+
frame_rate: int = 0,
208+
delta_actions: bool = True,
209+
cam_list: list[str] = [],
210+
mjcf_path: str = ''
211+
) -> gym.Env:
212+
if resolution is None:
213+
resolution = (256, 256)
214+
if cam_list is None or len(cam_list) == 0:
215+
error_msg = "cam_list must contain at least one camera name."
216+
raise ValueError(error_msg)
217+
cameras = {
218+
cam: SimCameraConfig(
219+
identifier=cam,
225220
type=CameraType.fixed,
226221
resolution_height=resolution[1],
227222
resolution_width=resolution[0],
228223
frame_rate=frame_rate,
229-
),
224+
)
225+
for cam in cam_list
230226
}
231-
robot_cfg = default_sim_robot_cfg(scene="fr3_simple_pick_up")
232-
233-
return SimTaskEnvCreator()(robot_cfg, render_mode, control_mode, delta_actions, cameras)
227+
robot_cfg = rcs.sim.SimRobotConfig()
228+
robot_cfg.tcp_offset = rcs.common.Pose(translation=np.array([0.0, 0.0, 0.15]), rotation=np.array([[0.707, 0.707, 0], [-0.707, 0.707, 0], [0, 0, 1]]))
229+
robot_cfg.robot_type = rcs.common.RobotType.FR3
230+
robot_cfg.realtime = False
231+
robot_cfg.add_id("0") # only required for fr3
232+
robot_cfg.mjcf_scene_path = mjcf_path
233+
robot_cfg.kinematic_model_path = rcs.scenes["fr3_empty_world"].mjcf_robot # .urdf (in case for urdf)
234+
print(f"Creating FR3LabDigitGripperPickUpSim with the following parameters: \n"
235+
f" render_mode: {render_mode}\n"
236+
f" control_mode: {control_mode}\n"
237+
f" resolution: {resolution}\n"
238+
f" frame_rate: {frame_rate}\n"
239+
f" delta_actions: {delta_actions}\n"
240+
f" cameras: {cameras}\n"
241+
f" mjcf_path: {mjcf_path}\n"
242+
)
243+
244+
return SimTaskEnvCreator()(robot_cfg, render_mode, control_mode, delta_actions, cameras)

0 commit comments

Comments
 (0)