Skip to content

Commit

Permalink
Fix #631
Browse files Browse the repository at this point in the history
  • Loading branch information
eleurent committed Nov 12, 2024
1 parent def6f4f commit 116c23f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions highway_env/envs/common/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ def get_available_actions(self) -> list[int]:
def set_record_video_wrapper(self, wrapper: RecordVideo):
self._record_video_wrapper = wrapper
self.update_metadata()
self._record_video_wrapper.frames_per_sec = self.metadata["render_fps"]

def _automatic_rendering(self) -> None:
"""
Expand All @@ -334,8 +335,8 @@ def _automatic_rendering(self) -> None:
If a RecordVideo wrapper has been set, use it to capture intermediate frames.
"""
if self.viewer is not None and self.enable_auto_render:
if self._record_video_wrapper and self._record_video_wrapper.video_recorder:
self._record_video_wrapper.video_recorder.capture_frame()
if self._record_video_wrapper:
self._record_video_wrapper._capture_frame()
else:
self.render()

Expand Down
2 changes: 1 addition & 1 deletion scripts/sb3_highway_dqn.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
env = RecordVideo(
env, video_folder="highway_dqn/videos", episode_trigger=lambda e: True
)
env.unwrapped.set_record_video_wrapper(env)
env.unwrapped.config["simulation_frequency"] = 15 # Higher FPS for rendering
env.unwrapped.set_record_video_wrapper(env)

for videos in range(10):
done = truncated = False
Expand Down

0 comments on commit 116c23f

Please sign in to comment.