HighwayEnv
HighwayEnv copied to clipboard
How to set the initial speed of ego vehicle?
According to documentation, the speed of vehicle are set in parameter DEFAULT_INITIAL_SPEEDS in class highway_env.vehicle.kinematics.Vehicle(...) that ranged from 23m/s to 25m/s, how can I set the speed of ego vehicle as a value I want?
Hi @Veronica1312,
The initial speed of a vehicle is often set in the _create_vehicles()
method of each environment, see e.g.
It is initialized differently depending on the scene, for instance in the case of highway-v0 the speed of the ego-vehicle is set to as 25 m/s https://github.com/eleurent/highway-env/blob/9d63973da854584fe51b00ccee7b24b1bf031418/highway_env/envs/highway_env.py#L58
And in the case of parking-v0, it is initialized to 0. https://github.com/eleurent/highway-env/blob/9d63973da854584fe51b00ccee7b24b1bf031418/highway_env/envs/parking_env.py#L106
For other vehicles, when the speed is not explicitely set it will be chosen from the DEFAULT_INITIAL_SPEEDS
range, but again there can be situations where we spawn vehicles at some specific speed.
So to conclude, it is currently mostly hardcoded on a case-by-case basis. It could be made configurable, but I guess the easiest way for you to change it freely is to clone this repository and edit the code directly.
Other possibility: you could set the ego-vehicle speed manually after each time the environment is reset, with:
env = gym.make(...)
env.reset()
env.vehicle.speed = <desired speed>