Farama-Foundation / HighwayEnv

A minimalist environment for decision-making in autonomous driving
https://highway-env.farama.org/
MIT License
2.5k stars 728 forks source link

Ensuring no collisions among background vehicles when increasing traffic density? #520

Open xiaofutongxuo opened 9 months ago

xiaofutongxuo commented 9 months ago

Hello,

Recently, I've been experimenting with the intersection and roundabout environments, specifically aiming to conduct reinforcement learning training under varying traffic densities. To achieve this, I tried increasing the number of vehicles in the environment, hoping to simulate a heavier traffic scenario.

However, I observed that as I increase the number of background vehicles, they tend to collide with each other more frequently. This in turn affects the training of the ego vehicle, as the background vehicle collisions create an unrealistic driving scenario.

In real-world road conditions, drivers typically avoid collisions and ensure safe driving. I'd love to replicate a similar scenario in this simulation environment.

Could you offer any methods or suggestions on how to ensure that background vehicles do not collide with each other while maintaining increased traffic density, thereby providing a more realistic training scenario for the ego vehicle?

Thank you so much for your time and consideration. I look forward to your response!

Best regards!

potatohhs commented 9 months ago

It seems that we are doing the similar research luckily. For the problem, generally speaking, the IDMVehicle module can avoid collisions. Shall we talk about it with email?

eleurent commented 9 months ago

Hi @xiaofutongxuo,

Yes I have noticed this issue as well. The IDM / MOBIL models are guaranteed to avoid collisions I think, but they only apply to straight roads and but not to any other road network configuration (merge, intersection, roundabout, etc.).

I think it would be quite difficult to find a perfect collision avoidance policy (as difficult as writing a working L5 autonomous driving software, really), and for my own work I was focusing on accounting for the effect of social interactions, so I didnt need the simulator to be fully realistic...

I mentioned this issue in the docs, and I welcome any PR that would improve the realism of the simulator without degrading the computing time too much.

Finally, there is a trick that I used when working with high-density scenarios: simply disable collision checks for all but controlled vehicles, meaning controlled vehicle will collide with all other vehicles, but other vehicles will not collide between themselves.

Here is an example where this is implemented:

https://github.com/Farama-Foundation/HighwayEnv/blob/86320a3197bc622700bad1145a5b96f439c2c234/highway_env/envs/highway_env.py#L145

xiaofutongxuo commented 9 months ago

It seems that we are doing the similar research luckily. For the problem, generally speaking, the IDMVehicle module can avoid collisions. Shall we talk about it with email?

Of course! My email address is 2022224122@chd.edu.cn

xiaofutongxuo commented 9 months ago

Big thanks for getting back to me! @eleurent

I think it would be quite difficult to find a perfect collision avoidance policy (as difficult as writing a working L5 autonomous driving software, really), and for my own work I was focusing on accounting for the effect of social interactions, so I didnt need the simulator to be fully realistic...

I’ve got a few thoughts about the aforementioned points and I'm not sure if they’re feasible:

eleurent commented 9 months ago

Real-world Traffic Data: I've noticed that the vehicles can't always completely avoid obstacles in the simulations. This got me thinking - could we incorporate real-world traffic data into the environment, since actual human driving doesn't involve collisions (well, most of the time)? Could this work, or is there another way to implement it?

Maybe this would be suitable for some specific use case, but not for the focus of highway-env which is modelling social interactions behind vehicles. That is, if the autonomous vehicle takes a decision, it needs to understand that (and how) it will impact others, and take it into account while planning. When replaying traffic data, other vehicles do not adapt to what the ego-vehicle does, it would be like driving while being invisible to other traffic participants, which is difficult and dangerous.

Mixing It Up with Other Simulator: I stumbled upon a paper where the authors used CARLA and highway-env together for joint simulations(in the 23rd reference of the paper, they cited one of your articles). Unfortunately, they didn't share the specifics. Have you come across something like this, or have any tips on connecting highway-env with other simulation environments like CARLA?

The point of highway-env is also to be simple and minimalist. If you're going to use something fancier like CARLA, you might as well use it on its own :)