HighwayEnv
HighwayEnv copied to clipboard
Lane index and location
Let's say I'm in the middle lane, how can I get the index of the left and right lanes and the current lane first, and then how can I find out which cars are in these three lanes based on the lane index, and how to get their speed and coordinates,I noticed that the official tutorial doesn't seem to have this information, how can I get it? Thank you so much
@eleurent Thank you very much
Let's say I'm in the middle lane, how can I get the index of the left and right lanes and the current lane first
You can access the ego-vehicle's lane index with env.vehicle.lane_index
. It is a (from: str, to: str, lane: int)
tuple, and the adjacent lanes are those with the same from/to bounds but +/-1 "lane" index.
and then how can I find out which cars are in these three lanes based on the lane index
You can iterate vehicles in env.road.vehicles
and check that their lane_index
matches env.vehicle.lane_index
(+/-1 on last tuple item).
and how to get their speed and coordinates
With vehicle.speed
and vehicle.position