HighwayEnv
HighwayEnv copied to clipboard
Generating specific scenarios for testing
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:
-
A number of static obstacles are set up in a specific location for the driverless vehicle to avoid.
-
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 :
-
Road shape.
-
Initial position of all vehicles.
-
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!
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 :)
Get it! Thank you very much, I'll try it.
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!
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
Ok, it works! Thank you very much!
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 ?
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.