A warning was raised whenever the render method was called. This PR should fix this. Changes made to this end:
Added **kwargs to super().__init__() in the LavaGap, MultiRoom, and PutNear environments, so that gym.make(..., render_mode=...) works for these environments.
Added two attributes to minigrid environments: render_mode (so that gym.make(..., render_mode=...) works as expected), and agent_pov, a boolean controling wether the rendered image is the full environment or only the agent's point of view.
Split the old render mode in two functions: get_render that returns an image as a 3D numpy array (whether the full environment or the agent's pov, depending on agent_pov), and the action render that calls get_render, and either draws the image in a Window object (if self.render_mode == 'human') or returns it.
Changed get_obs_render's signature to match get_full_render's signature. Neither needs to take the observation or the tile size as inputs.
Changed the observation method of the RGBImgObsWrapper class, where instead of using env.render(mode=...), it now uses env.get_full_render().
A warning was raised whenever a wrapper was used. This is because even though env.new_step_api=True, Wrapper(env).new_step_api=False by default. A simple fix was to add super().__init__(env, new_step_api=env.new_step_api) in each wrapper's init method.
The benchmark and manual_control now define functions that could be imported (for tests) and a main part that calls these functions when the scripts are run.
Finally, I added a new test file for window.py, benchmark.py and manual_control.py.
Checklist:
[x] I have run the pre-commit checks with pre-commit run --all-files (see CONTRIBUTING.md instructions to set it up)
[x] I have commented my code, particularly in hard-to-understand areas
[ ] I have made corresponding changes to the documentation
[x] My changes generate no new warnings
[x] I have added tests that prove my fix is effective or that my feature works
[ ] New and existing unit tests pass locally with my changes
Description
A warning was raised whenever the
render
method was called. This PR should fix this. Changes made to this end:super().__init__()
in the LavaGap, MultiRoom, and PutNear environments, so thatgym.make(..., render_mode=...)
works for these environments.render_mode
(so thatgym.make(..., render_mode=...)
works as expected), andagent_pov
, a boolean controling wether the rendered image is the full environment or only the agent's point of view.render
mode in two functions:get_render
that returns an image as a 3D numpy array (whether the full environment or the agent's pov, depending onagent_pov
), and the actionrender
that callsget_render
, and either draws the image in aWindow
object (ifself.render_mode == 'human'
) or returns it.get_obs_render
's signature to matchget_full_render
's signature. Neither needs to take the observation or the tile size as inputs.observation
method of the RGBImgObsWrapper class, where instead of usingenv.render(mode=...)
, it now usesenv.get_full_render()
.A warning was raised whenever a wrapper was used. This is because even though
env.new_step_api=True
,Wrapper(env).new_step_api=False
by default. A simple fix was to addsuper().__init__(env, new_step_api=env.new_step_api)
in each wrapper's init method.The
benchmark
andmanual_control
now define functions that could be imported (for tests) and a main part that calls these functions when the scripts are run.Finally, I added a new test file for
window.py
,benchmark.py
andmanual_control.py
.Checklist:
pre-commit
checks withpre-commit run --all-files
(seeCONTRIBUTING.md
instructions to set it up)