Road#

A Road is composed of a RoadNetwork and a list of Vehicle.

The RoadNetwork describes the topology of the road infrastructure as a graph, where edges represent lanes and nodes represent intersections. It contains a graph dictionary which stores the AbstractLane geometries by their LaneIndex. A LaneIndex is a tuple containing:

  • a string identifier of a starting position

  • a string identifier of an ending position

  • an integer giving the index of the described lane, in the (unique) road from the starting to the ending position

For instance, the geometry of the second lane in the road going from the "lab" to the "pub" can be obtained by:

lane = road.road_network.graph["lab"]["pub"][1]

The actual positions of the lab and the pub are defined in the lane```geometry object.

API#

class highway_env.road.road.Road(network: RoadNetwork = None, vehicles: List[kinematics.Vehicle] = None, road_objects: List[objects.RoadObject] = None, np_random: RandomState = None, record_history: bool = False)[source]#

A road is a set of lanes, and a set of vehicles driving on these lanes.

New road.

Parameters:
  • network – the road network describing the lanes

  • vehicles – the vehicles driving on the road

  • road_objects – the objects on the road including obstacles and landmarks

  • np_random (np.random.RandomState) – a random number generator for vehicle behaviour

  • record_history – whether the recent trajectories of vehicles should be recorded for display

act() None[source]#

Decide the actions of each entity on the road.

step(dt: float) None[source]#

Step the dynamics of each entity on the road.

Parameters:

dt – timestep [s]

neighbour_vehicles(vehicle: kinematics.Vehicle, lane_index: Tuple[str, str, int] = None) Tuple[kinematics.Vehicle | None, kinematics.Vehicle | None][source]#

Find the preceding and following vehicles of a given vehicle.

Parameters:
  • vehicle – the vehicle whose neighbours must be found

  • lane_index – the lane on which to look for preceding and following vehicles. It doesn’t have to be the current vehicle lane but can also be another lane, in which case the vehicle is projected on it considering its local coordinates in the lane.

Returns:

its preceding vehicle, its following vehicle