Road regulation¶
A RegulatedRoad
is a Road
in which the behavior of vehicles take or give the right of way at an intersection based on the priority
lane attribute.
On such a road, some rules are enforced:
most of the time, vehicles behave as usual;
however, they try to predict collisions with other vehicles through the
is_conflict_possible()
method;when it is the case, right of way is arbitrated through the
respect_priorities()
method, and the yielding vehicle target velocity is set to 0 until the conflict is resolved.
API¶
-
class
highway_env.road.regulation.
RegulatedRoad
(network: highway_env.road.road.RoadNetwork = None, vehicles: List[highway_env.vehicle.kinematics.Vehicle] = None, obstacles: List[highway_env.road.objects.Obstacle] = None, np_random: numpy.random.mtrand.RandomState = None, record_history: bool = False)[source]¶ -
YIELDING_COLOR
: Tuple[float, float, float] = None¶
-
REGULATION_FREQUENCY
: int = 2¶
-
YIELD_DURATION
: float = 0.0¶
-
__init__
(network: highway_env.road.road.RoadNetwork = None, vehicles: List[highway_env.vehicle.kinematics.Vehicle] = None, obstacles: List[highway_env.road.objects.Obstacle] = None, np_random: numpy.random.mtrand.RandomState = None, record_history: bool = False) → None[source]¶ 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
-
step
(dt: float) → None[source]¶ Step the dynamics of each entity on the road.
- Parameters
dt – timestep [s]
-
enforce_road_rules
() → None[source]¶ Find conflicts and resolve them by assigning yielding vehicles and stopping them.
-
static
respect_priorities
(v1: highway_env.vehicle.kinematics.Vehicle, v2: highway_env.vehicle.kinematics.Vehicle) → highway_env.vehicle.kinematics.Vehicle[source]¶ Resolve a conflict between two vehicles by determining who should yield
- Parameters
v1 – first vehicle
v2 – second vehicle
- Returns
the yielding vehicle
-
static
is_conflict_possible
(v1: highway_env.vehicle.controller.ControlledVehicle, v2: highway_env.vehicle.controller.ControlledVehicle, horizon: int = 3, step: float = 0.25) → bool[source]¶
-
__annotations__
= {'REGULATION_FREQUENCY': <class 'int'>, 'YIELDING_COLOR': typing.Tuple[float, float, float], 'YIELD_DURATION': <class 'float'>}¶
-
__module__
= 'highway_env.road.regulation'¶
-