-
Notifications
You must be signed in to change notification settings - Fork 261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integrate with Gym's RecordVideo
wrapper.
#84
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for doing this! Two questions for you.
brax/envs/wrappers.py
Outdated
@@ -103,6 +103,10 @@ class GymWrapper(gym.Env): | |||
# Flag that prevents `gym.register` from misinterpreting the `_step` and | |||
# `_reset` as signs of a deprecated gym Env API. | |||
_gym_disable_underscore_compat: ClassVar[bool] = True | |||
metadata = { | |||
'render.modes': ['human', 'rgb_array'], | |||
'video.frames_per_second' : 24 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be scaled according to the environment dt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I don't quite follow, what dt
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you step
an environment, a certain amount of time passes, for example in Ant
, each step is 0.05 seconds:
https://github.com/google/brax/blob/main/brax/envs/ant.py#L388
For the video speed to match the speed in the world, you would want video.frames_per_second
to be 1 / 0.05 = 20
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense. Thanks for the pointer. Just fixed it in the latest commit.
Looks great - thank you! |
This PR adds the meta-data tag that Gym's
RecordVideo
is looking for.Additionally, in the case of a vector environment, the render function would only render the first sub environment for speed reasons.
You can run the following to give it a try: