feat(simulate): configurable camera id
This commit is contained in:
parent
d6146850fb
commit
aabf1bc186
4 changed files with 7 additions and 2 deletions
|
|
@ -18,3 +18,5 @@ morphology_override: null
|
||||||
record_video: false
|
record_video: false
|
||||||
# When null, video is saved in a per-model evaluation folder alongside the model.
|
# When null, video is saved in a per-model evaluation folder alongside the model.
|
||||||
video_output_path: null
|
video_output_path: null
|
||||||
|
# Camera ID to use for video recording (1 is usually the close-up camera)
|
||||||
|
camera_id: 1
|
||||||
|
|
|
||||||
|
|
@ -148,6 +148,7 @@ def main(dict_cfg: DictConfig) -> None:
|
||||||
action_high=action_high,
|
action_high=action_high,
|
||||||
action_mask=action_mask,
|
action_mask=action_mask,
|
||||||
output_path=output_path,
|
output_path=output_path,
|
||||||
|
camera_id=sim_cfg.camera_id,
|
||||||
)
|
)
|
||||||
|
|
||||||
save_evaluation_metadata(
|
save_evaluation_metadata(
|
||||||
|
|
|
||||||
|
|
@ -24,3 +24,5 @@ class SimulationSettings:
|
||||||
record_video: bool = False
|
record_video: bool = False
|
||||||
# When None, video is saved in a per-model evaluation folder alongside the model.
|
# When None, video is saved in a per-model evaluation folder alongside the model.
|
||||||
video_output_path: Optional[str] = None
|
video_output_path: Optional[str] = None
|
||||||
|
# Camera ID to use for video recording (1 is usually the close-up camera)
|
||||||
|
camera_id: int = 1
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,7 @@ def record_episode(
|
||||||
action_high: np.ndarray | None,
|
action_high: np.ndarray | None,
|
||||||
action_mask: np.ndarray | None = None,
|
action_mask: np.ndarray | None = None,
|
||||||
output_path: Path,
|
output_path: Path,
|
||||||
|
camera_id: int = 1,
|
||||||
fps: int = 60,
|
fps: int = 60,
|
||||||
width: int = 640,
|
width: int = 640,
|
||||||
height: int = 480,
|
height: int = 480,
|
||||||
|
|
@ -77,6 +78,7 @@ def record_episode(
|
||||||
action_high: Maximum action values.
|
action_high: Maximum action values.
|
||||||
action_mask: Boolean mask for the actions.
|
action_mask: Boolean mask for the actions.
|
||||||
output_path: Where to save the .mp4 file.
|
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.
|
fps: Frames per second for the video.
|
||||||
width: Video width.
|
width: Video width.
|
||||||
height: Video height.
|
height: Video height.
|
||||||
|
|
@ -94,8 +96,6 @@ def record_episode(
|
||||||
model = state.mj_model
|
model = state.mj_model
|
||||||
data = state.mj_data
|
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)
|
renderer = mujoco.Renderer(model, width=width, height=height)
|
||||||
|
|
||||||
ep_return = 0.0
|
ep_return = 0.0
|
||||||
|
|
|
||||||
Reference in a new issue