Toni-SM / skrl

Modular reinforcement learning library (on PyTorch and JAX) with support for NVIDIA Isaac Gym, Omniverse Isaac Gym and Isaac Lab
https://skrl.readthedocs.io/
MIT License
445 stars 43 forks source link

Example Pendulum-v0 deprecated for gym 0.21.0+ #3

Closed simonbogh closed 2 years ago

simonbogh commented 2 years ago

Running the first OpenAI Pendulum-v0 example from the documentation gives a deprecation error. https://skrl.readthedocs.io/en/latest/intro/examples.html

Error gym.error.DeprecatedEnv: Env Pendulum-v0 not found (valid versions include ['Pendulum-v1'])

It looks like it has been renamed to Pendulum-v1 in gym v0.21.0. https://github.com/openai/gym/commit/d199778b9eb06c1370af65a1326238de2ab36746#diff-4fc33321bcd3c321db321c28fee8b7ae2b0101d0e24c2d5d4d911ae647061110

Workaround for now, change to Pendulum-v1 in line 49 of the example: env = gym.make("Pendulum-v0") if gym v0.21.0 or later.

Tested on:

Toni-SM commented 2 years ago

Hi @simonbogh

Now, OpenAI Gym examples use the following code to ensure compatibility between versions

try:
    env = gym.make("Pendulum-v1")
except gym.error.DeprecatedEnv as e:
    env_id = [spec.id for spec in gym.envs.registry.all() if spec.id.startswith("Pendulum-v")][0]
    print("Pendulum-v1 not found. Trying {}".format(env_id))
    env = gym.make(env_id)