Farama-Foundation / HighwayEnv

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

Generating specific scenarios for testing #148

Closed xph123123 closed 1 year ago

xph123123 commented 3 years ago

Hello, thank you very much for providing such a wonderful environment for reinforcement learning autonomous driving training. I have achieved good training results in your highway-env. Now I want to test my reinforcement learning model for some specific traffic conditions, but I don't know how to generate such scenarios like:

  1. A number of static obstacles are set up in a specific location for the driverless vehicle to avoid.

  2. Make the environment vehicle in the side lane cut in and block in front of the driverless vehicle suddenly.

I wish I could set it up like Prescan, such as :

  1. Road shape.

  2. Initial position of all vehicles.

  3. The driving track of the environment vehicle, as well as the driving speed and acceleration in each section of the track.

I don't know if it can be implemented in highway env. If so, how to set it? looking forward to your answer!

eleurent commented 3 years ago

Hi @xph123123 In order to implement specific scenarios, the best would be to create new environments according to your need. See the documentation about that: https://highway-env.readthedocs.io/en/latest/make_your_own.html

So, while it requires a little bit of work, it should all be possible right now in a few llines of code. Please feel free to ask if you struggle to get the result that you wish :)

xph123123 commented 3 years ago

Get it! Thank you very much, I'll try it.

xph123123 commented 3 years ago

Hi @eleurent, When I only set up two obstacle cars(the original number is 40) in the environment, the visual interface refreshes too fast, I have no time to observe what happens. Is this because the amount of calculation for each step of environment update and rendering is less? How can I achieve the normal playback speed when I have two environment vehicles? Looking forward to your reply!

eleurent commented 3 years ago

Yes, that is probably why. You can do: env.configure({"real_time_rendering": True})

EDIT: Or set this value in the env's default_config() method

xph123123 commented 3 years ago

Ok, it works! Thank you very much!

xph123123 commented 3 years ago

Hello @eleurent,I have another question. After the neural network generates discrete decision, I want to plan the trajectory by myself, and then make the vehicle track it. I want to ask whether the highway env has the function of controlling the vehicle to track a given trajectory ?

eleurent commented 3 years ago

Hey, Currently, what is implemented is :

So there are only some small changes required to get to what you need.