HighwayEnv icon indicating copy to clipboard operation
HighwayEnv copied to clipboard

Generating specific scenarios for testing

Open xph123123 opened this issue 3 years ago • 7 comments

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!

xph123123 avatar Mar 20 '21 07:03 xph123123

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

  • The road shape can be constructed by combining lanes with some given geometries, such as straight, circle, and sine. Each lane have a speed limit which can be used as the default target speed for other vehicles.
  • Static obstacles can be added through the Obstacle class, see e.g. in the Merge environment
  • Initial positions of vehicles can be set manually as well
  • Some events can be scripted in the env.step() method, such as a vehicle changing target lane / target speed etc.
  • The driving track of the environment vehicle can be chosen through the "route" attribute, which is a list of the desired road segments to follow.

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 :)

eleurent avatar Mar 20 '21 18:03 eleurent

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

xph123123 avatar Mar 21 '21 02:03 xph123123

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!

xph123123 avatar Apr 07 '21 09:04 xph123123

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

eleurent avatar Apr 07 '21 09:04 eleurent

Ok, it works! Thank you very much!

xph123123 avatar Apr 07 '21 12:04 xph123123

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 ?

xph123123 avatar Apr 08 '21 06:04 xph123123

Hey, Currently, what is implemented is :

  • a lateral position controller, which takes a Lane as input and outputs a steering angle that tracks the lane centerline. This could be adapted to track any curve, provided that you can compute the lateral distance from the vehicle to the curve
  • a speed controller, which takes a desired speed as input and outputs a gaz/throttle control. To track a position instead, the longitudinal error must be converted to a speed command by another controller.

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

eleurent avatar Apr 10 '21 11:04 eleurent