Skip to content

Commit

Permalink
Support for VecVideoRecorder (openai#62)
Browse files Browse the repository at this point in the history
* Support for VecVideoRecorder

Support for VecVideoRecorder
 https://stable-baselines3.readthedocs.io/en/master/guide/vec_envs.html?highlight=video#vecvideorecorder

* VecVideoRecorder update

* Update env.py

Frames per second fixed 24 from to 15 fps
  • Loading branch information
bragajj authored Jan 24, 2022
1 parent 577d0ef commit 4b5e5d5
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions procgen/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,22 @@ def __init__(
"distribution_mode": distribution_mode,
}
super().__init__(num, env_name, options, **kwargs)


class ToBaselinesVecEnv(gym3.ToBaselinesVecEnv):
metadata = {
'render.modes': ['human', 'rgb_array'],
'video.frames_per_second' : 15
}
def render(self, mode="human"):
info = self.env.get_info()[0]
_, ob, _ = self.env.observe()
if mode == "rgb_array":
if "rgb" in info:
return info["rgb"]
else:
return ob['rgb'][0]


def ProcgenEnv(num_envs, env_name, **kwargs):
"""
Baselines VecEnv interface for Procgen
"""
return gym3.ToBaselinesVecEnv(ProcgenGym3Env(num=num_envs, env_name=env_name, **kwargs))
return ToBaselinesVecEnv(ProcgenGym3Env(num=num_envs, env_name=env_name, **kwargs))

0 comments on commit 4b5e5d5

Please sign in to comment.