huawei-noah / SMARTS

Scalable Multi-Agent RL Training School for Autonomous Driving
MIT License
954 stars 190 forks source link

[Help Request] Cannot `gym.make("multi-scenario-v0")` #2123

Closed DOPEMANdd closed 10 months ago

DOPEMANdd commented 11 months ago

High Level Description

Traceback (most recent call last): File "/data/zhangdi/anaconda3/envs/smart/lib/python3.8/site-packages/gym/envs/registration.py", line 150, in spec return self.env_specs[id] KeyError: 'multi-scenario-v0'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "train_ppo.py", line 67, in env = gym.make("smarts.env:multi-scenario-v0", scenario="3lane_merge_single_agent", # 可以场景迭代 File "/data/zhangdi/anaconda3/envs/smart/lib/python3.8/site-packages/gym/envs/registration.py", line 184, in make return registry.make(id, **kwargs) File "/data/zhangdi/anaconda3/envs/smart/lib/python3.8/site-packages/gym/envs/registration.py", line 105, in make spec = self.spec(path) File "/data/zhangdi/anaconda3/envs/smart/lib/python3.8/site-packages/gym/envs/registration.py", line 167, in spec raise error.UnregisteredEnv("No registered env with id: {}".format(id)) gym.error.UnregisteredEnv: No registered env with id: multi-scenario-v0

Version

1.4

Operating System

No response

Problems

No response

Gamenot commented 11 months ago

From my understanding "multi-scenario-v0" does not exist in 1.4. Is there a particular reason why you want that environment?

Gamenot commented 11 months ago

Consider some of the following gymnasium environments:

https://github.com/huawei-noah/SMARTS/blob/366ed7e915a92087c2ff6ad7191ecf4c8f103896/smarts/env/gymnasium/__init__.py#L22-L46

These environments are located here: https://github.com/huawei-noah/SMARTS/tree/master/smarts/env/gymnasium

Gamenot commented 11 months ago

@DOPEMANdd "driving-smarts-v2022" is the most similar environment. Do note it is a gymnasium environment.

DOPEMANdd commented 11 months ago

@Gamenot Thank you for your reply, because I have been using this environment before, and now I want to use it again, but the error was reported.I will try "driving-smarts-v2022". thanks again.

DOPEMANdd commented 11 months ago

@Gamenot I have one more question: how do I convert the obs of the current dictionary type to the data type of the previous Observation wrapper. just like this: {'Agent_0': {'active': 1, 'steps_completed': 2, 'distance_travelled': 0.2, 'ego_vehicle_state': {'angular_velocity': array([-0.12299206, 1.5635582 , 0. ], dtype=float32), 'box': array([3.68, 1.47, 1.4 ], dtype=float32), 'heading': -1.4137963, 'lane_id': 'edge-west-WE_0', 'lane_index': 0, 'linear_velocity': array([11.488274 , 1.8186262, 0. ], dtype=float32), 'position': array([-74.77532766, -0.6 , 0. ]) convert to {'Agent_0': Observation(dt=0.1, step_count=169, steps_completed=1, elapsed_sim_time=17.0, events=Events(collisions=[], off_road=False, off_route=False, on_shoulder=False, wrong_way=False, not_moving=False, reached_goal=False, reached_max_episode_steps=False, agents_alive_done=False), ego_vehicle_state=EgoVehicleObservation(id='Agent_0-bc8960a9', position=array([ 8.16, -3.2 , 0. ])

Gamenot commented 11 months ago

@DOPEMANdd Sorry, just a follow-up that the scenarios that used to be in the multi-scenario are listed here:

https://github.com/huawei-noah/SMARTS/blob/6ffa83fca9dda72779b4f3e491578142164a2a45/smarts/benchmark/driving_smarts/v2022/config.yaml#L23-L31

@Gamenot I have one more question: how do I convert the obs of the current dictionary type to the data type of the previous Observation wrapper

Are using HiWayEnvV1? (because driving-smarts-v2022 should already return Observation) If you are using HiWayEnvV1, observations can be formatted or unformatted as demonstrated by the environment formatting configuration example:

https://github.com/huawei-noah/SMARTS/blob/6ffa83fca9dda72779b4f3e491578142164a2a45/examples/e4_environment_config.py#L75-L76

Unformatted will give you the Observation object style observations.

DOPEMANdd commented 11 months ago

@Gamenot thanks a lot! I will try this