1
Fork 0

feat(simulate): configurable camera id

This commit is contained in:
Tibo De Peuter 2026-04-28 14:00:12 +02:00
parent d6146850fb
commit aabf1bc186
Signed by: tdpeuter
SSH key fingerprint: SHA256:u/h/LVoqKF1Iz02uOyxe6hcjmoZASCGV2HM0TG9ZMoU
4 changed files with 7 additions and 2 deletions

View file

@ -18,3 +18,5 @@ morphology_override: null
record_video: false
# When null, video is saved in a per-model evaluation folder alongside the model.
video_output_path: null
# Camera ID to use for video recording (1 is usually the close-up camera)
camera_id: 1

View file

@ -148,6 +148,7 @@ def main(dict_cfg: DictConfig) -> None:
action_high=action_high,
action_mask=action_mask,
output_path=output_path,
camera_id=sim_cfg.camera_id,
)
save_evaluation_metadata(

View file

@ -24,3 +24,5 @@ class SimulationSettings:
record_video: bool = False
# When None, video is saved in a per-model evaluation folder alongside the model.
video_output_path: Optional[str] = None
# Camera ID to use for video recording (1 is usually the close-up camera)
camera_id: int = 1

View file

@ -62,6 +62,7 @@ def record_episode(
action_high: np.ndarray | None,
action_mask: np.ndarray | None = None,
output_path: Path,
camera_id: int = 1,
fps: int = 60,
width: int = 640,
height: int = 480,
@ -77,6 +78,7 @@ def record_episode(
action_high: Maximum action values.
action_mask: Boolean mask for the actions.
output_path: Where to save the .mp4 file.
camera_id: Camera index to use for rendering (1 is usually close-up).
fps: Frames per second for the video.
width: Video width.
height: Video height.
@ -94,8 +96,6 @@ def record_episode(
model = state.mj_model
data = state.mj_data
# Use the first camera defined in the environment config, or default to 0
camera_id = env._config.camera_ids[0] if env._config.camera_ids else 0
renderer = mujoco.Renderer(model, width=width, height=height)
ep_return = 0.0