rl icon indicating copy to clipboard operation
rl copied to clipboard

[BUG] torchrl doesn't support minigrid gymnasium environments

Open kbkartik opened this issue 2 years ago • 2 comments

I am trying to parallelize FourRooms minigrid environment using torchrl. Following is my code:

class MinigridGymWrapper(GymWrapper):
    """FARAMA Minigrid environment wrapper."""

    git_url = "https://github.com/Farama-Foundation/Minigrid"
    libname = "minigrid"

    _make_specs = set_gym_backend("gymnasium")(GymEnv._make_specs)

with set_gym_backend(gym):
    assert gym_backend() == gym
    print(gym_backend())
    gym_env = MinigridGymWrapper(gym.make("BabyAI-KeyCorridorS6R3-v0"))

I get the following output with error:

<module 'gymnasium' from '/usr/local/lib/python3.10/dist-packages/gymnasium/__init__.py'>

[/usr/local/lib/python3.10/dist-packages/torchrl/envs/libs/gym.py](https://localhost:8080/#) in _gym_to_torchrl_spec_transform(spec, dtype, device, categorical_action_encoding)
    264         )
    265     else:
--> 266         raise NotImplementedError(
    267             f"spec of type {type(spec).__name__} is currently unaccounted for"
    268         )

NotImplementedError: spec of type BabyAIMissionSpace is currently unaccounted for

kbkartik avatar Aug 20 '23 12:08 kbkartik

Interesting, what is a BabyAIMissionSpace exactly? Seems like something quite custom no?

vmoens avatar Sep 07 '23 17:09 vmoens

It is part of Minigrid environments (https://minigrid.farama.org/environments/babyai/)

kbkartik avatar Sep 12 '23 17:09 kbkartik

@kbkartik were you able to get MiniGrid to work with torch_rl?

Sami6720 avatar Aug 17 '24 03:08 Sami6720