HighwayEnv
HighwayEnv copied to clipboard
request of adding a new scenario
May I ask if the author can add a scenario of multi-agent cooperative collision avoidance on straight roads? (The number of controlled_vehicle is more than 1)
Yes I think this is supported already, you can configure the highway-v0
env with some >1 controlled_vehicles
:
import gymnasium
env = gymnasium.make('higway-v0', config={'controlled_vehicles': 3})
See
https://github.com/Farama-Foundation/HighwayEnv/blob/81c11d6ff50a4fecf05a8341edaecfc245924e0b/highway_env/envs/highway_env.py#L35C18-L35C37
Thank you for your reply. Perhaps my expression is not very clear, I hope these vehicles have a final speed of 0, are parked on the road, and do not collide. Is there any setting here that resembles the final target speed? Or it can only be achieved by changing the reward function.
There is the parking-v0
environment which is a bit similar, where the task is to reach a goal position, heading, and speed(=0).
But it is not a multi-agent environment right now, you can only add parked vehicles as obstacles.
The highway env (with multiple controlled vehicles) and parking env (with a goal_speed=0) can probably be combined, but this requires a bit of work.
As you suggested, maybe a simple start would be to edit the highway-env's reward function: by default there is a term that rewards high speeds here:
https://github.com/Farama-Foundation/HighwayEnv/blob/81c11d6ff50a4fecf05a8341edaecfc245924e0b/highway_env/envs/highway_env.py#L132
You can probably changed it to something like -(vehicle.speed / max_vehicle_speed)**2 to incentivize driving at speed 0 instead.
You will also have to edit the environment's action config such that the minimum speed is 0 (by default the SLOW_DOWN action saturates at a min value of 20 m/s I think). Something like:
"action": {
"type": "DiscreteMetaAction",
"longitudinal": True,
"lateral": True,
"target_speeds": [0, 10, 20, 30],
},
in here:
https://github.com/Farama-Foundation/HighwayEnv/blob/81c11d6ff50a4fecf05a8341edaecfc245924e0b/highway_env/envs/highway_env.py#L30