tkn-tub / veins-gym

Reinforcement Learning-based VANET simulations
https://www2.tkn.tu-berlin.de/software/veins-gym/
GNU General Public License v2.0
53 stars 8 forks source link

AssertionError on gym.make() with Gym Version 0.24.1 #8

Closed dstolpmann closed 2 years ago

dstolpmann commented 2 years ago

Hi, when trying to use Veins-Gym with Gym version 0.24.1, I get the following error message:

AssertionError: Observation space (None) does not inherit from gym.spaces.Space

This occurs when calling

env = gym.make("veins-v1")

right after registering Veins-Gym as an environment using:

gym.register(
    id="veins-v1",
    entry_point="veins_gym:VeinsEnv",
    kwargs={
        "scenario_dir": "scenario",
        "print_veins_stdout": True
    },
)

This issue does not occur with Gym version 0.24.0. The Gym changelog of version 0.24.1 mentions a change to the environment checker that might be the reason for this problem:

Replaced the environment checker introduced in V24, such that the environment checker will not call step and reset during make. This new version is a wrapper that will observe the data that step and reset returns on their first call and check the data against the environment checker.

As far as I understood it, Veins-Gym initializes the observation and action spaces after communicating with the Veins simulator for the first time, which happens when calling the reset() function. This method might no longer work for newer Gym versions.

It is possible to work around this problem by disabling the environment checker in the gym.make() command like this:

env = gym.make("veins-v1", disable_env_checker=True)

Best regards, Daniel

dbuse commented 2 years ago

Thanks for the note, this may also be the reason for https://github.com/tkn-tub/serpentine-env/issues/9.

I'll try to implement a fix or use your suggested workaround.