Skip to content

Commit

Permalink
[Feature] Substep Rendering (#724)
Browse files Browse the repository at this point in the history
* Update record.py

* Update record.py
  • Loading branch information
StoneT2000 authored Nov 28, 2024
1 parent f83b97f commit bec2b94
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions mani_skill/utils/wrappers/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ class RecordEpisode(gym.Wrapper):
record_reward: whether to record the reward in the trajectory data
record_env_state: whether to record the environment state in the trajectory data
video_fps (int): The FPS of the video to generate if save_video is True
render_substeps (bool): Whether to render substeps for video. This is captures an image of the environment after each physics step. This runs slower but generates more image frames
per environment step which when coupled with a higher video FPS can yield a smoother video.
avoid_overwriting_video (bool): If true, the wrapper will iterate over possible video names to avoid overwriting existing videos in the output directory. Useful for resuming training runs.
source_type (Optional[str]): a word to describe the source of the actions used to record episodes (e.g. RL, motionplanning, teleoperation)
source_desc (Optional[str]): A longer description describing how the demonstrations are collected
Expand All @@ -226,6 +228,7 @@ def __init__(
record_reward: bool = True,
record_env_state: bool = True,
video_fps: int = 30,
render_substeps: bool = False,
avoid_overwriting_video: bool = False,
source_type: Optional[str] = None,
source_desc: Optional[str] = None,
Expand Down Expand Up @@ -302,6 +305,19 @@ def __init__(
else:
break

self.render_substeps = render_substeps
if self.render_substeps:
_original_after_simulation_step = self.base_env._after_simulation_step

def wrapped_after_simulation_step():
_original_after_simulation_step()
if self.save_video:
if self.base_env.gpu_sim_enabled:
self.base_env.scene._gpu_fetch_all()
self.render_images.append(self.capture_image())

self.base_env._after_simulation_step = wrapped_after_simulation_step

@property
def num_envs(self):
return self.base_env.num_envs
Expand Down

0 comments on commit bec2b94

Please sign in to comment.