Farama-Foundation / Minigrid

Simple and easily configurable grid world environments for reinforcement learning
https://minigrid.farama.org/
Other
2.13k stars 611 forks source link

[Bug Report] Width/Height inverted in all non-square Minigrid environments with RGBImgObsWrapper #444

Closed waymao closed 3 months ago

waymao commented 3 months ago

Describe the bug When the width and height of a custom minigrid environment are not the same, it causes the observation generated by RGBImgObsWrapper to have the width and height to be inverted. The shape of the obs in the obs space and the actual obs is thus inconsistent.

Code example

from minigrid.wrappers import RGBImgObsWrapper
import gymnasium

env = RGBImgObsWrapper(gymnasium.make("MiniGrid-BlockedUnlockPickup-v0")) # any non-square env will cause the error
print(env.observation_space)

obs, info = env.reset()
print(obs['image'].shape)

assert env.observation_space['image'].shape == obs['image'].shape

System Info Describe the characteristic of your environment:

Additional context Possibly due to the way the grid renders itself (in the format of height/width/3), while the wrapper defines the observation space to be in width/height/3.

Checklist

pseudo-rnd-thoughts commented 3 months ago

Thanks for reporting the issue, could you make a PR that fixes this issue?

catanzaromj commented 3 months ago

I just ran into this issue as well. Is there a PR open for this? If not, I can try.

pseudo-rnd-thoughts commented 3 months ago

@catanzaromj There isn't a PR, if you want to make one then go for it