Skip to content
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

Fix: add mujoco render arguments to init #2891

Merged
merged 5 commits into from
Jun 16, 2022
Merged

Conversation

younik
Copy link
Contributor

@younik younik commented Jun 14, 2022

Allow user to specify render arguments for Mujoco during initialization.

For example:

import gym

env = gym.make("Humanoid-v4", render_mode="rgb_array", height=450, width=500)
env.reset()
for _ in range(100):
    env.step(env.action_space.sample())

im = env.render()
env.close()

> im[0].shape
(450, 500, 3)

Thanks @wookayin for spotting this (#2889)

@wookayin
Copy link
Contributor

Thanks for initiating the PR. However I am opposed to specifying all the rendering-based arguments to the constructor. Not only the name is confusing, but users would also want to pass those arguments for customizing rendering (also because .render() takes kwargs). Use of render_kwargs would be another alternative but it doesn't sound pretty. Why don't we simply allow env.render(..., width=, height=, camera_id=..., etc.) as before?

@younik
Copy link
Contributor Author

younik commented Jun 14, 2022

also because .render() takes kwargs

This will not be true anymore with gym 1.0

Why don't we simply allow env.render(..., width=, height=, camera_id=..., etc.) as before?

Because the frames are computed before the render call; you should call render just to collect frames

Use of render_kwargs would be another alternative but it doesn't sound pretty.

Do you mean something like this?

render_kwargs = {'height'=450, 'width'=500}
env = gym.make("Humanoid-v4", render_mode="rgb_array", render_kwargs=render_kwargs)

I don't have a strong preference for this.

@wookayin wookayin mentioned this pull request Jun 14, 2022
1 task
@younik younik marked this pull request as draft June 14, 2022 15:14
@younik younik marked this pull request as ready for review June 16, 2022 09:40
@pseudo-rnd-thoughts
Copy link
Contributor

With type hints, looks good to merge

@jkterry1 jkterry1 merged commit a7e1861 into openai:master Jun 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants