diff --git a/main/_images/index_1_1.png b/main/_images/index_1_1.png
index 2305a8001..3bef64f49 100644
Binary files a/main/_images/index_1_1.png and b/main/_images/index_1_1.png differ
diff --git a/main/_images/index_2_1.png b/main/_images/index_2_1.png
index 5e3999c05..5d3ad8690 100644
Binary files a/main/_images/index_2_1.png and b/main/_images/index_2_1.png differ
diff --git a/main/_images/index_2_2.png b/main/_images/index_2_2.png
index 68abc4462..6ac57ea96 100644
Binary files a/main/_images/index_2_2.png and b/main/_images/index_2_2.png differ
diff --git a/main/_images/index_2_3.png b/main/_images/index_2_3.png
index dbf22d721..f2f502838 100644
Binary files a/main/_images/index_2_3.png and b/main/_images/index_2_3.png differ
diff --git a/main/_images/index_3_1.png b/main/_images/index_3_1.png
index 60fe7fb94..a62e201dc 100644
Binary files a/main/_images/index_3_1.png and b/main/_images/index_3_1.png differ
diff --git a/main/_images/multi_agent_0_1.png b/main/_images/multi_agent_0_1.png
index 282a26e59..86024bbfd 100644
Binary files a/main/_images/multi_agent_0_1.png and b/main/_images/multi_agent_0_1.png differ
diff --git a/main/_images/multi_agent_1_1.png b/main/_images/multi_agent_1_1.png
index e77ef386e..c25e1b1bf 100644
Binary files a/main/_images/multi_agent_1_1.png and b/main/_images/multi_agent_1_1.png differ
diff --git a/main/_images/quickstart_0_3.png b/main/_images/quickstart_0_3.png
index 7638c9224..d757195cc 100644
Binary files a/main/_images/quickstart_0_3.png and b/main/_images/quickstart_0_3.png differ
diff --git a/main/_images/quickstart_2_0.png b/main/_images/quickstart_2_0.png
index 0837433e9..b30031b24 100644
Binary files a/main/_images/quickstart_2_0.png and b/main/_images/quickstart_2_0.png differ
diff --git a/main/_modules/highway_env/__init__/index.html b/main/_modules/highway_env/__init__/index.html
index 03f0ee27c..4f3578e75 100644
--- a/main/_modules/highway_env/__init__/index.html
+++ b/main/_modules/highway_env/__init__/index.html
@@ -291,10 +291,22 @@
Source code for highway_env.__init__
-# Hide pygame support prompt
-import os
-os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = '1'
+import os
+import sys
+__version__ = "1.8.2"
+
+try:
+ from farama_notifications import notifications
+
+ if "highway_env" in notifications and __version__ in notifications["gymnasium"]:
+ print(notifications["highway_env"][__version__], file=sys.stderr)
+
+except Exception: # nosec
+ pass
+
+# Hide pygame support prompt
+os.environ["PYGAME_HIDE_SUPPORT_PROMPT"] = "1"
from gymnasium.envs.registration import register
@@ -306,96 +318,89 @@ Source code for highway_env.__init__
# exit_env.py
register(
- id='exit-v0',
- entry_point='highway_env.envs:ExitEnv',
+ id="exit-v0",
+ entry_point="highway_env.envs:ExitEnv",
)
# highway_env.py
register(
- id='highway-v0',
- entry_point='highway_env.envs:HighwayEnv',
+ id="highway-v0",
+ entry_point="highway_env.envs:HighwayEnv",
)
register(
- id='highway-fast-v0',
- entry_point='highway_env.envs:HighwayEnvFast',
+ id="highway-fast-v0",
+ entry_point="highway_env.envs:HighwayEnvFast",
)
# intersection_env.py
register(
- id='intersection-v0',
- entry_point='highway_env.envs:IntersectionEnv',
+ id="intersection-v0",
+ entry_point="highway_env.envs:IntersectionEnv",
)
register(
- id='intersection-v1',
- entry_point='highway_env.envs:ContinuousIntersectionEnv',
+ id="intersection-v1",
+ entry_point="highway_env.envs:ContinuousIntersectionEnv",
)
register(
- id='intersection-multi-agent-v0',
- entry_point='highway_env.envs:MultiAgentIntersectionEnv',
+ id="intersection-multi-agent-v0",
+ entry_point="highway_env.envs:MultiAgentIntersectionEnv",
)
register(
- id='intersection-multi-agent-v1',
- entry_point='highway_env.envs:TupleMultiAgentIntersectionEnv',
+ id="intersection-multi-agent-v1",
+ entry_point="highway_env.envs:TupleMultiAgentIntersectionEnv",
)
# lane_keeping_env.py
register(
- id='lane-keeping-v0',
- entry_point='highway_env.envs:LaneKeepingEnv',
- max_episode_steps=200
+ id="lane-keeping-v0",
+ entry_point="highway_env.envs:LaneKeepingEnv",
+ max_episode_steps=200,
)
# merge_env.py
register(
- id='merge-v0',
- entry_point='highway_env.envs:MergeEnv',
+ id="merge-v0",
+ entry_point="highway_env.envs:MergeEnv",
)
# parking_env.py
register(
- id='parking-v0',
- entry_point='highway_env.envs:ParkingEnv',
+ id="parking-v0",
+ entry_point="highway_env.envs:ParkingEnv",
)
register(
- id='parking-ActionRepeat-v0',
- entry_point='highway_env.envs:ParkingEnvActionRepeat'
+ id="parking-ActionRepeat-v0",
+ entry_point="highway_env.envs:ParkingEnvActionRepeat",
)
register(
- id='parking-parked-v0',
- entry_point='highway_env.envs:ParkingEnvParkedVehicles'
+ id="parking-parked-v0", entry_point="highway_env.envs:ParkingEnvParkedVehicles"
)
# racetrack_env.py
register(
- id='racetrack-v0',
- entry_point='highway_env.envs:RacetrackEnv',
+ id="racetrack-v0",
+ entry_point="highway_env.envs:RacetrackEnv",
)
# roundabout_env.py
register(
- id='roundabout-v0',
- entry_point='highway_env.envs:RoundaboutEnv',
+ id="roundabout-v0",
+ entry_point="highway_env.envs:RoundaboutEnv",
)
# two_way_env.py
register(
- id='two-way-v0',
- entry_point='highway_env.envs:TwoWayEnv',
- max_episode_steps=15
+ id="two-way-v0", entry_point="highway_env.envs:TwoWayEnv", max_episode_steps=15
)
# u_turn_env.py
- register(
- id='u-turn-v0',
- entry_point='highway_env.envs:UTurnEnv'
- )
-
+ register(id="u-turn-v0", entry_point="highway_env.envs:UTurnEnv")
diff --git a/main/_modules/highway_env/envs/common/abstract/index.html b/main/_modules/highway_env/envs/common/abstract/index.html
index 7fc38100e..7f4ec3638 100644
--- a/main/_modules/highway_env/envs/common/abstract/index.html
+++ b/main/_modules/highway_env/envs/common/abstract/index.html
@@ -293,20 +293,19 @@
import copy
import os
-from typing import List, Tuple, Optional, Callable, TypeVar, Generic, Union, Dict, Text
+from typing import Dict, List, Optional, Text, Tuple, TypeVar
+
import gymnasium as gym
+import numpy as np
from gymnasium import Wrapper
from gymnasium.wrappers import RecordVideo
-from gymnasium.utils import seeding
-import numpy as np
from highway_env import utils
-from highway_env.envs.common.action import action_factory, Action, DiscreteMetaAction, ActionType
-from highway_env.envs.common.observation import observation_factory, ObservationType
+from highway_env.envs.common.action import Action, ActionType, action_factory
from highway_env.envs.common.finite_mdp import finite_mdp
from highway_env.envs.common.graphics import EnvViewer
-from highway_env.vehicle.behavior import IDMVehicle, LinearVehicle
-from highway_env.vehicle.controller import MDPVehicle
+from highway_env.envs.common.observation import ObservationType, observation_factory
+from highway_env.vehicle.behavior import IDMVehicle
from highway_env.vehicle.kinematics import Vehicle
Observation = TypeVar("Observation")
@@ -323,11 +322,12 @@ Source code for highway_env.envs.common.abstract
speed. The action space is fixed, but the observation space and reward function must be defined in the
environment implementations.
"""
+
observation_type: ObservationType
action_type: ActionType
_record_video_wrapper: Optional[RecordVideo]
metadata = {
-
'render_modes': ['human', 'rgb_array'],
+
"render_modes": ["human", "rgb_array"],
}
PERCEPTION_DISTANCE = 5.0 * Vehicle.MAX_SPEED
@@ -386,12 +386,8 @@
Source code for highway_env.envs.common.abstract
:return: a configuration dict
"""
return {
-
"observation": {
-
"type": "Kinematics"
-
},
-
"action": {
-
"type": "DiscreteMetaAction"
-
},
+
"observation": {"type": "Kinematics"},
+
"action": {"type": "DiscreteMetaAction"},
"simulation_frequency": 15, # [Hz]
"policy_frequency": 1, # [Hz]
"other_vehicles_type": "highway_env.vehicle.behavior.IDMVehicle",
@@ -403,7 +399,7 @@
Source code for highway_env.envs.common.abstract
"render_agent": True,
"offscreen_rendering": os.environ.get("OFFSCREEN_RENDERING", "0") == "1",
"manual_control": False,
- "real_time_rendering": False
+ "real_time_rendering": False,
}
@@ -412,9 +408,12 @@
Source code for highway_env.envs.common.abstract
self.config.update(config)
def update_metadata(self, video_real_time_ratio=2):
-
frames_freq = self.config["simulation_frequency"] \
-
if self._record_video_wrapper else self.config["policy_frequency"]
-
self.metadata['render_fps'] = video_real_time_ratio * frames_freq
+
frames_freq = (
+
self.config["simulation_frequency"]
+
if self._record_video_wrapper
+
else self.config["policy_frequency"]
+
)
+
self.metadata["render_fps"] = video_real_time_ratio * frames_freq
[docs]
@@ -501,10 +500,11 @@
Source code for highway_env.envs.common.abstract
[docs]
-
def reset(self,
-
*,
-
seed: Optional[int] = None,
-
options: Optional[dict] = None,
+
def reset(
+
self,
+
*,
+
seed: Optional[int] = None,
+
options: Optional[dict] = None,
) -> Tuple[Observation, dict]:
"""
Reset the environment to it's initial configuration
@@ -524,7 +524,7 @@
Source code for highway_env.envs.common.abstract
self.define_spaces() # Second, to link the obs and actions to the vehicles once the scene is created
obs = self.observation_type.observe()
info = self._info(obs, action=self.action_space.sample())
- if self.render_mode == 'human':
+ if self.render_mode == "human":
self.render()
return obs, info
@@ -553,7 +553,9 @@
Source code for highway_env.envs.common.abstract
:return: a tuple (observation, reward, terminated, truncated, info)
"""
if self.road is None or self.vehicle is None:
-
raise NotImplementedError("The road and vehicle must be initialized in the environment implementation")
+
raise NotImplementedError(
+
"The road and vehicle must be initialized in the environment implementation"
+
)
self.time += 1 / self.config["policy_frequency"]
self._simulate(action)
@@ -563,7 +565,7 @@
Source code for highway_env.envs.common.abstract
terminated = self._is_terminated()
truncated = self._is_truncated()
info = self._info(obs, action)
- if self.render_mode == 'human':
+ if self.render_mode == "human":
self.render()
return obs, reward, terminated, truncated, info
@@ -573,12 +575,21 @@
Source code for highway_env.envs.common.abstract
[docs]
def _simulate(self, action: Optional[Action] = None) -> None:
"""Perform several steps of simulation with constant action."""
-
frames = int(self.config["simulation_frequency"] // self.config["policy_frequency"])
+
frames = int(
+
self.config["simulation_frequency"] // self.config["policy_frequency"]
+
)
for frame in range(frames):
# Forward action to the vehicle
-
if action is not None \
-
and not self.config["manual_control"] \
-
and self.steps % int(self.config["simulation_frequency"] // self.config["policy_frequency"]) == 0:
+
if (
+
action is not None
+
and not self.config["manual_control"]
+
and self.steps
+
% int(
+
self.config["simulation_frequency"]
+
// self.config["policy_frequency"]
+
)
+
== 0
+
):
self.action_type.act(action)
self.road.act()
@@ -587,7 +598,9 @@
Source code for highway_env.envs.common.abstract
# Automatically render intermediate simulation steps if a viewer has been launched
# Ignored if the rendering is done offscreen
- if frame < frames - 1: # Last frame will be rendered through env.render() as usual
+ if (
+ frame < frames - 1
+ ): # Last frame will be rendered through env.render() as usual
self._automatic_rendering()
self.enable_auto_render = False
@@ -618,7 +631,7 @@
Source code for highway_env.envs.common.abstract
if not self.viewer.offscreen:
self.viewer.handle_events()
- if self.render_mode == 'rgb_array':
+ if self.render_mode == "rgb_array":
image = self.viewer.get_image()
return image
@@ -654,7 +667,6 @@
Source code for highway_env.envs.common.abstract
If a RecordVideo wrapper has been set, use it to capture intermediate frames.
"""
if self.viewer is not None and self.enable_auto_render:
-
if self._record_video_wrapper and self._record_video_wrapper.video_recorder:
self._record_video_wrapper.video_recorder.capture_frame()
else:
@@ -663,7 +675,7 @@
Source code for highway_env.envs.common.abstract
[docs]
-
def simplify(self) -> 'AbstractEnv':
+
def simplify(self) -> "AbstractEnv":
"""
Return a simplified copy of the environment where distant vehicles have been removed from the road.
@@ -672,15 +684,18 @@
Source code for highway_env.envs.common.abstract
:return: a simplified environment state
"""
state_copy = copy.deepcopy(self)
- state_copy.road.vehicles = [state_copy.vehicle] + state_copy.road.close_vehicles_to(
- state_copy.vehicle, self.PERCEPTION_DISTANCE)
+ state_copy.road.vehicles = [
+ state_copy.vehicle
+ ] + state_copy.road.close_vehicles_to(
+ state_copy.vehicle, self.PERCEPTION_DISTANCE
+ )
return state_copy
[docs]
-
def change_vehicles(self, vehicle_class_path: str) -> 'AbstractEnv':
+
def change_vehicles(self, vehicle_class_path: str) -> "AbstractEnv":
"""
Change the type of all vehicles on the road
@@ -698,7 +713,7 @@
Source code for highway_env.envs.common.abstract
return env_copy
-
def set_preferred_lane(self, preferred_lane: int = None) -> 'AbstractEnv':
+
def set_preferred_lane(self, preferred_lane: int = None) -> "AbstractEnv":
env_copy = copy.deepcopy(self)
if preferred_lane:
for v in env_copy.road.vehicles:
@@ -708,14 +723,14 @@
Source code for highway_env.envs.common.abstract
v.LANE_CHANGE_MAX_BRAKING_IMPOSED = 1000
return env_copy
-
def set_route_at_intersection(self, _to: str) -> 'AbstractEnv':
+
def set_route_at_intersection(self, _to: str) -> "AbstractEnv":
env_copy = copy.deepcopy(self)
for v in env_copy.road.vehicles:
if isinstance(v, IDMVehicle):
v.set_route_at_intersection(_to)
return env_copy
-
def set_vehicle_field(self, args: Tuple[str, object]) -> 'AbstractEnv':
+
def set_vehicle_field(self, args: Tuple[str, object]) -> "AbstractEnv":
field, value = args
env_copy = copy.deepcopy(self)
for v in env_copy.road.vehicles:
@@ -723,7 +738,7 @@
Source code for highway_env.envs.common.abstract
setattr(v, field, value)
return env_copy
-
def call_vehicle_method(self, args: Tuple[str, Tuple[object]]) -> 'AbstractEnv':
+
def call_vehicle_method(self, args: Tuple[str, Tuple[object]]) -> "AbstractEnv":
method, method_args = args
env_copy = copy.deepcopy(self)
for i, v in enumerate(env_copy.road.vehicles):
@@ -731,7 +746,7 @@
Source code for highway_env.envs.common.abstract
env_copy.road.vehicles[i] = getattr(v, method)(*method_args)
return env_copy
-
def randomize_behavior(self) -> 'AbstractEnv':
+
def randomize_behavior(self) -> "AbstractEnv":
env_copy = copy.deepcopy(self)
for v in env_copy.road.vehicles:
if isinstance(v, IDMVehicle):
@@ -739,7 +754,7 @@
Source code for highway_env.envs.common.abstract
return env_copy
def to_finite_mdp(self):
-
return finite_mdp(self, time_quantization=1/self.config["policy_frequency"])
+
return finite_mdp(self, time_quantization=1 / self.config["policy_frequency"])
def __deepcopy__(self, memo):
"""Perform a deep copy but without copying the environment viewer."""
@@ -747,7 +762,7 @@
Source code for highway_env.envs.common.abstract
result = cls.__new__(cls)
memo[id(self)] = result
for k, v in self.__dict__.items():
-
if k not in ['viewer', '_record_video_wrapper']:
+
if k not in ["viewer", "_record_video_wrapper"]:
setattr(result, k, copy.deepcopy(v, memo))
else:
setattr(result, k, None)
diff --git a/main/_modules/highway_env/envs/common/action/index.html b/main/_modules/highway_env/envs/common/action/index.html
index 06f554b63..ed9b9c138 100644
--- a/main/_modules/highway_env/envs/common/action/index.html
+++ b/main/_modules/highway_env/envs/common/action/index.html
@@ -293,16 +293,16 @@
Source code for highway_env.envs.common.action
import functools
import itertools
-from typing import TYPE_CHECKING, Optional, Union, Tuple, Callable, List
-from gymnasium import spaces
+from typing import TYPE_CHECKING, Callable, List, Optional, Tuple, Union
+
import numpy as np
+from gymnasium import spaces
from highway_env import utils
from highway_env.utils import Vector
-from highway_env.vehicle.behavior import IDMVehicle
+from highway_env.vehicle.controller import MDPVehicle
from highway_env.vehicle.dynamics import BicycleVehicle
from highway_env.vehicle.kinematics import Vehicle
-from highway_env.vehicle.controller import MDPVehicle
if TYPE_CHECKING:
from highway_env.envs.common.abstract import AbstractEnv
@@ -316,7 +316,7 @@ Source code for highway_env.envs.common.action
"""A type of action specifies its definition space, and how actions are executed in the environment"""
- def __init__(self, env: 'AbstractEnv', **kwargs) -> None:
+ def __init__(self, env: "AbstractEnv", **kwargs) -> None:
self.env = env
self.__controlled_vehicle = None
@@ -391,16 +391,18 @@
Source code for highway_env.envs.common.action
STEERING_RANGE = (-np.pi / 4, np.pi / 4)
"""Steering angle range: [-x, x], in rad."""
- def __init__(self,
- env: 'AbstractEnv',
- acceleration_range: Optional[Tuple[float, float]] = None,
- steering_range: Optional[Tuple[float, float]] = None,
- speed_range: Optional[Tuple[float, float]] = None,
- longitudinal: bool = True,
- lateral: bool = True,
- dynamical: bool = False,
- clip: bool = True,
- **kwargs) -> None:
+ def __init__(
+ self,
+ env: "AbstractEnv",
+ acceleration_range: Optional[Tuple[float, float]] = None,
+ steering_range: Optional[Tuple[float, float]] = None,
+ speed_range: Optional[Tuple[float, float]] = None,
+ longitudinal: bool = True,
+ lateral: bool = True,
+ dynamical: bool = False,
+ clip: bool = True,
+ **kwargs
+ ) -> None:
"""
Create a continuous action space.
@@ -414,13 +416,17 @@
Source code for highway_env.envs.common.action
:param clip: clip action to the defined range
"""
super().__init__(env)
- self.acceleration_range = acceleration_range if acceleration_range else self.ACCELERATION_RANGE
+ self.acceleration_range = (
+ acceleration_range if acceleration_range else self.ACCELERATION_RANGE
+ )
self.steering_range = steering_range if steering_range else self.STEERING_RANGE
self.speed_range = speed_range
self.lateral = lateral
self.longitudinal = longitudinal
if not self.lateral and not self.longitudinal:
- raise ValueError("Either longitudinal and/or lateral control must be enabled")
+ raise ValueError(
+ "Either longitudinal and/or lateral control must be enabled"
+ )
self.dynamical = dynamical
self.clip = clip
self.size = 2 if self.lateral and self.longitudinal else 1
@@ -429,7 +435,7 @@
Source code for highway_env.envs.common.action
[docs]
def space(self) -> spaces.Box:
- return spaces.Box(-1., 1., shape=(self.size,), dtype=np.float32)
+
return spaces.Box(-1.0, 1.0, shape=(self.size,), dtype=np.float32)
@property
@@ -440,7 +446,10 @@
Source code for highway_env.envs.common.action
if self.clip:
action = np.clip(action, -1, 1)
if self.speed_range:
- self.controlled_vehicle.MIN_SPEED, self.controlled_vehicle.MAX_SPEED = self.speed_range
+ (
+ self.controlled_vehicle.MIN_SPEED,
+ self.controlled_vehicle.MAX_SPEED,
+ ) = self.speed_range
if self.longitudinal and self.lateral:
return {
"acceleration": utils.lmap(action[0], [-1, 1], self.acceleration_range),
@@ -454,7 +463,7 @@
Source code for highway_env.envs.common.action
elif self.lateral:
return {
"acceleration": 0,
- "steering": utils.lmap(action[0], [-1, 1], self.steering_range)
+ "steering": utils.lmap(action[0], [-1, 1], self.steering_range),
}
@@ -469,18 +478,27 @@
Source code for highway_env.envs.common.action
[docs]
class DiscreteAction(ContinuousAction):
- def __init__(self,
- env: 'AbstractEnv',
- acceleration_range: Optional[Tuple[float, float]] = None,
- steering_range: Optional[Tuple[float, float]] = None,
- longitudinal: bool = True,
- lateral: bool = True,
- dynamical: bool = False,
- clip: bool = True,
- actions_per_axis: int = 3,
- **kwargs) -> None:
- super().__init__(env, acceleration_range=acceleration_range, steering_range=steering_range,
- longitudinal=longitudinal, lateral=lateral, dynamical=dynamical, clip=clip)
+ def __init__(
+ self,
+ env: "AbstractEnv",
+ acceleration_range: Optional[Tuple[float, float]] = None,
+ steering_range: Optional[Tuple[float, float]] = None,
+ longitudinal: bool = True,
+ lateral: bool = True,
+ dynamical: bool = False,
+ clip: bool = True,
+ actions_per_axis: int = 3,
+ **kwargs
+ ) -> None:
+ super().__init__(
+ env,
+ acceleration_range=acceleration_range,
+ steering_range=steering_range,
+ longitudinal=longitudinal,
+ lateral=lateral,
+ dynamical=dynamical,
+ clip=clip,
+ )
self.actions_per_axis = actions_per_axis
@@ -508,35 +526,23 @@
Source code for highway_env.envs.common.action
An discrete action space of meta-actions: lane changes, and cruise control set-point.
"""
- ACTIONS_ALL = {
- 0: 'LANE_LEFT',
- 1: 'IDLE',
- 2: 'LANE_RIGHT',
- 3: 'FASTER',
- 4: 'SLOWER'
- }
+ ACTIONS_ALL = {0: "LANE_LEFT", 1: "IDLE", 2: "LANE_RIGHT", 3: "FASTER", 4: "SLOWER"}
"""A mapping of action indexes to labels."""
- ACTIONS_LONGI = {
- 0: 'SLOWER',
- 1: 'IDLE',
- 2: 'FASTER'
- }
+ ACTIONS_LONGI = {0: "SLOWER", 1: "IDLE", 2: "FASTER"}
"""A mapping of longitudinal action indexes to labels."""
- ACTIONS_LAT = {
- 0: 'LANE_LEFT',
- 1: 'IDLE',
- 2: 'LANE_RIGHT'
- }
+ ACTIONS_LAT = {0: "LANE_LEFT", 1: "IDLE", 2: "LANE_RIGHT"}
"""A mapping of lateral action indexes to labels."""
- def __init__(self,
- env: 'AbstractEnv',
- longitudinal: bool = True,
- lateral: bool = True,
- target_speeds: Optional[Vector] = None,
- **kwargs) -> None:
+ def __init__(
+ self,
+ env: "AbstractEnv",
+ longitudinal: bool = True,
+ lateral: bool = True,
+ target_speeds: Optional[Vector] = None,
+ **kwargs
+ ) -> None:
"""
Create a discrete action space of meta-actions.
@@ -548,13 +554,24 @@
Source code for highway_env.envs.common.action
super().__init__(env)
self.longitudinal = longitudinal
self.lateral = lateral
- self.target_speeds = np.array(target_speeds) if target_speeds is not None else MDPVehicle.DEFAULT_TARGET_SPEEDS
- self.actions = self.ACTIONS_ALL if longitudinal and lateral \
- else self.ACTIONS_LONGI if longitudinal \
- else self.ACTIONS_LAT if lateral \
+ self.target_speeds = (
+ np.array(target_speeds)
+ if target_speeds is not None
+ else MDPVehicle.DEFAULT_TARGET_SPEEDS
+ )
+ self.actions = (
+ self.ACTIONS_ALL
+ if longitudinal and lateral
+ else self.ACTIONS_LONGI
+ if longitudinal
+ else self.ACTIONS_LAT
+ if lateral
else None
+ )
if self.actions is None:
- raise ValueError("At least longitudinal or lateral actions must be included")
+ raise ValueError(
+ "At least longitudinal or lateral actions must be included"
+ )
self.actions_indexes = {v: k for k, v in self.actions.items()}
@@ -607,10 +636,7 @@
Source code for highway_env.envs.common.action
[docs]
class MultiAgentAction(ActionType):
- def __init__(self,
- env: 'AbstractEnv',
- action_config: dict,
- **kwargs) -> None:
+ def __init__(self, env: "AbstractEnv", action_config: dict, **kwargs) -> None:
super().__init__(env)
self.action_config = action_config
self.agents_action_types = []
@@ -622,7 +648,9 @@
Source code for highway_env.envs.common.action
[docs]
def space(self) -> spaces.Space:
- return spaces.Tuple([action_type.space() for action_type in self.agents_action_types])
+
return spaces.Tuple(
+
[action_type.space() for action_type in self.agents_action_types]
+
)
@property
@@ -640,12 +668,17 @@
Source code for highway_env.envs.common.action
[docs]
def get_available_actions(self):
- return itertools.product(*[action_type.get_available_actions() for action_type in self.agents_action_types])
+
return itertools.product(
+
*[
+
action_type.get_available_actions()
+
for action_type in self.agents_action_types
+
]
+
)
-
def action_factory(env: 'AbstractEnv', config: dict) -> ActionType:
+
def action_factory(env: "AbstractEnv", config: dict) -> ActionType:
if config["type"] == "ContinuousAction":
return ContinuousAction(env, **config)
if config["type"] == "DiscreteAction":
diff --git a/main/_modules/highway_env/envs/common/graphics/index.html b/main/_modules/highway_env/envs/common/graphics/index.html
index f7d2fb32f..c81109017 100644
--- a/main/_modules/highway_env/envs/common/graphics/index.html
+++ b/main/_modules/highway_env/envs/common/graphics/index.html
@@ -293,11 +293,16 @@
Source code for highway_env.envs.common.graphics
import os
from typing import TYPE_CHECKING, Callable, List, Optional
+
import numpy as np
import pygame
-from highway_env.envs.common.action import ActionType, DiscreteMetaAction, ContinuousAction
-from highway_env.road.graphics import WorldSurface, RoadGraphics
+from highway_env.envs.common.action import (
+ ActionType,
+ ContinuousAction,
+ DiscreteMetaAction,
+)
+from highway_env.road.graphics import RoadGraphics, WorldSurface
from highway_env.vehicle.graphics import VehicleGraphics
if TYPE_CHECKING:
@@ -314,7 +319,7 @@ Source code for highway_env.envs.common.graphics
SAVE_IMAGES = False
agent_display = None
-
def __init__(self, env: 'AbstractEnv', config: Optional[dict] = None) -> None:
+
def __init__(self, env: "AbstractEnv", config: Optional[dict] = None) -> None:
self.env = env
self.config = config or env.config
self.offscreen = self.config["offscreen_rendering"]
@@ -332,12 +337,18 @@
Source code for highway_env.envs.common.graphics
# instruction allows the drawing to be done on surfaces without
# handling a screen display, useful for e.g. cloud computing
if not self.offscreen:
-
self.screen = pygame.display.set_mode([self.config["screen_width"], self.config["screen_height"]])
+
self.screen = pygame.display.set_mode(
+
[self.config["screen_width"], self.config["screen_height"]]
+
)
if self.agent_display:
self.extend_display()
self.sim_surface = WorldSurface(panel_size, 0, pygame.Surface(panel_size))
-
self.sim_surface.scaling = self.config.get("scaling", self.sim_surface.INITIAL_SCALING)
-
self.sim_surface.centering_position = self.config.get("centering_position", self.sim_surface.INITIAL_CENTERING)
+
self.sim_surface.scaling = self.config.get(
+
"scaling", self.sim_surface.INITIAL_SCALING
+
)
+
self.sim_surface.centering_position = self.config.get(
+
"centering_position", self.sim_surface.INITIAL_CENTERING
+
)
self.clock = pygame.time.Clock()
self.enabled = True
@@ -362,16 +373,20 @@
Source code for highway_env.envs.common.graphics
def extend_display(self) -> None:
if not self.offscreen:
if self.config["screen_width"] > self.config["screen_height"]:
-
self.screen = pygame.display.set_mode((self.config["screen_width"],
-
2 * self.config["screen_height"]))
+
self.screen = pygame.display.set_mode(
+
(self.config["screen_width"], 2 * self.config["screen_height"])
+
)
else:
-
self.screen = pygame.display.set_mode((2 * self.config["screen_width"],
-
self.config["screen_height"]))
-
self.agent_surface = pygame.Surface((self.config["screen_width"], self.config["screen_height"]))
+
self.screen = pygame.display.set_mode(
+
(2 * self.config["screen_width"], self.config["screen_height"])
+
)
+
self.agent_surface = pygame.Surface(
+
(self.config["screen_width"], self.config["screen_height"])
+
)
[docs]
-
def set_agent_action_sequence(self, actions: List['Action']) -> None:
+
def set_agent_action_sequence(self, actions: List["Action"]) -> None:
"""
Set the sequence of actions chosen by the agent, so that it can be displayed
@@ -382,10 +397,12 @@
Source code for highway_env.envs.common.graphics
elif isinstance(self.env.action_type, ContinuousAction):
actions = [self.env.action_type.get_action(a) for a in actions]
if len(actions) > 1:
- self.vehicle_trajectory = self.env.vehicle.predict_trajectory(actions,
- 1 / self.env.config["policy_frequency"],
- 1 / 3 / self.env.config["policy_frequency"],
- 1 / self.env.config["simulation_frequency"])
+
self.vehicle_trajectory = self.env.vehicle.predict_trajectory(
+
actions,
+
1 / self.env.config["policy_frequency"],
+
1 / 3 / self.env.config["policy_frequency"],
+
1 / self.env.config["simulation_frequency"],
+
)
@@ -412,29 +429,31 @@
Source code for highway_env.envs.common.graphics
if self.vehicle_trajectory:
VehicleGraphics.display_trajectory(
-
self.vehicle_trajectory,
-
self.sim_surface,
-
offscreen=self.offscreen)
+
self.vehicle_trajectory, self.sim_surface, offscreen=self.offscreen
+
)
RoadGraphics.display_road_objects(
-
self.env.road,
-
self.sim_surface,
-
offscreen=self.offscreen
+
self.env.road, self.sim_surface, offscreen=self.offscreen
)
if EnvViewer.agent_display:
EnvViewer.agent_display(self.agent_surface, self.sim_surface)
if not self.offscreen:
if self.config["screen_width"] > self.config["screen_height"]:
-
self.screen.blit(self.agent_surface, (0, self.config["screen_height"]))
+
self.screen.blit(
+
self.agent_surface, (0, self.config["screen_height"])
+
)
else:
-
self.screen.blit(self.agent_surface, (self.config["screen_width"], 0))
+
self.screen.blit(
+
self.agent_surface, (self.config["screen_width"], 0)
+
)
RoadGraphics.display_traffic(
self.env.road,
self.sim_surface,
simulation_frequency=self.env.config["simulation_frequency"],
-
offscreen=self.offscreen)
+
offscreen=self.offscreen,
+
)
ObservationGraphics.display(self.env.observation_type, self.sim_surface)
@@ -445,7 +464,10 @@
Source code for highway_env.envs.common.graphics
pygame.display.flip()
if self.SAVE_IMAGES and self.directory:
- pygame.image.save(self.sim_surface, str(self.directory / "highway-env_{}.png".format(self.frame)))
+ pygame.image.save(
+ self.sim_surface,
+ str(self.directory / "highway-env_{}.png".format(self.frame)),
+ )
self.frame += 1
@@ -457,7 +479,11 @@
Source code for highway_env.envs.common.graphics
Gymnasium's channel convention is H x W x C
"""
- surface = self.screen if self.config["render_agent"] and not self.offscreen else self.sim_surface
+ surface = (
+ self.screen
+ if self.config["render_agent"] and not self.offscreen
+ else self.sim_surface
+ )
data = pygame.surfarray.array3d(surface) # in W x H x C channel convention
return np.moveaxis(data, 0, 1)
@@ -485,7 +511,9 @@
Source code for highway_env.envs.common.graphics
class EventHandler(object):
@classmethod
-
def handle_event(cls, action_type: ActionType, event: pygame.event.EventType) -> None:
+
def handle_event(
+
cls, action_type: ActionType, event: pygame.event.EventType
+
) -> None:
"""
Map the pygame keyboard events to control decisions
@@ -498,7 +526,9 @@
Source code for highway_env.envs.common.graphics
cls.handle_continuous_action_event(action_type, event)
@classmethod
-
def handle_discrete_action_event(cls, action_type: DiscreteMetaAction, event: pygame.event.EventType) -> None:
+
def handle_discrete_action_event(
+
cls, action_type: DiscreteMetaAction, event: pygame.event.EventType
+
) -> None:
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_RIGHT and action_type.longitudinal:
action_type.act(action_type.actions_indexes["FASTER"])
@@ -510,7 +540,9 @@
Source code for highway_env.envs.common.graphics
action_type.act(action_type.actions_indexes["LANE_LEFT"])
@classmethod
-
def handle_continuous_action_event(cls, action_type: ContinuousAction, event: pygame.event.EventType) -> None:
+
def handle_continuous_action_event(
+
cls, action_type: ContinuousAction, event: pygame.event.EventType
+
) -> None:
action = action_type.last_action.copy()
steering_index = action_type.space().shape[0] - 1
if event.type == pygame.KEYDOWN:
@@ -540,19 +572,33 @@
Source code for highway_env.envs.common.graphics
@classmethod
def display(cls, obs, sim_surface):
from highway_env.envs.common.observation import LidarObservation
+
if isinstance(obs, LidarObservation):
cls.display_grid(obs, sim_surface)
@classmethod
def display_grid(cls, lidar_observation, surface):
- psi = np.repeat(np.arange(-lidar_observation.angle/2,
- 2 * np.pi - lidar_observation.angle/2,
- 2 * np.pi / lidar_observation.grid.shape[0]), 2)
+ psi = np.repeat(
+ np.arange(
+ -lidar_observation.angle / 2,
+ 2 * np.pi - lidar_observation.angle / 2,
+ 2 * np.pi / lidar_observation.grid.shape[0],
+ ),
+ 2,
+ )
psi = np.hstack((psi[1:], [psi[0]]))
- r = np.repeat(np.minimum(lidar_observation.grid[:, 0], lidar_observation.maximum_range), 2)
- points = [(surface.pos2pix(lidar_observation.origin[0] + r[i] * np.cos(psi[i]),
- lidar_observation.origin[1] + r[i] * np.sin(psi[i])))
- for i in range(np.size(psi))]
+ r = np.repeat(
+ np.minimum(lidar_observation.grid[:, 0], lidar_observation.maximum_range), 2
+ )
+ points = [
+ (
+ surface.pos2pix(
+ lidar_observation.origin[0] + r[i] * np.cos(psi[i]),
+ lidar_observation.origin[1] + r[i] * np.sin(psi[i]),
+ )
+ )
+ for i in range(np.size(psi))
+ ]
pygame.draw.lines(surface, ObservationGraphics.COLOR, True, points, 1)
diff --git a/main/_modules/highway_env/envs/common/observation/index.html b/main/_modules/highway_env/envs/common/observation/index.html
index 6df9d763f..33288dc47 100644
--- a/main/_modules/highway_env/envs/common/observation/index.html
+++ b/main/_modules/highway_env/envs/common/observation/index.html
@@ -293,17 +293,17 @@
Source code for highway_env.envs.common.observation
from collections import OrderedDict
from itertools import product
-from typing import List, Dict, TYPE_CHECKING, Optional, Union, Tuple
-from gymnasium import spaces
+from typing import TYPE_CHECKING, Dict, List, Optional, Tuple
+
import numpy as np
import pandas as pd
+from gymnasium import spaces
from highway_env import utils
from highway_env.envs.common.finite_mdp import compute_ttc_grid
from highway_env.envs.common.graphics import EnvViewer
from highway_env.road.lane import AbstractLane
-from highway_env.utils import distance_to_circle, Vector
-from highway_env.vehicle.controller import MDPVehicle
+from highway_env.utils import Vector
from highway_env.vehicle.kinematics import Vehicle
if TYPE_CHECKING:
@@ -311,7 +311,7 @@ Source code for highway_env.envs.common.observation
class
ObservationType(object):
-
def __init__(self, env: 'AbstractEnv', **kwargs) -> None:
+
def __init__(self, env: "AbstractEnv", **kwargs) -> None:
self.env = env
self.__observer_vehicle = None
@@ -357,28 +357,34 @@
Source code for highway_env.envs.common.observation
}
"""
-
def __init__(self, env: 'AbstractEnv',
-
observation_shape: Tuple[int, int],
-
stack_size: int,
-
weights: List[float],
-
scaling: Optional[float] = None,
-
centering_position: Optional[List[float]] = None,
-
**kwargs) -> None:
+
def __init__(
+
self,
+
env: "AbstractEnv",
+
observation_shape: Tuple[int, int],
+
stack_size: int,
+
weights: List[float],
+
scaling: Optional[float] = None,
+
centering_position: Optional[List[float]] = None,
+
**kwargs
+
) -> None:
super().__init__(env)
self.observation_shape = observation_shape
-
self.shape = (stack_size, ) + self.observation_shape
+
self.shape = (stack_size,) + self.observation_shape
self.weights = weights
self.obs = np.zeros(self.shape, dtype=np.uint8)
# The viewer configuration can be different between this observation and env.render() (typically smaller)
viewer_config = env.config.copy()
-
viewer_config.update({
-
"offscreen_rendering": True,
-
"screen_width": self.observation_shape[0],
-
"screen_height": self.observation_shape[1],
-
"scaling": scaling or viewer_config["scaling"],
-
"centering_position": centering_position or viewer_config["centering_position"]
-
})
+
viewer_config.update(
+
{
+
"offscreen_rendering": True,
+
"screen_width": self.observation_shape[0],
+
"screen_height": self.observation_shape[1],
+
"scaling": scaling or viewer_config["scaling"],
+
"centering_position": centering_position
+
or viewer_config["centering_position"],
+
}
+
)
self.viewer = EnvViewer(env, config=viewer_config)
@@ -406,34 +412,42 @@
Source code for highway_env.envs.common.observation
class
TimeToCollisionObservation(ObservationType):
-
def __init__(self, env: 'AbstractEnv', horizon: int = 10, **kwargs: dict) -> None:
+
def __init__(self, env: "AbstractEnv", horizon: int = 10, **kwargs: dict) -> None:
super().__init__(env)
self.horizon = horizon
def space(self) -> spaces.Space:
try:
-
return spaces.Box(shape=self.observe().shape, low=0, high=1, dtype=np.float32)
+
return spaces.Box(
+
shape=self.observe().shape, low=0, high=1, dtype=np.float32
+
)
except AttributeError:
return spaces.Space()
def observe(self) -> np.ndarray:
if not self.env.road:
-
return np.zeros((3, 3, int(self.horizon * self.env.config["policy_frequency"])))
-
grid = compute_ttc_grid(self.env, vehicle=self.observer_vehicle,
-
time_quantization=1/self.env.config["policy_frequency"], horizon=self.horizon)
+
return np.zeros(
+
(3, 3, int(self.horizon * self.env.config["policy_frequency"]))
+
)
+
grid = compute_ttc_grid(
+
self.env,
+
vehicle=self.observer_vehicle,
+
time_quantization=1 / self.env.config["policy_frequency"],
+
horizon=self.horizon,
+
)
padding = np.ones(np.shape(grid))
padded_grid = np.concatenate([padding, grid, padding], axis=1)
obs_lanes = 3
l0 = grid.shape[1] + self.observer_vehicle.lane_index[2] - obs_lanes // 2
lf = grid.shape[1] + self.observer_vehicle.lane_index[2] + obs_lanes // 2
-
clamped_grid = padded_grid[:, l0:lf+1, :]
+
clamped_grid = padded_grid[:, l0 : lf + 1, :]
repeats = np.ones(clamped_grid.shape[0])
repeats[np.array([0, -1])] += clamped_grid.shape[0]
padded_grid = np.repeat(clamped_grid, repeats.astype(int), axis=0)
obs_speeds = 3
v0 = grid.shape[0] + self.observer_vehicle.speed_index - obs_speeds // 2
vf = grid.shape[0] + self.observer_vehicle.speed_index + obs_speeds // 2
-
clamped_grid = padded_grid[v0:vf + 1, :, :]
+
clamped_grid = padded_grid[v0 : vf + 1, :, :]
return clamped_grid.astype(np.float32)
@@ -443,20 +457,23 @@
Source code for highway_env.envs.common.observation
"""Observe the kinematics of nearby vehicles."""
-
FEATURES: List[str] = ['presence', 'x', 'y', 'vx', 'vy']
-
-
def __init__(self, env: 'AbstractEnv',
-
features: List[str] = None,
-
vehicles_count: int = 5,
-
features_range: Dict[str, List[float]] = None,
-
absolute: bool = False,
-
order: str = "sorted",
-
normalize: bool = True,
-
clip: bool = True,
-
see_behind: bool = False,
-
observe_intentions: bool = False,
-
include_obstacles: bool = True,
-
**kwargs: dict) -> None:
+
FEATURES: List[str] = ["presence", "x", "y", "vx", "vy"]
+
+
def __init__(
+
self,
+
env: "AbstractEnv",
+
features: List[str] = None,
+
vehicles_count: int = 5,
+
features_range: Dict[str, List[float]] = None,
+
absolute: bool = False,
+
order: str = "sorted",
+
normalize: bool = True,
+
clip: bool = True,
+
see_behind: bool = False,
+
observe_intentions: bool = False,
+
include_obstacles: bool = True,
+
**kwargs: dict
+
) -> None:
"""
:param env: The environment to observe
:param features: Names of features used in the observation
@@ -484,7 +501,12 @@
Source code for highway_env.envs.common.observation
[docs]
def space(self) -> spaces.Space:
-
return spaces.Box(shape=(self.vehicles_count, len(self.features)), low=-np.inf, high=np.inf, dtype=np.float32)
+
return spaces.Box(
+
shape=(self.vehicles_count, len(self.features)),
+
low=-np.inf,
+
high=np.inf,
+
dtype=np.float32,
+
)
@@ -497,12 +519,17 @@
Source code for highway_env.envs.common.observation
:param Dataframe df: observation data
"""
if not self.features_range:
-
side_lanes = self.env.road.network.all_side_lanes(self.observer_vehicle.lane_index)
+
side_lanes = self.env.road.network.all_side_lanes(
+
self.observer_vehicle.lane_index
+
)
self.features_range = {
"x": [-5.0 * Vehicle.MAX_SPEED, 5.0 * Vehicle.MAX_SPEED],
-
"y": [-AbstractLane.DEFAULT_WIDTH * len(side_lanes), AbstractLane.DEFAULT_WIDTH * len(side_lanes)],
-
"vx": [-2*Vehicle.MAX_SPEED, 2*Vehicle.MAX_SPEED],
-
"vy": [-2*Vehicle.MAX_SPEED, 2*Vehicle.MAX_SPEED]
+
"y": [
+
-AbstractLane.DEFAULT_WIDTH * len(side_lanes),
+
AbstractLane.DEFAULT_WIDTH * len(side_lanes),
+
],
+
"vx": [-2 * Vehicle.MAX_SPEED, 2 * Vehicle.MAX_SPEED],
+
"vy": [-2 * Vehicle.MAX_SPEED, 2 * Vehicle.MAX_SPEED],
}
for feature, f_range in self.features_range.items():
if feature in df:
@@ -521,17 +548,22 @@
Source code for highway_env.envs.common.observation
# Add ego-vehicle
df = pd.DataFrame.from_records([self.observer_vehicle.to_dict()])
# Add nearby traffic
-
close_vehicles = self.env.road.close_objects_to(self.observer_vehicle,
-
self.env.PERCEPTION_DISTANCE,
-
count=self.vehicles_count - 1,
-
see_behind=self.see_behind,
-
sort=self.order == "sorted",
-
vehicles_only=not self.include_obstacles)
+
close_vehicles = self.env.road.close_objects_to(
+
self.observer_vehicle,
+
self.env.PERCEPTION_DISTANCE,
+
count=self.vehicles_count - 1,
+
see_behind=self.see_behind,
+
sort=self.order == "sorted",
+
vehicles_only=not self.include_obstacles,
+
)
if close_vehicles:
origin = self.observer_vehicle if not self.absolute else None
vehicles_df = pd.DataFrame.from_records(
-
[v.to_dict(origin, observe_intentions=self.observe_intentions)
-
for v in close_vehicles[-self.vehicles_count + 1:]])
+
[
+
v.to_dict(origin, observe_intentions=self.observe_intentions)
+
for v in close_vehicles[-self.vehicles_count + 1 :]
+
]
+
)
df = pd.concat([df, vehicles_df], ignore_index=True)
df = df[self.features]
@@ -542,7 +574,9 @@
Source code for highway_env.envs.common.observation
# Fill missing rows
if df.shape[0] < self.vehicles_count:
rows = np.zeros((self.vehicles_count - df.shape[0], len(self.features)))
-
df = pd.concat([df, pd.DataFrame(data=rows, columns=self.features)], ignore_index=True)
+
df = pd.concat(
+
[df, pd.DataFrame(data=rows, columns=self.features)], ignore_index=True
+
)
# Reorder
df = df[self.features]
obs = df.values.copy()
@@ -560,21 +594,23 @@
Source code for highway_env.envs.common.observation
"""Observe an occupancy grid of nearby vehicles."""
-
FEATURES: List[str] = ['presence', 'vx', 'vy', 'on_road']
-
GRID_SIZE: List[List[float]] = [[-5.5*5, 5.5*5], [-5.5*5, 5.5*5]]
+
FEATURES: List[str] = ["presence", "vx", "vy", "on_road"]
+
GRID_SIZE: List[List[float]] = [[-5.5 * 5, 5.5 * 5], [-5.5 * 5, 5.5 * 5]]
GRID_STEP: List[int] = [5, 5]
-
def __init__(self,
-
env: 'AbstractEnv',
-
features: Optional[List[str]] = None,
-
grid_size: Optional[Tuple[Tuple[float, float], Tuple[float, float]]] = None,
-
grid_step: Optional[Tuple[float, float]] = None,
-
features_range: Dict[str, List[float]] = None,
-
absolute: bool = False,
-
align_to_vehicle_axes: bool = False,
-
clip: bool = True,
-
as_image: bool = False,
-
**kwargs: dict) -> None:
+
def __init__(
+
self,
+
env: "AbstractEnv",
+
features: Optional[List[str]] = None,
+
grid_size: Optional[Tuple[Tuple[float, float], Tuple[float, float]]] = None,
+
grid_step: Optional[Tuple[float, float]] = None,
+
features_range: Dict[str, List[float]] = None,
+
absolute: bool = False,
+
align_to_vehicle_axes: bool = False,
+
clip: bool = True,
+
as_image: bool = False,
+
**kwargs: dict
+
) -> None:
"""
:param env: The environment to observe
:param features: Names of features used in the observation
@@ -588,10 +624,16 @@
Source code for highway_env.envs.common.observation
"""
super().__init__(env)
self.features = features if features is not None else self.FEATURES
-
self.grid_size = np.array(grid_size) if grid_size is not None else np.array(self.GRID_SIZE)
-
self.grid_step = np.array(grid_step) if grid_step is not None else np.array(self.GRID_STEP)
-
grid_shape = np.asarray(np.floor((self.grid_size[:, 1] - self.grid_size[:, 0]) / self.grid_step),
-
dtype=np.uint8)
+
self.grid_size = (
+
np.array(grid_size) if grid_size is not None else np.array(self.GRID_SIZE)
+
)
+
self.grid_step = (
+
np.array(grid_step) if grid_step is not None else np.array(self.GRID_STEP)
+
)
+
grid_shape = np.asarray(
+
np.floor((self.grid_size[:, 1] - self.grid_size[:, 0]) / self.grid_step),
+
dtype=np.uint8,
+
)
self.grid = np.zeros((len(self.features), *grid_shape))
self.features_range = features_range
self.absolute = absolute
@@ -605,7 +647,9 @@
Source code for highway_env.envs.common.observation
if self.as_image:
return spaces.Box(shape=self.grid.shape, low=0, high=255, dtype=np.uint8)
else:
- return spaces.Box(shape=self.grid.shape, low=-np.inf, high=np.inf, dtype=np.float32)
+
return spaces.Box(
+
shape=self.grid.shape, low=-np.inf, high=np.inf, dtype=np.float32
+
)
@@ -619,8 +663,8 @@
Source code for highway_env.envs.common.observation
"""
if not self.features_range:
self.features_range = {
-
"vx": [-2*Vehicle.MAX_SPEED, 2*Vehicle.MAX_SPEED],
-
"vy": [-2*Vehicle.MAX_SPEED, 2*Vehicle.MAX_SPEED]
+
"vx": [-2 * Vehicle.MAX_SPEED, 2 * Vehicle.MAX_SPEED],
+
"vy": [-2 * Vehicle.MAX_SPEED, 2 * Vehicle.MAX_SPEED],
}
for feature, f_range in self.features_range.items():
if feature in df:
@@ -642,7 +686,8 @@
Source code for highway_env.envs.common.observation
# Get nearby traffic data
df = pd.DataFrame.from_records(
-
[v.to_dict(self.observer_vehicle) for v in self.env.road.vehicles])
+
[v.to_dict(self.observer_vehicle) for v in self.env.road.vehicles]
+
)
# Normalize
df = self.normalize(df)
# Fill-in features
@@ -652,11 +697,28 @@
Source code for highway_env.envs.common.observation
x
, y = vehicle["x"], vehicle["y"]
# Recover unnormalized coordinates for cell index
if "x" in self.features_range:
-
x = utils.lmap(x, [-1, 1], [self.features_range["x"][0], self.features_range["x"][1]])
+
x = utils.lmap(
+
x,
+
[-1, 1],
+
[
+
self.features_range["x"][0],
+
self.features_range["x"][1],
+
],
+
)
if "y" in self.features_range:
-
y = utils.lmap(y, [-1, 1], [self.features_range["y"][0], self.features_range["y"][1]])
+
y = utils.lmap(
+
y,
+
[-1, 1],
+
[
+
self.features_range["y"][0],
+
self.features_range["y"][1],
+
],
+
)
cell = self.pos_to_index((x, y), relative=not self.absolute)
-
if 0 <= cell[1] < self.grid.shape[-2] and 0 <= cell[0] < self.grid.shape[-1]:
+
if (
+
0 <= cell[1] < self.grid.shape[-2]
+
and 0 <= cell[0] < self.grid.shape[-1]
+
):
self.grid[layer, cell[1], cell[0]] = vehicle[feature]
elif feature == "on_road":
self.fill_road_layer_by_lanes(layer)
@@ -689,20 +751,26 @@
Source code for highway_env.envs.common.observation
if not relative:
position -= self.observer_vehicle.position
if self.align_to_vehicle_axes:
- c, s = np.cos(self.observer_vehicle.heading), np.sin(self.observer_vehicle.heading)
+ c, s = np.cos(self.observer_vehicle.heading), np.sin(
+ self.observer_vehicle.heading
+ )
position = np.array([[c, s], [-s, c]]) @ position
- return int(np.floor((position[0] - self.grid_size[0, 0]) / self.grid_step[0])),\
- int(np.floor((position[1] - self.grid_size[1, 0]) / self.grid_step[1]))
+
return int(
+
np.floor((position[0] - self.grid_size[0, 0]) / self.grid_step[0])
+
), int(np.floor((position[1] - self.grid_size[1, 0]) / self.grid_step[1]))
def index_to_pos(self, index: Tuple[int, int]) -> np.ndarray:
-
-
position = np.array([
-
(index[1] + 0.5) * self.grid_step[0] + self.grid_size[0, 0],
-
(index[0] + 0.5) * self.grid_step[1] + self.grid_size[1, 0]
-
])
+
position = np.array(
+
[
+
(index[1] + 0.5) * self.grid_step[0] + self.grid_size[0, 0],
+
(index[0] + 0.5) * self.grid_step[1] + self.grid_size[1, 0],
+
]
+
)
if self.align_to_vehicle_axes:
-
c, s = np.cos(-self.observer_vehicle.heading), np.sin(-self.observer_vehicle.heading)
+
c, s = np.cos(-self.observer_vehicle.heading), np.sin(
+
-self.observer_vehicle.heading
+
)
position = np.array([[c, s], [-s, c]]) @ position
position += self.observer_vehicle.position
@@ -710,7 +778,9 @@
Source code for highway_env.envs.common.observation
[docs]
-
def fill_road_layer_by_lanes(self, layer_index: int, lane_perception_distance: float = 100) -> None:
+
def fill_road_layer_by_lanes(
+
self, layer_index: int, lane_perception_distance: float = 100
+
) -> None:
"""
A layer to encode the onroad (1) / offroad (0) information
@@ -727,12 +797,17 @@
Source code for highway_env.envs.common.observation
for _to in road.network.graph[_from].keys():
for lane in road.network.graph[_from][_to]:
origin, _ = lane.local_coordinates(self.observer_vehicle.position)
- waypoints = np.arange(origin - lane_perception_distance,
- origin + lane_perception_distance,
- lane_waypoints_spacing).clip(0, lane.length)
+ waypoints = np.arange(
+ origin - lane_perception_distance,
+ origin + lane_perception_distance,
+ lane_waypoints_spacing,
+ ).clip(0, lane.length)
for waypoint in waypoints:
cell = self.pos_to_index(lane.position(waypoint, 0))
- if 0 <= cell[1] < self.grid.shape[-2] and 0 <= cell[0] < self.grid.shape[-1]:
+ if (
+ 0 <= cell[1] < self.grid.shape[-2]
+ and 0 <= cell[0] < self.grid.shape[-1]
+ ):
self.grid[layer_index, cell[1], cell[0]] = 1
@@ -759,7 +834,7 @@
Source code for highway_env.envs.common.observation
[docs]
class KinematicsGoalObservation(KinematicObservation):
-
def __init__(self, env: 'AbstractEnv', scales: List[float], **kwargs: dict) -> None:
+
def __init__(self, env: "AbstractEnv", scales: List[float], **kwargs: dict) -> None:
self.scales = np.array(scales)
super().__init__(env, **kwargs)
@@ -768,11 +843,28 @@
Source code for highway_env.envs.common.observation
def space(self) -> spaces.Space:
try:
obs = self.observe()
- return spaces.Dict(dict(
- desired_goal=spaces.Box(-np.inf, np.inf, shape=obs["desired_goal"].shape, dtype=np.float64),
- achieved_goal=spaces.Box(-np.inf, np.inf, shape=obs["achieved_goal"].shape, dtype=np.float64),
- observation=spaces.Box(-np.inf, np.inf, shape=obs["observation"].shape, dtype=np.float64),
- ))
+ return spaces.Dict(
+ dict(
+ desired_goal=spaces.Box(
+ -np.inf,
+ np.inf,
+ shape=obs["desired_goal"].shape,
+ dtype=np.float64,
+ ),
+ achieved_goal=spaces.Box(
+ -np.inf,
+ np.inf,
+ shape=obs["achieved_goal"].shape,
+ dtype=np.float64,
+ ),
+ observation=spaces.Box(
+ -np.inf,
+ np.inf,
+ shape=obs["observation"].shape,
+ dtype=np.float64,
+ ),
+ )
+ )
except AttributeError:
return spaces.Space()
@@ -781,50 +873,61 @@
Source code for highway_env.envs.common.observation
[docs]
def observe(self) -> Dict[str, np.ndarray]:
if not self.observer_vehicle:
- return OrderedDict([
- ("observation", np.zeros((len(self.features),))),
- ("achieved_goal", np.zeros((len(self.features),))),
- ("desired_goal", np.zeros((len(self.features),)))
- ])
-
- obs = np.ravel(pd.DataFrame.from_records([self.observer_vehicle.to_dict()])[self.features])
- goal = np.ravel(pd.DataFrame.from_records([self.env.goal.to_dict()])[self.features])
- obs = OrderedDict([
- ("observation", obs / self.scales),
- ("achieved_goal", obs / self.scales),
- ("desired_goal", goal / self.scales)
- ])
+ return OrderedDict(
+ [
+ ("observation", np.zeros((len(self.features),))),
+ ("achieved_goal", np.zeros((len(self.features),))),
+ ("desired_goal", np.zeros((len(self.features),))),
+ ]
+ )
+
+ obs = np.ravel(
+ pd.DataFrame.from_records([self.observer_vehicle.to_dict()])[self.features]
+ )
+ goal = np.ravel(
+ pd.DataFrame.from_records([self.env.goal.to_dict()])[self.features]
+ )
+ obs = OrderedDict(
+ [
+ ("observation", obs / self.scales),
+ ("achieved_goal", obs / self.scales),
+ ("desired_goal", goal / self.scales),
+ ]
+ )
return obs
class AttributesObservation(ObservationType):
-
def __init__(self, env: 'AbstractEnv', attributes: List[str], **kwargs: dict) -> None:
+
def __init__(
+
self, env: "AbstractEnv", attributes: List[str], **kwargs: dict
+
) -> None:
self.env = env
self.attributes = attributes
def space(self) -> spaces.Space:
try:
obs = self.observe()
-
return spaces.Dict({
-
attribute: spaces.Box(-np.inf, np.inf, shape=obs[attribute].shape, dtype=np.float64)
-
for attribute in self.attributes
-
})
+
return spaces.Dict(
+
{
+
attribute: spaces.Box(
+
-np.inf, np.inf, shape=obs[attribute].shape, dtype=np.float64
+
)
+
for attribute in self.attributes
+
}
+
)
except AttributeError:
return spaces.Space()
def observe(self) -> Dict[str, np.ndarray]:
-
return OrderedDict([
-
(attribute, getattr(self.env, attribute)) for attribute in self.attributes
-
])
+
return OrderedDict(
+
[(attribute, getattr(self.env, attribute)) for attribute in self.attributes]
+
)
class MultiAgentObservation(ObservationType):
-
def __init__(self,
-
env: 'AbstractEnv',
-
observation_config: dict,
-
**kwargs) -> None:
+
def __init__(self, env: "AbstractEnv", observation_config: dict, **kwargs) -> None:
super().__init__(env)
self.observation_config = observation_config
self.agents_observation_types = []
@@ -834,19 +937,23 @@
Source code for highway_env.envs.common.observation
self
.agents_observation_types.append(obs_type)
def space(self) -> spaces.Space:
-
return spaces.Tuple([obs_type.space() for obs_type in self.agents_observation_types])
+
return spaces.Tuple(
+
[obs_type.space() for obs_type in self.agents_observation_types]
+
)
def observe(self) -> tuple:
return tuple(obs_type.observe() for obs_type in self.agents_observation_types)
class TupleObservation(ObservationType):
-
def __init__(self,
-
env: 'AbstractEnv',
-
observation_configs: List[dict],
-
**kwargs) -> None:
+
def __init__(
+
self, env: "AbstractEnv", observation_configs: List[dict], **kwargs
+
) -> None:
super().__init__(env)
-
self.observation_types = [observation_factory(self.env, obs_config) for obs_config in observation_configs]
+
self.observation_types = [
+
observation_factory(self.env, obs_config)
+
for obs_config in observation_configs
+
]
def space(self) -> spaces.Space:
return spaces.Tuple([obs_type.space() for obs_type in self.observation_types])
@@ -874,23 +981,37 @@
Source code for highway_env.envs.common.observation
df
= pd.DataFrame.from_records([ego_dict])[self.features]
# Add nearby traffic
-
close_vehicles = self.env.road.close_vehicles_to(self.observer_vehicle,
-
self.env.PERCEPTION_DISTANCE,
-
count=self.vehicles_count - 1,
-
see_behind=self.see_behind)
+
close_vehicles = self.env.road.close_vehicles_to(
+
self.observer_vehicle,
+
self.env.PERCEPTION_DISTANCE,
+
count=self.vehicles_count - 1,
+
see_behind=self.see_behind,
+
)
if close_vehicles:
origin = self.observer_vehicle if not self.absolute else None
-
df = pd.concat([df, pd.DataFrame.from_records(
-
[v.to_dict(origin, observe_intentions=self.observe_intentions)
-
for v in close_vehicles[-self.vehicles_count + 1:]])[self.features]],
-
ignore_index=True)
+
df = pd.concat(
+
[
+
df,
+
pd.DataFrame.from_records(
+
[
+
v.to_dict(
+
origin, observe_intentions=self.observe_intentions
+
)
+
for v in close_vehicles[-self.vehicles_count + 1 :]
+
]
+
)[self.features],
+
],
+
ignore_index=True,
+
)
# Normalize and clip
if self.normalize:
df = self.normalize_obs(df)
# Fill missing rows
if df.shape[0] < self.vehicles_count:
rows = np.zeros((self.vehicles_count - df.shape[0], len(self.features)))
-
df = pd.concat([df, pd.DataFrame(data=rows, columns=self.features)], ignore_index=True)
+
df = pd.concat(
+
[df, pd.DataFrame(data=rows, columns=self.features)], ignore_index=True
+
)
# Reorder
df = df[self.features]
obs = df.values.copy()
@@ -906,17 +1027,20 @@
Source code for highway_env.envs.common.observation
DISTANCE
= 0
SPEED = 1
-
def __init__(self, env,
-
cells: int = 16,
-
maximum_range: float = 60,
-
normalize: bool = True,
-
**kwargs):
+
def __init__(
+
self,
+
env,
+
cells: int = 16,
+
maximum_range: float = 60,
+
normalize: bool = True,
+
**kwargs
+
):
super().__init__(env, **kwargs)
self.cells = cells
self.maximum_range = maximum_range
self.normalize = normalize
self.angle = 2 * np.pi / self.cells
-
self.grid = np.ones((self.cells, 1)) * float('inf')
+
self.grid = np.ones((self.cells, 1)) * float("inf")
self.origin = None
def space(self) -> spaces.Space:
@@ -924,7 +1048,9 @@
Source code for highway_env.envs.common.observation
return
spaces.Box(shape=(self.cells, 2), low=-high, high=high, dtype=np.float32)
def observe(self) -> np.ndarray:
-
obs = self.trace(self.observer_vehicle.position, self.observer_vehicle.velocity).copy()
+
obs = self.trace(
+
self.observer_vehicle.position, self.observer_vehicle.velocity
+
).copy()
if self.normalize:
obs /= self.maximum_range
return obs
@@ -948,16 +1074,22 @@
Source code for highway_env.envs.common.observation
self
.grid[center_index, :] = [distance, velocity]
# Angular sector covered by the obstacle
-
corners = utils.rect_corners(obstacle.position, obstacle.LENGTH, obstacle.WIDTH, obstacle.heading)
+
corners = utils.rect_corners(
+
obstacle.position, obstacle.LENGTH, obstacle.WIDTH, obstacle.heading
+
)
angles = [self.position_to_angle(corner, origin) for corner in corners]
min_angle, max_angle = min(angles), max(angles)
-
if min_angle < -np.pi/2 < np.pi/2 < max_angle: # Object's corners are wrapping around +pi
-
min_angle, max_angle = max_angle, min_angle + 2*np.pi
+
if (
+
min_angle < -np.pi / 2 < np.pi / 2 < max_angle
+
): # Object's corners are wrapping around +pi
+
min_angle, max_angle = max_angle, min_angle + 2 * np.pi
start, end = self.angle_to_index(min_angle), self.angle_to_index(max_angle)
if start < end:
-
indexes = np.arange(start, end+1)
+
indexes = np.arange(start, end + 1)
else: # Object's corners are wrapping around 0
-
indexes = np.hstack([np.arange(start, self.cells), np.arange(0, end + 1)])
+
indexes = np.hstack(
+
[np.arange(start, self.cells), np.arange(0, end + 1)]
+
)
# Actual distance computation for these sections
for index in indexes:
@@ -970,7 +1102,10 @@
Source code for highway_env.envs.common.observation
return
self.grid
def position_to_angle(self, position: np.ndarray, origin: np.ndarray) -> float:
-
return np.arctan2(position[1] - origin[1], position[0] - origin[0]) + self.angle/2
+
return (
+
np.arctan2(position[1] - origin[1], position[0] - origin[0])
+
+ self.angle / 2
+
)
def position_to_index(self, position: np.ndarray, origin: np.ndarray) -> int:
return self.angle_to_index(self.position_to_angle(position, origin))
@@ -982,7 +1117,7 @@
Source code for highway_env.envs.common.observation
return
np.array([np.cos(index * self.angle), np.sin(index * self.angle)])
-
def observation_factory(env: 'AbstractEnv', config: dict) -> ObservationType:
+
def observation_factory(env: "AbstractEnv", config: dict) -> ObservationType:
if config["type"] == "TimeToCollision":
return TimeToCollisionObservation(env, **config)
elif config["type"] == "Kinematics":
diff --git a/main/_modules/highway_env/envs/highway_env/index.html b/main/_modules/highway_env/envs/highway_env/index.html
index d686e9e1f..e42242034 100644
--- a/main/_modules/highway_env/envs/highway_env/index.html
+++ b/main/_modules/highway_env/envs/highway_env/index.html
@@ -321,30 +321,30 @@
Source code for highway_env.envs.highway_env
@classmethod
def default_config(cls) -> dict:
config = super().default_config()
- config.update({
- "observation": {
- "type": "Kinematics"
- },
- "action": {
- "type": "DiscreteMetaAction",
- },
- "lanes_count": 4,
- "vehicles_count": 50,
- "controlled_vehicles": 1,
- "initial_lane_id": None,
- "duration": 40, # [s]
- "ego_spacing": 2,
- "vehicles_density": 1,
- "collision_reward": -1, # The reward received when colliding with a vehicle.
- "right_lane_reward": 0.1, # The reward received when driving on the right-most lanes, linearly mapped to
- # zero for other lanes.
- "high_speed_reward": 0.4, # The reward received when driving at full speed, linearly mapped to zero for
- # lower speeds according to config["reward_speed_range"].
- "lane_change_reward": 0, # The reward received at each lane change action.
- "reward_speed_range": [20, 30],
- "normalize_reward": True,
- "offroad_terminal": False
- })
+ config.update(
+ {
+ "observation": {"type": "Kinematics"},
+ "action": {
+ "type": "DiscreteMetaAction",
+ },
+ "lanes_count": 4,
+ "vehicles_count": 50,
+ "controlled_vehicles": 1,
+ "initial_lane_id": None,
+ "duration": 40, # [s]
+ "ego_spacing": 2,
+ "vehicles_density": 1,
+ "collision_reward": -1, # The reward received when colliding with a vehicle.
+ "right_lane_reward": 0.1, # The reward received when driving on the right-most lanes, linearly mapped to
+ # zero for other lanes.
+ "high_speed_reward": 0.4, # The reward received when driving at full speed, linearly mapped to zero for
+ # lower speeds according to config["reward_speed_range"].
+ "lane_change_reward": 0, # The reward received at each lane change action.
+ "reward_speed_range": [20, 30],
+ "normalize_reward": True,
+ "offroad_terminal": False,
+ }
+ )
return config
@@ -354,13 +354,20 @@
Source code for highway_env.envs.highway_env
def _create_road(self) -> None:
"""Create a road composed of straight adjacent lanes."""
- self.road = Road(network=RoadNetwork.straight_road_network(self.config["lanes_count"], speed_limit=30),
- np_random=self.np_random, record_history=self.config["show_trajectories"])
+ self.road = Road(
+ network=RoadNetwork.straight_road_network(
+ self.config["lanes_count"], speed_limit=30
+ ),
+ np_random=self.np_random,
+ record_history=self.config["show_trajectories"],
+ )
def _create_vehicles(self) -> None:
"""Create some new random vehicles of a given type, and add them on the road."""
other_vehicles_type = utils.class_from_path(self.config["other_vehicles_type"])
- other_per_controlled = near_split(self.config["vehicles_count"], num_bins=self.config["controlled_vehicles"])
+ other_per_controlled = near_split(
+ self.config["vehicles_count"], num_bins=self.config["controlled_vehicles"]
+ )
self.controlled_vehicles = []
for others in other_per_controlled:
@@ -368,14 +375,18 @@ Source code for highway_env.envs.highway_env
self.road,
speed=25,
lane_id=self.config["initial_lane_id"],
- spacing=self.config["ego_spacing"]
+ spacing=self.config["ego_spacing"],
+ )
+ vehicle = self.action_type.vehicle_class(
+ self.road, vehicle.position, vehicle.heading, vehicle.speed
)
- vehicle = self.action_type.vehicle_class(self.road, vehicle.position, vehicle.heading, vehicle.speed)
self.controlled_vehicles.append(vehicle)
self.road.vehicles.append(vehicle)
for _ in range(others):
- vehicle = other_vehicles_type.create_random(self.road, spacing=1 / self.config["vehicles_density"])
+ vehicle = other_vehicles_type.create_random(
+ self.road, spacing=1 / self.config["vehicles_density"]
+ )
vehicle.randomize_behavior()
self.road.vehicles.append(vehicle)
@@ -386,33 +397,47 @@ Source code for highway_env.envs.highway_env
:return: the corresponding reward
"""
rewards = self._rewards(action)
- reward = sum(self.config.get(name, 0) * reward for name, reward in rewards.items())
+ reward = sum(
+ self.config.get(name, 0) * reward for name, reward in rewards.items()
+ )
if self.config["normalize_reward"]:
- reward = utils.lmap(reward,
- [self.config["collision_reward"],
- self.config["high_speed_reward"] + self.config["right_lane_reward"]],
- [0, 1])
- reward *= rewards['on_road_reward']
+ reward = utils.lmap(
+ reward,
+ [
+ self.config["collision_reward"],
+ self.config["high_speed_reward"] + self.config["right_lane_reward"],
+ ],
+ [0, 1],
+ )
+ reward *= rewards["on_road_reward"]
return reward
def _rewards(self, action: Action) -> Dict[Text, float]:
neighbours = self.road.network.all_side_lanes(self.vehicle.lane_index)
- lane = self.vehicle.target_lane_index[2] if isinstance(self.vehicle, ControlledVehicle) \
+ lane = (
+ self.vehicle.target_lane_index[2]
+ if isinstance(self.vehicle, ControlledVehicle)
else self.vehicle.lane_index[2]
+ )
# Use forward speed rather than speed, see https://github.com/eleurent/highway-env/issues/268
forward_speed = self.vehicle.speed * np.cos(self.vehicle.heading)
- scaled_speed = utils.lmap(forward_speed, self.config["reward_speed_range"], [0, 1])
+ scaled_speed = utils.lmap(
+ forward_speed, self.config["reward_speed_range"], [0, 1]
+ )
return {
"collision_reward": float(self.vehicle.crashed),
"right_lane_reward": lane / max(len(neighbours) - 1, 1),
"high_speed_reward": np.clip(scaled_speed, 0, 1),
- "on_road_reward": float(self.vehicle.on_road)
+ "on_road_reward": float(self.vehicle.on_road),
}
def _is_terminated(self) -> bool:
"""The episode is over if the ego vehicle crashed."""
- return (self.vehicle.crashed or
- self.config["offroad_terminal"] and not self.vehicle.on_road)
+ return (
+ self.vehicle.crashed
+ or self.config["offroad_terminal"]
+ and not self.vehicle.on_road
+ )
def _is_truncated(self) -> bool:
"""The episode is truncated if the time limit is reached."""
@@ -427,16 +452,19 @@ Source code for highway_env.envs.highway_env
- fewer vehicles in the scene (and fewer lanes, shorter episode duration)
- only check collision of controlled vehicles with others
"""
+
@classmethod
def default_config(cls) -> dict:
cfg = super().default_config()
- cfg.update({
- "simulation_frequency": 5,
- "lanes_count": 3,
- "vehicles_count": 20,
- "duration": 30, # [s]
- "ego_spacing": 1.5,
- })
+ cfg.update(
+ {
+ "simulation_frequency": 5,
+ "lanes_count": 3,
+ "vehicles_count": 20,
+ "duration": 30, # [s]
+ "ego_spacing": 1.5,
+ }
+ )
return cfg
def _create_vehicles(self) -> None:
diff --git a/main/_modules/highway_env/envs/intersection_env/index.html b/main/_modules/highway_env/envs/intersection_env/index.html
index 17cf9fe86..e4a1b2aee 100644
--- a/main/_modules/highway_env/envs/intersection_env/index.html
+++ b/main/_modules/highway_env/envs/intersection_env/index.html
@@ -291,28 +291,22 @@
Source code for highway_env.envs.intersection_env
-from typing import Dict, Tuple, Text
+from typing import Dict, Text, Tuple
import numpy as np
from highway_env import utils
from highway_env.envs.common.abstract import AbstractEnv, MultiAgentWrapper
-from highway_env.road.lane import LineType, StraightLane, CircularLane, AbstractLane
+from highway_env.road.lane import AbstractLane, CircularLane, LineType, StraightLane
from highway_env.road.regulation import RegulatedRoad
from highway_env.road.road import RoadNetwork
from highway_env.vehicle.kinematics import Vehicle
-from highway_env.vehicle.controller import ControlledVehicle
[docs]
class IntersectionEnv(AbstractEnv):
-
-
ACTIONS: Dict[int, str] = {
-
0: 'SLOWER',
-
1: 'IDLE',
-
2: 'FASTER'
-
}
+
ACTIONS: Dict[int, str] = {0: "SLOWER", 1: "IDLE", 2: "FASTER"}
ACTIONS_INDEXES = {v: k for k, v in ACTIONS.items()}
@@ -320,88 +314,103 @@
Source code for highway_env.envs.intersection_env
@classmethod
def default_config(cls) -> dict:
config = super().default_config()
- config.update({
- "observation": {
- "type": "Kinematics",
- "vehicles_count": 15,
- "features": ["presence", "x", "y", "vx", "vy", "cos_h", "sin_h"],
- "features_range": {
- "x": [-100, 100],
- "y": [-100, 100],
- "vx": [-20, 20],
- "vy": [-20, 20],
+ config.update(
+ {
+ "observation": {
+ "type": "Kinematics",
+ "vehicles_count": 15,
+ "features": ["presence", "x", "y", "vx", "vy", "cos_h", "sin_h"],
+ "features_range": {
+ "x": [-100, 100],
+ "y": [-100, 100],
+ "vx": [-20, 20],
+ "vy": [-20, 20],
+ },
+ "absolute": True,
+ "flatten": False,
+ "observe_intentions": False,
+ },
+ "action": {
+ "type": "DiscreteMetaAction",
+ "longitudinal": True,
+ "lateral": False,
+ "target_speeds": [0, 4.5, 9],
},
- "absolute": True,
- "flatten": False,
- "observe_intentions": False
- },
- "action": {
- "type": "DiscreteMetaAction",
- "longitudinal": True,
- "lateral": False,
- "target_speeds": [0, 4.5, 9]
- },
- "duration": 13, # [s]
- "destination": "o1",
- "controlled_vehicles": 1,
- "initial_vehicle_count": 10,
- "spawn_probability": 0.6,
- "screen_width": 600,
- "screen_height": 600,
- "centering_position": [0.5, 0.6],
- "scaling": 5.5 * 1.3,
- "collision_reward": -5,
- "high_speed_reward": 1,
- "arrived_reward": 1,
- "reward_speed_range": [7.0, 9.0],
- "normalize_reward": False,
- "offroad_terminal": False
- })
+ "duration": 13, # [s]
+ "destination": "o1",
+ "controlled_vehicles": 1,
+ "initial_vehicle_count": 10,
+ "spawn_probability": 0.6,
+ "screen_width": 600,
+ "screen_height": 600,
+ "centering_position": [0.5, 0.6],
+ "scaling": 5.5 * 1.3,
+ "collision_reward": -5,
+ "high_speed_reward": 1,
+ "arrived_reward": 1,
+ "reward_speed_range": [7.0, 9.0],
+ "normalize_reward": False,
+ "offroad_terminal": False,
+ }
+ )
return config
def _reward(self, action: int) -> float:
"""Aggregated reward, for cooperative agents."""
-
return sum(self._agent_reward(action, vehicle) for vehicle in self.controlled_vehicles
-
) / len(self.controlled_vehicles)
+
return sum(
+
self._agent_reward(action, vehicle) for vehicle in self.controlled_vehicles
+
) / len(self.controlled_vehicles)
def _rewards(self, action: int) -> Dict[Text, float]:
"""Multi-objective rewards, for cooperative agents."""
-
agents_rewards = [self._agent_rewards(action, vehicle) for vehicle in self.controlled_vehicles]
+
agents_rewards = [
+
self._agent_rewards(action, vehicle) for vehicle in self.controlled_vehicles
+
]
return {
-
name: sum(agent_rewards[name] for agent_rewards in agents_rewards) / len(agents_rewards)
+
name: sum(agent_rewards[name] for agent_rewards in agents_rewards)
+
/ len(agents_rewards)
for name in agents_rewards[0].keys()
}
def _agent_reward(self, action: int, vehicle: Vehicle) -> float:
"""Per-agent reward signal."""
rewards = self._agent_rewards(action, vehicle)
-
reward = sum(self.config.get(name, 0) * reward for name, reward in rewards.items())
+
reward = sum(
+
self.config.get(name, 0) * reward for name, reward in rewards.items()
+
)
reward = self.config["arrived_reward"] if rewards["arrived_reward"] else reward
reward *= rewards["on_road_reward"]
if self.config["normalize_reward"]:
-
reward = utils.lmap(reward, [self.config["collision_reward"], self.config["arrived_reward"]], [0, 1])
+
reward = utils.lmap(
+
reward,
+
[self.config["collision_reward"], self.config["arrived_reward"]],
+
[0, 1],
+
)
return reward
def _agent_rewards(self, action: int, vehicle: Vehicle) -> Dict[Text, float]:
"""Per-agent per-objective reward signal."""
-
scaled_speed = utils.lmap(vehicle.speed, self.config["reward_speed_range"], [0, 1])
+
scaled_speed = utils.lmap(
+
vehicle.speed, self.config["reward_speed_range"], [0, 1]
+
)
return {
"collision_reward": vehicle.crashed,
"high_speed_reward": np.clip(scaled_speed, 0, 1),
"arrived_reward": self.has_arrived(vehicle),
-
"on_road_reward": vehicle.on_road
+
"on_road_reward": vehicle.on_road,
}
def _is_terminated(self) -> bool:
-
return any(vehicle.crashed for vehicle in self.controlled_vehicles) \
-
or all(self.has_arrived(vehicle) for vehicle in self.controlled_vehicles) \
-
or (self.config["offroad_terminal"] and not self.vehicle.on_road)
+
return (
+
any(vehicle.crashed for vehicle in self.controlled_vehicles)
+
or all(self.has_arrived(vehicle) for vehicle in self.controlled_vehicles)
+
or (self.config["offroad_terminal"] and not self.vehicle.on_road)
+
)
def _agent_is_terminal(self, vehicle: Vehicle) -> bool:
"""The episode is over when a collision occurs or when the access ramp has been passed."""
-
return (vehicle.crashed or
-
self.has_arrived(vehicle))
+
return vehicle.crashed or self.has_arrived(vehicle)
def _is_truncated(self) -> bool:
"""The episode is truncated if the time limit is reached."""
@@ -409,8 +418,12 @@
Source code for highway_env.envs.intersection_env
def
_info(self, obs: np.ndarray, action: int) -> dict:
info = super()._info(obs, action)
-
info["agents_rewards"] = tuple(self._agent_reward(action, vehicle) for vehicle in self.controlled_vehicles)
-
info["agents_dones"] = tuple(self._agent_is_terminal(vehicle) for vehicle in self.controlled_vehicles)
+
info["agents_rewards"] = tuple(
+
self._agent_reward(action, vehicle) for vehicle in self.controlled_vehicles
+
)
+
info["agents_dones"] = tuple(
+
self._agent_is_terminal(vehicle) for vehicle in self.controlled_vehicles
+
)
return info
def _reset(self) -> None:
@@ -453,34 +466,87 @@
Source code for highway_env.envs.intersection_env
angle
= np.radians(90 * corner)
is_horizontal = corner % 2
priority = 3 if is_horizontal else 1
-
rotation = np.array([[np.cos(angle), -np.sin(angle)], [np.sin(angle), np.cos(angle)]])
+
rotation = np.array(
+
[[np.cos(angle), -np.sin(angle)], [np.sin(angle), np.cos(angle)]]
+
)
# Incoming
-
start = rotation @ np.array([lane_width / 2, access_length + outer_distance])
+
start = rotation @ np.array(
+
[lane_width / 2, access_length + outer_distance]
+
)
end = rotation @ np.array([lane_width / 2, outer_distance])
-
net.add_lane("o" + str(corner), "ir" + str(corner),
-
StraightLane(start, end, line_types=[s, c], priority=priority, speed_limit=10))
+
net.add_lane(
+
"o" + str(corner),
+
"ir" + str(corner),
+
StraightLane(
+
start, end, line_types=[s, c], priority=priority, speed_limit=10
+
),
+
)
# Right turn
r_center = rotation @ (np.array([outer_distance, outer_distance]))
-
net.add_lane("ir" + str(corner), "il" + str((corner - 1) % 4),
-
CircularLane(r_center, right_turn_radius, angle + np.radians(180), angle + np.radians(270),
-
line_types=[n, c], priority=priority, speed_limit=10))
+
net.add_lane(
+
"ir" + str(corner),
+
"il" + str((corner - 1) % 4),
+
CircularLane(
+
r_center,
+
right_turn_radius,
+
angle + np.radians(180),
+
angle + np.radians(270),
+
line_types=[n, c],
+
priority=priority,
+
speed_limit=10,
+
),
+
)
# Left turn
-
l_center = rotation @ (np.array([-left_turn_radius + lane_width / 2, left_turn_radius - lane_width / 2]))
-
net.add_lane("ir" + str(corner), "il" + str((corner + 1) % 4),
-
CircularLane(l_center, left_turn_radius, angle + np.radians(0), angle + np.radians(-90),
-
clockwise=False, line_types=[n, n], priority=priority - 1, speed_limit=10))
+
l_center = rotation @ (
+
np.array(
+
[
+
-left_turn_radius + lane_width / 2,
+
left_turn_radius - lane_width / 2,
+
]
+
)
+
)
+
net.add_lane(
+
"ir" + str(corner),
+
"il" + str((corner + 1) % 4),
+
CircularLane(
+
l_center,
+
left_turn_radius,
+
angle + np.radians(0),
+
angle + np.radians(-90),
+
clockwise=False,
+
line_types=[n, n],
+
priority=priority - 1,
+
speed_limit=10,
+
),
+
)
# Straight
start = rotation @ np.array([lane_width / 2, outer_distance])
end = rotation @ np.array([lane_width / 2, -outer_distance])
-
net.add_lane("ir" + str(corner), "il" + str((corner + 2) % 4),
-
StraightLane(start, end, line_types=[s, n], priority=priority, speed_limit=10))
+
net.add_lane(
+
"ir" + str(corner),
+
"il" + str((corner + 2) % 4),
+
StraightLane(
+
start, end, line_types=[s, n], priority=priority, speed_limit=10
+
),
+
)
# Exit
-
start = rotation @ np.flip([lane_width / 2, access_length + outer_distance], axis=0)
+
start = rotation @ np.flip(
+
[lane_width / 2, access_length + outer_distance], axis=0
+
)
end = rotation @ np.flip([lane_width / 2, outer_distance], axis=0)
-
net.add_lane("il" + str((corner - 1) % 4), "o" + str((corner - 1) % 4),
-
StraightLane(end, start, line_types=[n, c], priority=priority, speed_limit=10))
-
-
road = RegulatedRoad(network=net, np_random=self.np_random, record_history=self.config["show_trajectories"])
+
net.add_lane(
+
"il" + str((corner - 1) % 4),
+
"o" + str((corner - 1) % 4),
+
StraightLane(
+
end, start, line_types=[n, c], priority=priority, speed_limit=10
+
),
+
)
+
+
road = RegulatedRoad(
+
network=net,
+
np_random=self.np_random,
+
record_history=self.config["show_trajectories"],
+
)
self.road = road
def _make_vehicles(self, n_vehicles: int = 10) -> None:
@@ -500,50 +566,80 @@
Source code for highway_env.envs.intersection_env
for
t in range(n_vehicles - 1):
self._spawn_vehicle(np.linspace(0, 80, n_vehicles)[t])
for _ in range(simulation_steps):
-
[(self.road.act(), self.road.step(1 / self.config["simulation_frequency"])) for _ in range(self.config["simulation_frequency"])]
+
[
+
(
+
self.road.act(),
+
self.road.step(1 / self.config["simulation_frequency"]),
+
)
+
for _ in range(self.config["simulation_frequency"])
+
]
# Challenger vehicle
-
self._spawn_vehicle(60, spawn_probability=1, go_straight=True, position_deviation=0.1, speed_deviation=0)
+
self._spawn_vehicle(
+
60,
+
spawn_probability=1,
+
go_straight=True,
+
position_deviation=0.1,
+
speed_deviation=0,
+
)
# Controlled vehicles
self.controlled_vehicles = []
for ego_id in range(0, self.config["controlled_vehicles"]):
-
ego_lane = self.road.network.get_lane(("o{}".format(ego_id % 4), "ir{}".format(ego_id % 4), 0))
-
destination = self.config["destination"] or "o" + str(self.np_random.integers(1, 4))
+
ego_lane = self.road.network.get_lane(
+
("o{}".format(ego_id % 4), "ir{}".format(ego_id % 4), 0)
+
)
+
destination = self.config["destination"] or "o" + str(
+
self.np_random.integers(1, 4)
+
)
ego_vehicle = self.action_type.vehicle_class(
-
self.road,
-
ego_lane.position(60 + 5*self.np_random.normal(1), 0),
-
speed=ego_lane.speed_limit,
-
heading=ego_lane.heading_at(60))
+
self.road,
+
ego_lane.position(60 + 5 * self.np_random.normal(1), 0),
+
speed=ego_lane.speed_limit,
+
heading=ego_lane.heading_at(60),
+
)
try:
ego_vehicle.plan_route_to(destination)
-
ego_vehicle.speed_index = ego_vehicle.speed_to_index(ego_lane.speed_limit)
-
ego_vehicle.target_speed = ego_vehicle.index_to_speed(ego_vehicle.speed_index)
+
ego_vehicle.speed_index = ego_vehicle.speed_to_index(
+
ego_lane.speed_limit
+
)
+
ego_vehicle.target_speed = ego_vehicle.index_to_speed(
+
ego_vehicle.speed_index
+
)
except AttributeError:
pass
self.road.vehicles.append(ego_vehicle)
self.controlled_vehicles.append(ego_vehicle)
for v in self.road.vehicles: # Prevent early collisions
-
if v is not ego_vehicle and np.linalg.norm(v.position - ego_vehicle.position) < 20:
+
if (
+
v is not ego_vehicle
+
and np.linalg.norm(v.position - ego_vehicle.position) < 20
+
):
self.road.vehicles.remove(v)
-
def _spawn_vehicle(self,
-
longitudinal: float = 0,
-
position_deviation: float = 1.,
-
speed_deviation: float = 1.,
-
spawn_probability: float = 0.6,
-
go_straight: bool = False) -> None:
+
def _spawn_vehicle(
+
self,
+
longitudinal: float = 0,
+
position_deviation: float = 1.0,
+
speed_deviation: float = 1.0,
+
spawn_probability: float = 0.6,
+
go_straight: bool = False,
+
) -> None:
if self.np_random.uniform() > spawn_probability:
return
route = self.np_random.choice(range(4), size=2, replace=False)
route[1] = (route[0] + 2) % 4 if go_straight else route[1]
vehicle_type = utils.class_from_path(self.config["other_vehicles_type"])
-
vehicle = vehicle_type.make_on_lane(self.road, ("o" + str(route[0]), "ir" + str(route[0]), 0),
-
longitudinal=(longitudinal + 5
-
+ self.np_random.normal() * position_deviation),
-
speed=8 + self.np_random.normal() * speed_deviation)
+
vehicle = vehicle_type.make_on_lane(
+
self.road,
+
("o" + str(route[0]), "ir" + str(route[0]), 0),
+
longitudinal=(
+
longitudinal + 5 + self.np_random.normal() * position_deviation
+
),
+
speed=8 + self.np_random.normal() * speed_deviation,
+
)
for v in self.road.vehicles:
if np.linalg.norm(v.position - vehicle.position) < 15:
return
@@ -553,16 +649,25 @@
Source code for highway_env.envs.intersection_env
return vehicle
def _clear_vehicles(self) -> None:
- is_leaving = lambda vehicle: "il" in vehicle.lane_index[0] and "o" in vehicle.lane_index[1] \
- and vehicle.lane.local_coordinates(vehicle.position)[0] \
- >= vehicle.lane.length - 4 * vehicle.LENGTH
- self.road.vehicles = [vehicle for vehicle in self.road.vehicles if
- vehicle in self.controlled_vehicles or not (is_leaving(vehicle) or vehicle.route is None)]
+ is_leaving = (
+ lambda vehicle: "il" in vehicle.lane_index[0]
+ and "o" in vehicle.lane_index[1]
+ and vehicle.lane.local_coordinates(vehicle.position)[0]
+ >= vehicle.lane.length - 4 * vehicle.LENGTH
+ )
+ self.road.vehicles = [
+ vehicle
+ for vehicle in self.road.vehicles
+ if vehicle in self.controlled_vehicles
+ or not (is_leaving(vehicle) or vehicle.route is None)
+ ]
def has_arrived(self, vehicle: Vehicle, exit_distance: float = 25) -> bool:
- return "il" in vehicle.lane_index[0] \
- and "o" in vehicle.lane_index[1] \
- and vehicle.lane.local_coordinates(vehicle.position)[0] >= exit_distance
+
return (
+
"il" in vehicle.lane_index[0]
+
and "o" in vehicle.lane_index[1]
+
and vehicle.lane.local_coordinates(vehicle.position)[0] >= exit_distance
+
)
@@ -570,45 +675,58 @@
Source code for highway_env.envs.intersection_env
@classmethod
def default_config(cls) -> dict:
config = super().default_config()
- config.update({
- "action": {
- "type": "MultiAgentAction",
- "action_config": {
- "type": "DiscreteMetaAction",
- "lateral": False,
- "longitudinal": True
- }
- },
- "observation": {
- "type": "MultiAgentObservation",
- "observation_config": {
- "type": "Kinematics"
- }
- },
- "controlled_vehicles": 2
- })
+ config.update(
+ {
+ "action": {
+ "type": "MultiAgentAction",
+ "action_config": {
+ "type": "DiscreteMetaAction",
+ "lateral": False,
+ "longitudinal": True,
+ },
+ },
+ "observation": {
+ "type": "MultiAgentObservation",
+ "observation_config": {"type": "Kinematics"},
+ },
+ "controlled_vehicles": 2,
+ }
+ )
return config
+
class ContinuousIntersectionEnv(IntersectionEnv):
@classmethod
def default_config(cls) -> dict:
config = super().default_config()
- config.update({
- "observation": {
- "type": "Kinematics",
- "vehicles_count": 5,
- "features": ["presence", "x", "y", "vx", "vy", "long_off", "lat_off", "ang_off"],
- },
- "action": {
- "type": "ContinuousAction",
- "steering_range": [-np.pi / 3, np.pi / 3],
- "longitudinal": True,
- "lateral": True,
- "dynamical": True
- },
- })
+ config.update(
+ {
+ "observation": {
+ "type": "Kinematics",
+ "vehicles_count": 5,
+ "features": [
+ "presence",
+ "x",
+ "y",
+ "vx",
+ "vy",
+ "long_off",
+ "lat_off",
+ "ang_off",
+ ],
+ },
+ "action": {
+ "type": "ContinuousAction",
+ "steering_range": [-np.pi / 3, np.pi / 3],
+ "longitudinal": True,
+ "lateral": True,
+ "dynamical": True,
+ },
+ }
+ )
return config
+
TupleMultiAgentIntersectionEnv = MultiAgentWrapper(MultiAgentIntersectionEnv)
diff --git a/main/_modules/highway_env/envs/merge_env/index.html b/main/_modules/highway_env/envs/merge_env/index.html
index 084a30d4f..a675b5685 100644
--- a/main/_modules/highway_env/envs/merge_env/index.html
+++ b/main/_modules/highway_env/envs/merge_env/index.html
@@ -297,7 +297,7 @@
Source code for highway_env.envs.merge_env
from highway_env import utils
from highway_env.envs.common.abstract import AbstractEnv
-from highway_env.road.lane import LineType, StraightLane, SineLane
+from highway_env.road.lane import LineType, SineLane, StraightLane
from highway_env.road.road import Road, RoadNetwork
from highway_env.vehicle.controller import ControlledVehicle
from highway_env.vehicle.objects import Obstacle
@@ -320,14 +320,16 @@ Source code for highway_env.envs.merge_env
@classmethod
def default_config(cls) -> dict:
cfg = super().default_config()
- cfg.update({
- "collision_reward": -1,
- "right_lane_reward": 0.1,
- "high_speed_reward": 0.2,
- "reward_speed_range": [20, 30],
- "merging_speed_reward": -0.5,
- "lane_change_reward": -0.05,
- })
+ cfg.update(
+ {
+ "collision_reward": -1,
+ "right_lane_reward": 0.1,
+ "high_speed_reward": 0.2,
+ "reward_speed_range": [20, 30],
+ "merging_speed_reward": -0.5,
+ "lane_change_reward": -0.05,
+ }
+ )
return cfg
@@ -340,14 +342,23 @@ Source code for highway_env.envs.merge_env
:param action: the action performed
:return: the reward of the state-action transition
"""
- reward = sum(self.config.get(name, 0) * reward for name, reward in self._rewards(action).items())
- return utils.lmap(reward,
- [self.config["collision_reward"] + self.config["merging_speed_reward"],
- self.config["high_speed_reward"] + self.config["right_lane_reward"]],
- [0, 1])
+ reward = sum(
+ self.config.get(name, 0) * reward
+ for name, reward in self._rewards(action).items()
+ )
+ return utils.lmap(
+ reward,
+ [
+ self.config["collision_reward"] + self.config["merging_speed_reward"],
+ self.config["high_speed_reward"] + self.config["right_lane_reward"],
+ ],
+ [0, 1],
+ )
def _rewards(self, action: int) -> Dict[Text, float]:
- scaled_speed = utils.lmap(self.vehicle.speed, self.config["reward_speed_range"], [0, 1])
+ scaled_speed = utils.lmap(
+ self.vehicle.speed, self.config["reward_speed_range"], [0, 1]
+ )
return {
"collision_reward": self.vehicle.crashed,
"right_lane_reward": self.vehicle.lane_index[2] / 1,
@@ -356,14 +367,15 @@ Source code for highway_env.envs.merge_env
"merging_speed_reward": sum( # Altruistic penalty
(vehicle.target_speed - vehicle.speed) / vehicle.target_speed
for vehicle in self.road.vehicles
- if vehicle.lane_index == ("b", "c", 2) and isinstance(vehicle, ControlledVehicle)
- )
+ if vehicle.lane_index == ("b", "c", 2)
+ and isinstance(vehicle, ControlledVehicle)
+ ),
}
def _is_terminated(self) -> bool:
"""The episode is over when a collision occurs or when the access ramp has been passed."""
print("crash" + str(self.vehicle.crashed))
- print("over" + str(self.vehicle.position[0] > 370))
+ print("over" + str(self.vehicle.position[0] > 370))
return self.vehicle.crashed or bool(self.vehicle.position[0] > 370)
def _is_truncated(self) -> bool:
@@ -388,21 +400,56 @@ Source code for highway_env.envs.merge_env
line_type = [[c, s], [n, c]]
line_type_merge = [[c, s], [n, s]]
for i in range(2):
- net.add_lane("a", "b", StraightLane([0, y[i]], [sum(ends[:2]), y[i]], line_types=line_type[i]))
- net.add_lane("b", "c", StraightLane([sum(ends[:2]), y[i]], [sum(ends[:3]), y[i]], line_types=line_type_merge[i]))
- net.add_lane("c", "d", StraightLane([sum(ends[:3]), y[i]], [sum(ends), y[i]], line_types=line_type[i]))
+ net.add_lane(
+ "a",
+ "b",
+ StraightLane([0, y[i]], [sum(ends[:2]), y[i]], line_types=line_type[i]),
+ )
+ net.add_lane(
+ "b",
+ "c",
+ StraightLane(
+ [sum(ends[:2]), y[i]],
+ [sum(ends[:3]), y[i]],
+ line_types=line_type_merge[i],
+ ),
+ )
+ net.add_lane(
+ "c",
+ "d",
+ StraightLane(
+ [sum(ends[:3]), y[i]], [sum(ends), y[i]], line_types=line_type[i]
+ ),
+ )
# Merging lane
amplitude = 3.25
- ljk = StraightLane([0, 6.5 + 4 + 4], [ends[0], 6.5 + 4 + 4], line_types=[c, c], forbidden=True)
- lkb = SineLane(ljk.position(ends[0], -amplitude), ljk.position(sum(ends[:2]), -amplitude),
- amplitude, 2 * np.pi / (2*ends[1]), np.pi / 2, line_types=[c, c], forbidden=True)
- lbc = StraightLane(lkb.position(ends[1], 0), lkb.position(ends[1], 0) + [ends[2], 0],
- line_types=[n, c], forbidden=True)
+ ljk = StraightLane(
+ [0, 6.5 + 4 + 4], [ends[0], 6.5 + 4 + 4], line_types=[c, c], forbidden=True
+ )
+ lkb = SineLane(
+ ljk.position(ends[0], -amplitude),
+ ljk.position(sum(ends[:2]), -amplitude),
+ amplitude,
+ 2 * np.pi / (2 * ends[1]),
+ np.pi / 2,
+ line_types=[c, c],
+ forbidden=True,
+ )
+ lbc = StraightLane(
+ lkb.position(ends[1], 0),
+ lkb.position(ends[1], 0) + [ends[2], 0],
+ line_types=[n, c],
+ forbidden=True,
+ )
net.add_lane("j", "k", ljk)
net.add_lane("k", "b", lkb)
net.add_lane("b", "c", lbc)
- road = Road(network=net, np_random=self.np_random, record_history=self.config["show_trajectories"])
+ road = Road(
+ network=net,
+ np_random=self.np_random,
+ record_history=self.config["show_trajectories"],
+ )
road.objects.append(Obstacle(road, lbc.position(ends[2], 0)))
self.road = road
@@ -413,9 +460,9 @@ Source code for highway_env.envs.merge_env
:return: the ego-vehicle
"""
road = self.road
- ego_vehicle = self.action_type.vehicle_class(road,
- road.network.get_lane(("a", "b", 1)).position(30, 0),
- speed=30)
+ ego_vehicle = self.action_type.vehicle_class(
+ road, road.network.get_lane(("a", "b", 1)).position(30, 0), speed=30
+ )
road.vehicles.append(ego_vehicle)
other_vehicles_type = utils.class_from_path(self.config["other_vehicles_type"])
@@ -426,7 +473,9 @@ Source code for highway_env.envs.merge_env
speed += self.np_random.uniform(-1, 1)
road.vehicles.append(other_vehicles_type(road, position, speed=speed))
- merging_v = other_vehicles_type(road, road.network.get_lane(("j", "k", 0)).position(110, 0), speed=20)
+ merging_v = other_vehicles_type(
+ road, road.network.get_lane(("j", "k", 0)).position(110, 0), speed=20
+ )
merging_v.target_speed = 30
road.vehicles.append(merging_v)
self.vehicle = ego_vehicle
diff --git a/main/_modules/highway_env/envs/parking_env/index.html b/main/_modules/highway_env/envs/parking_env/index.html
index 9a098b3c1..6af923f7e 100644
--- a/main/_modules/highway_env/envs/parking_env/index.html
+++ b/main/_modules/highway_env/envs/parking_env/index.html
@@ -294,12 +294,15 @@ Source code for highway_env.envs.parking_env
from abc import abstractmethod
from typing import Optional
-from gymnasium import Env
import numpy as np
+from gymnasium import Env
from highway_env.envs.common.abstract import AbstractEnv
-from highway_env.envs.common.observation import MultiAgentObservation, observation_factory
-from highway_env.road.lane import StraightLane, LineType
+from highway_env.envs.common.observation import (
+ MultiAgentObservation,
+ observation_factory,
+)
+from highway_env.road.lane import LineType, StraightLane
from highway_env.road.road import Road, RoadNetwork
from highway_env.vehicle.graphics import VehicleGraphics
from highway_env.vehicle.kinematics import Vehicle
@@ -325,7 +328,9 @@ Source code for highway_env.envs.parking_env
"""
@abstractmethod
- def compute_reward(self, achieved_goal: np.ndarray, desired_goal: np.ndarray, info: dict) -> float:
+ def compute_reward(
+ self, achieved_goal: np.ndarray, desired_goal: np.ndarray, info: dict
+ ) -> float:
"""Compute the step reward. This externalizes the reward function and makes
it dependent on a desired goal and the one that was achieved. If you wish to include
additional rewards that are independent of the goal, you can include the necessary values
@@ -358,12 +363,14 @@ Source code for highway_env.envs.parking_env
# For parking env with GrayscaleObservation, the env need
# this PARKING_OBS to calculate the reward and the info.
# Bug fixed by Mcfly(https://github.com/McflyWZX)
- PARKING_OBS = {"observation": {
+ PARKING_OBS = {
+ "observation": {
"type": "KinematicsGoal",
- "features": ['x', 'y', 'vx', 'vy', 'cos_h', 'sin_h'],
+ "features": ["x", "y", "vx", "vy", "cos_h", "sin_h"],
"scales": [100, 100, 5, 5, 1, 1],
- "normalize": False
- }}
+ "normalize": False,
+ }
+ }
def __init__(self, config: dict = None, render_mode: Optional[str] = None) -> None:
super().__init__(config, render_mode)
@@ -374,31 +381,31 @@ Source code for highway_env.envs.parking_env
@classmethod
def default_config(cls) -> dict:
config = super().default_config()
- config.update({
- "observation": {
- "type": "KinematicsGoal",
- "features": ['x', 'y', 'vx', 'vy', 'cos_h', 'sin_h'],
- "scales": [100, 100, 5, 5, 1, 1],
- "normalize": False
- },
- "action": {
- "type": "ContinuousAction"
- },
- "reward_weights": [1, 0.3, 0, 0, 0.02, 0.02],
- "success_goal_reward": 0.12,
- "collision_reward": -5,
- "steering_range": np.deg2rad(45),
- "simulation_frequency": 15,
- "policy_frequency": 5,
- "duration": 100,
- "screen_width": 600,
- "screen_height": 300,
- "centering_position": [0.5, 0.5],
- "scaling": 7,
- "controlled_vehicles": 1,
- "vehicles_count": 0,
- "add_walls": True
- })
+ config.update(
+ {
+ "observation": {
+ "type": "KinematicsGoal",
+ "features": ["x", "y", "vx", "vy", "cos_h", "sin_h"],
+ "scales": [100, 100, 5, 5, 1, 1],
+ "normalize": False,
+ },
+ "action": {"type": "ContinuousAction"},
+ "reward_weights": [1, 0.3, 0, 0, 0.02, 0.02],
+ "success_goal_reward": 0.12,
+ "collision_reward": -5,
+ "steering_range": np.deg2rad(45),
+ "simulation_frequency": 15,
+ "policy_frequency": 5,
+ "duration": 100,
+ "screen_width": 600,
+ "screen_height": 300,
+ "centering_position": [0.5, 0.5],
+ "scaling": 7,
+ "controlled_vehicles": 1,
+ "vehicles_count": 0,
+ "add_walls": True,
+ }
+ )
return config
@@ -409,16 +416,21 @@ Source code for highway_env.envs.parking_env
Set the types and spaces of observation and action from config.
"""
super().define_spaces()
- self.observation_type_parking = observation_factory(self, self.PARKING_OBS["observation"])
+ self.observation_type_parking = observation_factory(
+ self, self.PARKING_OBS["observation"]
+ )
def _info(self, obs, action) -> dict:
info = super(ParkingEnv, self)._info(obs, action)
if isinstance(self.observation_type, MultiAgentObservation):
- success = tuple(self._is_success(agent_obs['achieved_goal'], agent_obs['desired_goal']) for agent_obs in obs)
+ success = tuple(
+ self._is_success(agent_obs["achieved_goal"], agent_obs["desired_goal"])
+ for agent_obs in obs
+ )
else:
obs = self.observation_type_parking.observe()
- success = self._is_success(obs['achieved_goal'], obs['desired_goal'])
+ success = self._is_success(obs["achieved_goal"], obs["desired_goal"])
info.update({"is_success": success})
return info
@@ -440,12 +452,26 @@ Source code for highway_env.envs.parking_env
length = 8
for k in range(spots):
x = (k + 1 - spots // 2) * (width + x_offset) - width / 2
- net.add_lane("a", "b", StraightLane([x, y_offset], [x, y_offset+length], width=width, line_types=lt))
- net.add_lane("b", "c", StraightLane([x, -y_offset], [x, -y_offset-length], width=width, line_types=lt))
-
- self.road = Road(network=net,
- np_random=self.np_random,
- record_history=self.config["show_trajectories"])
+ net.add_lane(
+ "a",
+ "b",
+ StraightLane(
+ [x, y_offset], [x, y_offset + length], width=width, line_types=lt
+ ),
+ )
+ net.add_lane(
+ "b",
+ "c",
+ StraightLane(
+ [x, -y_offset], [x, -y_offset - length], width=width, line_types=lt
+ ),
+ )
+
+ self.road = Road(
+ network=net,
+ np_random=self.np_random,
+ record_history=self.config["show_trajectories"],
+ )
def _create_vehicles(self) -> None:
"""Create some new random vehicles of a given type, and add them on the road."""
@@ -454,7 +480,9 @@ Source code for highway_env.envs.parking_env
# Controlled vehicles
self.controlled_vehicles = []
for i in range(self.config["controlled_vehicles"]):
- vehicle = self.action_type.vehicle_class(self.road, [i*20, 0], 2*np.pi*self.np_random.uniform(), 0)
+ vehicle = self.action_type.vehicle_class(
+ self.road, [i * 20, 0], 2 * np.pi * self.np_random.uniform(), 0
+ )
vehicle.color = VehicleGraphics.EGO_COLOR
self.road.vehicles.append(vehicle)
self.controlled_vehicles.append(vehicle)
@@ -463,7 +491,9 @@ Source code for highway_env.envs.parking_env
# Goal
lane_index = empty_spots[self.np_random.choice(np.arange(len(empty_spots)))]
lane = self.road.network.get_lane(lane_index)
- self.goal = Landmark(self.road, lane.position(lane.length/2, 0), heading=lane.heading)
+ self.goal = Landmark(
+ self.road, lane.position(lane.length / 2, 0), heading=lane.heading
+ )
self.road.objects.append(self.goal)
empty_spots.remove(lane_index)
@@ -477,7 +507,7 @@ Source code for highway_env.envs.parking_env
empty_spots.remove(lane_index)
# Walls
- if self.config['add_walls']:
+ if self.config["add_walls"]:
width, height = 70, 42
for y in [-height / 2, height / 2]:
obstacle = Obstacle(self.road, [0, y])
@@ -492,7 +522,13 @@ Source code for highway_env.envs.parking_env
[docs]
- def compute_reward(self, achieved_goal: np.ndarray, desired_goal: np.ndarray, info: dict, p: float = 0.5) -> float:
+ def compute_reward(
+ self,
+ achieved_goal: np.ndarray,
+ desired_goal: np.ndarray,
+ info: dict,
+ p: float = 0.5,
+ ) -> float:
"""
Proximity to the goal is rewarded
@@ -504,25 +540,44 @@ Source code for highway_env.envs.parking_env
:param p: the Lp^p norm used in the reward. Use p<1 to have high kurtosis for rewards in [0, 1]
:return: the corresponding reward
"""
- return -np.power(np.dot(np.abs(achieved_goal - desired_goal), np.array(self.config["reward_weights"])), p)
+ return -np.power(
+ np.dot(
+ np.abs(achieved_goal - desired_goal),
+ np.array(self.config["reward_weights"]),
+ ),
+ p,
+ )
def _reward(self, action: np.ndarray) -> float:
obs = self.observation_type_parking.observe()
obs = obs if isinstance(obs, tuple) else (obs,)
- reward = sum(self.compute_reward(agent_obs['achieved_goal'], agent_obs['desired_goal'], {}) for agent_obs in obs)
- reward += self.config['collision_reward'] * sum(v.crashed for v in self.controlled_vehicles)
+ reward = sum(
+ self.compute_reward(
+ agent_obs["achieved_goal"], agent_obs["desired_goal"], {}
+ )
+ for agent_obs in obs
+ )
+ reward += self.config["collision_reward"] * sum(
+ v.crashed for v in self.controlled_vehicles
+ )
return reward
def _is_success(self, achieved_goal: np.ndarray, desired_goal: np.ndarray) -> bool:
- return self.compute_reward(achieved_goal, desired_goal, {}) > -self.config["success_goal_reward"]
+ return (
+ self.compute_reward(achieved_goal, desired_goal, {})
+ > -self.config["success_goal_reward"]
+ )
def _is_terminated(self) -> bool:
"""The episode is over if the ego vehicle crashed or the goal is reached or time is over."""
crashed = any(vehicle.crashed for vehicle in self.controlled_vehicles)
obs = self.observation_type_parking.observe()
obs = obs if isinstance(obs, tuple) else (obs,)
- success = all(self._is_success(agent_obs['achieved_goal'], agent_obs['desired_goal']) for agent_obs in obs)
+ success = all(
+ self._is_success(agent_obs["achieved_goal"], agent_obs["desired_goal"])
+ for agent_obs in obs
+ )
return bool(crashed or success)
def _is_truncated(self) -> bool:
diff --git a/main/_modules/highway_env/envs/racetrack_env/index.html b/main/_modules/highway_env/envs/racetrack_env/index.html
index e5364b49d..c27438074 100644
--- a/main/_modules/highway_env/envs/racetrack_env/index.html
+++ b/main/_modules/highway_env/envs/racetrack_env/index.html
@@ -291,14 +291,13 @@
Source code for highway_env.envs.racetrack_env
-from itertools import repeat, product
-from typing import Tuple, Dict, Text
+from typing import Dict, Text
import numpy as np
from highway_env import utils
from highway_env.envs.common.abstract import AbstractEnv
-from highway_env.road.lane import LineType, StraightLane, CircularLane, SineLane
+from highway_env.road.lane import CircularLane, LineType, StraightLane
from highway_env.road.road import Road, RoadNetwork
from highway_env.vehicle.behavior import IDMVehicle
@@ -322,40 +321,44 @@ Source code for highway_env.envs.racetrack_env
@classmethod
def default_config(cls) -> dict:
config = super().default_config()
- config.update({
- "observation": {
- "type": "OccupancyGrid",
- "features": ['presence', 'on_road'],
- "grid_size": [[-18, 18], [-18, 18]],
- "grid_step": [3, 3],
- "as_image": False,
- "align_to_vehicle_axes": True
- },
- "action": {
- "type": "ContinuousAction",
- "longitudinal": False,
- "lateral": True,
- "target_speeds": [0, 5, 10]
- },
- "simulation_frequency": 15,
- "policy_frequency": 5,
- "duration": 300,
- "collision_reward": -1,
- "lane_centering_cost": 4,
- "lane_centering_reward": 1,
- "action_reward": -0.3,
- "controlled_vehicles": 1,
- "other_vehicles": 1,
- "screen_width": 600,
- "screen_height": 600,
- "centering_position": [0.5, 0.5],
- })
+ config.update(
+ {
+ "observation": {
+ "type": "OccupancyGrid",
+ "features": ["presence", "on_road"],
+ "grid_size": [[-18, 18], [-18, 18]],
+ "grid_step": [3, 3],
+ "as_image": False,
+ "align_to_vehicle_axes": True,
+ },
+ "action": {
+ "type": "ContinuousAction",
+ "longitudinal": False,
+ "lateral": True,
+ "target_speeds": [0, 5, 10],
+ },
+ "simulation_frequency": 15,
+ "policy_frequency": 5,
+ "duration": 300,
+ "collision_reward": -1,
+ "lane_centering_cost": 4,
+ "lane_centering_reward": 1,
+ "action_reward": -0.3,
+ "controlled_vehicles": 1,
+ "other_vehicles": 1,
+ "screen_width": 600,
+ "screen_height": 600,
+ "centering_position": [0.5, 0.5],
+ }
+ )
return config
def _reward(self, action: np.ndarray) -> float:
rewards = self._rewards(action)
- reward = sum(self.config.get(name, 0) * reward for name, reward in rewards.items())
+ reward = sum(
+ self.config.get(name, 0) * reward for name, reward in rewards.items()
+ )
reward = utils.lmap(reward, [self.config["collision_reward"], 1], [0, 1])
reward *= rewards["on_road_reward"]
return reward
@@ -363,7 +366,8 @@ Source code for highway_env.envs.racetrack_env
def _rewards(self, action: np.ndarray) -> Dict[Text, float]:
_, lateral = self.vehicle.lane.local_coordinates(self.vehicle.position)
return {
- "lane_centering_reward": 1/(1+self.config["lane_centering_cost"]*lateral**2),
+ "lane_centering_reward": 1
+ / (1 + self.config["lane_centering_cost"] * lateral**2),
"action_reward": np.linalg.norm(action),
"collision_reward": self.vehicle.crashed,
"on_road_reward": self.vehicle.on_road,
@@ -386,98 +390,270 @@
Source code for highway_env.envs.racetrack_env
speedlimits = [None, 10, 10, 10, 10, 10, 10, 10, 10]
# Initialise First Lane
- lane = StraightLane([42, 0], [100, 0], line_types=(LineType.CONTINUOUS, LineType.STRIPED), width=5, speed_limit=speedlimits[1])
+ lane = StraightLane(
+ [42, 0],
+ [100, 0],
+ line_types=(LineType.CONTINUOUS, LineType.STRIPED),
+ width=5,
+ speed_limit=speedlimits[1],
+ )
self.lane = lane
# Add Lanes to Road Network - Straight Section
net.add_lane("a", "b", lane)
- net.add_lane("a", "b", StraightLane([42, 5], [100, 5], line_types=(LineType.STRIPED, LineType.CONTINUOUS), width=5, speed_limit=speedlimits[1]))
+ net.add_lane(
+ "a",
+ "b",
+ StraightLane(
+ [42, 5],
+ [100, 5],
+ line_types=(LineType.STRIPED, LineType.CONTINUOUS),
+ width=5,
+ speed_limit=speedlimits[1],
+ ),
+ )
# 2 - Circular Arc #1
center1 = [100, -20]
radii1 = 20
- net.add_lane("b", "c",
- CircularLane(center1, radii1, np.deg2rad(90), np.deg2rad(-1), width=5,
- clockwise=False, line_types=(LineType.CONTINUOUS, LineType.NONE),
- speed_limit=speedlimits[2]))
- net.add_lane("b", "c",
- CircularLane(center1, radii1+5, np.deg2rad(90), np.deg2rad(-1), width=5,
- clockwise=False, line_types=(LineType.STRIPED, LineType.CONTINUOUS),
- speed_limit=speedlimits[2]))
+ net.add_lane(
+ "b",
+ "c",
+ CircularLane(
+ center1,
+ radii1,
+ np.deg2rad(90),
+ np.deg2rad(-1),
+ width=5,
+ clockwise=False,
+ line_types=(LineType.CONTINUOUS, LineType.NONE),
+ speed_limit=speedlimits[2],
+ ),
+ )
+ net.add_lane(
+ "b",
+ "c",
+ CircularLane(
+ center1,
+ radii1 + 5,
+ np.deg2rad(90),
+ np.deg2rad(-1),
+ width=5,
+ clockwise=False,
+ line_types=(LineType.STRIPED, LineType.CONTINUOUS),
+ speed_limit=speedlimits[2],
+ ),
+ )
# 3 - Vertical Straight
- net.add_lane("c", "d", StraightLane([120, -20], [120, -30],
- line_types=(LineType.CONTINUOUS, LineType.NONE), width=5,
- speed_limit=speedlimits[3]))
- net.add_lane("c", "d", StraightLane([125, -20], [125, -30],
- line_types=(LineType.STRIPED, LineType.CONTINUOUS), width=5,
- speed_limit=speedlimits[3]))
+ net.add_lane(
+ "c",
+ "d",
+ StraightLane(
+ [120, -20],
+ [120, -30],
+ line_types=(LineType.CONTINUOUS, LineType.NONE),
+ width=5,
+ speed_limit=speedlimits[3],
+ ),
+ )
+ net.add_lane(
+ "c",
+ "d",
+ StraightLane(
+ [125, -20],
+ [125, -30],
+ line_types=(LineType.STRIPED, LineType.CONTINUOUS),
+ width=5,
+ speed_limit=speedlimits[3],
+ ),
+ )
# 4 - Circular Arc #2
center2 = [105, -30]
radii2 = 15
- net.add_lane("d", "e",
- CircularLane(center2, radii2, np.deg2rad(0), np.deg2rad(-181), width=5,
- clockwise=False, line_types=(LineType.CONTINUOUS, LineType.NONE),
- speed_limit=speedlimits[4]))
- net.add_lane("d", "e",
- CircularLane(center2, radii2+5, np.deg2rad(0), np.deg2rad(-181), width=5,
- clockwise=False, line_types=(LineType.STRIPED, LineType.CONTINUOUS),
- speed_limit=speedlimits[4]))
+ net.add_lane(
+ "d",
+ "e",
+ CircularLane(
+ center2,
+ radii2,
+ np.deg2rad(0),
+ np.deg2rad(-181),
+ width=5,
+ clockwise=False,
+ line_types=(LineType.CONTINUOUS, LineType.NONE),
+ speed_limit=speedlimits[4],
+ ),
+ )
+ net.add_lane(
+ "d",
+ "e",
+ CircularLane(
+ center2,
+ radii2 + 5,
+ np.deg2rad(0),
+ np.deg2rad(-181),
+ width=5,
+ clockwise=False,
+ line_types=(LineType.STRIPED, LineType.CONTINUOUS),
+ speed_limit=speedlimits[4],
+ ),
+ )
# 5 - Circular Arc #3
center3 = [70, -30]
radii3 = 15
- net.add_lane("e", "f",
- CircularLane(center3, radii3+5, np.deg2rad(0), np.deg2rad(136), width=5,
- clockwise=True, line_types=(LineType.CONTINUOUS, LineType.STRIPED),
- speed_limit=speedlimits[5]))
- net.add_lane("e", "f",
- CircularLane(center3, radii3, np.deg2rad(0), np.deg2rad(137), width=5,
- clockwise=True, line_types=(LineType.NONE, LineType.CONTINUOUS),
- speed_limit=speedlimits[5]))
+ net.add_lane(
+ "e",
+ "f",
+ CircularLane(
+ center3,
+ radii3 + 5,
+ np.deg2rad(0),
+ np.deg2rad(136),
+ width=5,
+ clockwise=True,
+ line_types=(LineType.CONTINUOUS, LineType.STRIPED),
+ speed_limit=speedlimits[5],
+ ),
+ )
+ net.add_lane(
+ "e",
+ "f",
+ CircularLane(
+ center3,
+ radii3,
+ np.deg2rad(0),
+ np.deg2rad(137),
+ width=5,
+ clockwise=True,
+ line_types=(LineType.NONE, LineType.CONTINUOUS),
+ speed_limit=speedlimits[5],
+ ),
+ )
# 6 - Slant
- net.add_lane("f", "g", StraightLane([55.7, -15.7], [35.7, -35.7],
- line_types=(LineType.CONTINUOUS, LineType.NONE), width=5,
- speed_limit=speedlimits[6]))
- net.add_lane("f", "g", StraightLane([59.3934, -19.2], [39.3934, -39.2],
- line_types=(LineType.STRIPED, LineType.CONTINUOUS), width=5,
- speed_limit=speedlimits[6]))
+ net.add_lane(
+ "f",
+ "g",
+ StraightLane(
+ [55.7, -15.7],
+ [35.7, -35.7],
+ line_types=(LineType.CONTINUOUS, LineType.NONE),
+ width=5,
+ speed_limit=speedlimits[6],
+ ),
+ )
+ net.add_lane(
+ "f",
+ "g",
+ StraightLane(
+ [59.3934, -19.2],
+ [39.3934, -39.2],
+ line_types=(LineType.STRIPED, LineType.CONTINUOUS),
+ width=5,
+ speed_limit=speedlimits[6],
+ ),
+ )
# 7 - Circular Arc #4 - Bugs out when arc is too large, hence written in 2 sections
center4 = [18.1, -18.1]
radii4 = 25
- net.add_lane("g", "h",
- CircularLane(center4, radii4, np.deg2rad(315), np.deg2rad(170), width=5,
- clockwise=False, line_types=(LineType.CONTINUOUS, LineType.NONE),
- speed_limit=speedlimits[7]))
- net.add_lane("g", "h",
- CircularLane(center4, radii4+5, np.deg2rad(315), np.deg2rad(165), width=5,
- clockwise=False, line_types=(LineType.STRIPED, LineType.CONTINUOUS),
- speed_limit=speedlimits[7]))
- net.add_lane("h", "i",
- CircularLane(center4, radii4, np.deg2rad(170), np.deg2rad(56), width=5,
- clockwise=False, line_types=(LineType.CONTINUOUS, LineType.NONE),
- speed_limit=speedlimits[7]))
- net.add_lane("h", "i",
- CircularLane(center4, radii4+5, np.deg2rad(170), np.deg2rad(58), width=5,
- clockwise=False, line_types=(LineType.STRIPED, LineType.CONTINUOUS),
- speed_limit=speedlimits[7]))
+ net.add_lane(
+ "g",
+ "h",
+ CircularLane(
+ center4,
+ radii4,
+ np.deg2rad(315),
+ np.deg2rad(170),
+ width=5,
+ clockwise=False,
+ line_types=(LineType.CONTINUOUS, LineType.NONE),
+ speed_limit=speedlimits[7],
+ ),
+ )
+ net.add_lane(
+ "g",
+ "h",
+ CircularLane(
+ center4,
+ radii4 + 5,
+ np.deg2rad(315),
+ np.deg2rad(165),
+ width=5,
+ clockwise=False,
+ line_types=(LineType.STRIPED, LineType.CONTINUOUS),
+ speed_limit=speedlimits[7],
+ ),
+ )
+ net.add_lane(
+ "h",
+ "i",
+ CircularLane(
+ center4,
+ radii4,
+ np.deg2rad(170),
+ np.deg2rad(56),
+ width=5,
+ clockwise=False,
+ line_types=(LineType.CONTINUOUS, LineType.NONE),
+ speed_limit=speedlimits[7],
+ ),
+ )
+ net.add_lane(
+ "h",
+ "i",
+ CircularLane(
+ center4,
+ radii4 + 5,
+ np.deg2rad(170),
+ np.deg2rad(58),
+ width=5,
+ clockwise=False,
+ line_types=(LineType.STRIPED, LineType.CONTINUOUS),
+ speed_limit=speedlimits[7],
+ ),
+ )
# 8 - Circular Arc #5 - Reconnects to Start
center5 = [43.2, 23.4]
radii5 = 18.5
- net.add_lane("i", "a",
- CircularLane(center5, radii5+5, np.deg2rad(240), np.deg2rad(270), width=5,
- clockwise=True, line_types=(LineType.CONTINUOUS, LineType.STRIPED),
- speed_limit=speedlimits[8]))
- net.add_lane("i", "a",
- CircularLane(center5, radii5, np.deg2rad(238), np.deg2rad(268), width=5,
- clockwise=True, line_types=(LineType.NONE, LineType.CONTINUOUS),
- speed_limit=speedlimits[8]))
-
- road = Road(network=net, np_random=self.np_random, record_history=self.config["show_trajectories"])
+ net.add_lane(
+ "i",
+ "a",
+ CircularLane(
+ center5,
+ radii5 + 5,
+ np.deg2rad(240),
+ np.deg2rad(270),
+ width=5,
+ clockwise=True,
+ line_types=(LineType.CONTINUOUS, LineType.STRIPED),
+ speed_limit=speedlimits[8],
+ ),
+ )
+ net.add_lane(
+ "i",
+ "a",
+ CircularLane(
+ center5,
+ radii5,
+ np.deg2rad(238),
+ np.deg2rad(268),
+ width=5,
+ clockwise=True,
+ line_types=(LineType.NONE, LineType.CONTINUOUS),
+ speed_limit=speedlimits[8],
+ ),
+ )
+
+ road = Road(
+ network=net,
+ np_random=self.np_random,
+ record_history=self.config["show_trajectories"],
+ )
self.road = road
def _make_vehicles(self) -> None:
@@ -489,32 +665,40 @@
Source code for highway_env.envs.racetrack_env
# Controlled vehicles
self.controlled_vehicles = []
for i in range(self.config["controlled_vehicles"]):
- lane_index = ("a", "b", rng.integers(2)) if i == 0 else \
- self.road.network.random_lane_index(rng)
- controlled_vehicle = self.action_type.vehicle_class.make_on_lane(self.road, lane_index, speed=None,
- longitudinal=rng.uniform(20, 50))
+ lane_index = (
+ ("a", "b", rng.integers(2))
+ if i == 0
+ else self.road.network.random_lane_index(rng)
+ )
+ controlled_vehicle = self.action_type.vehicle_class.make_on_lane(
+ self.road, lane_index, speed=None, longitudinal=rng.uniform(20, 50)
+ )
self.controlled_vehicles.append(controlled_vehicle)
self.road.vehicles.append(controlled_vehicle)
# Front vehicle
- vehicle = IDMVehicle.make_on_lane(self.road, ("b", "c", lane_index[-1]),
- longitudinal=rng.uniform(
- low=0,
- high=self.road.network.get_lane(("b", "c", 0)).length
- ),
- speed=6+rng.uniform(high=3))
+ vehicle = IDMVehicle.make_on_lane(
+ self.road,
+ ("b", "c", lane_index[-1]),
+ longitudinal=rng.uniform(
+ low=0, high=self.road.network.get_lane(("b", "c", 0)).length
+ ),
+ speed=6 + rng.uniform(high=3),
+ )
self.road.vehicles.append(vehicle)
# Other vehicles
for i in range(rng.integers(self.config["other_vehicles"])):
random_lane_index = self.road.network.random_lane_index(rng)
- vehicle = IDMVehicle.make_on_lane(self.road, random_lane_index,
- longitudinal=rng.uniform(
- low=0,
- high=self.road.network.get_lane(random_lane_index).length
- ),
- speed=6+rng.uniform(high=3))
+ vehicle = IDMVehicle.make_on_lane(
+ self.road,
+ random_lane_index,
+ longitudinal=rng.uniform(
+ low=0, high=self.road.network.get_lane(random_lane_index).length
+ ),
+ speed=6 + rng.uniform(high=3),
+ )
# Prevent early collisions
for v in self.road.vehicles:
if np.linalg.norm(vehicle.position - v.position) < 20:
diff --git a/main/_modules/highway_env/envs/roundabout_env/index.html b/main/_modules/highway_env/envs/roundabout_env/index.html
index 3a57c6659..3cfc3332e 100644
--- a/main/_modules/highway_env/envs/roundabout_env/index.html
+++ b/main/_modules/highway_env/envs/roundabout_env/index.html
@@ -291,13 +291,13 @@
Source code for highway_env.envs.roundabout_env
-from typing import Tuple, Dict, Text
+from typing import Dict, Text
import numpy as np
from highway_env import utils
from highway_env.envs.common.abstract import AbstractEnv
-from highway_env.road.lane import LineType, StraightLane, CircularLane, SineLane
+from highway_env.road.lane import CircularLane, LineType, SineLane, StraightLane
from highway_env.road.road import Road, RoadNetwork
from highway_env.vehicle.controller import MDPVehicle
@@ -305,51 +305,60 @@ Source code for highway_env.envs.roundabout_env
<
[docs]
class RoundaboutEnv(AbstractEnv):
-
[docs]
@classmethod
def default_config(cls) -> dict:
config = super().default_config()
-
config.update({
-
"observation": {
-
"type": "Kinematics",
-
"absolute": True,
-
"features_range": {"x": [-100, 100], "y": [-100, 100], "vx": [-15, 15], "vy": [-15, 15]},
-
},
-
"action": {
-
"type": "DiscreteMetaAction",
-
"target_speeds": [0, 8, 16]
-
},
-
"incoming_vehicle_destination": None,
-
"collision_reward": -1,
-
"high_speed_reward": 0.2,
-
"right_lane_reward": 0,
-
"lane_change_reward": -0.05,
-
"screen_width": 600,
-
"screen_height": 600,
-
"centering_position": [0.5, 0.6],
-
"duration": 11,
-
"normalize_reward": True
-
})
+
config.update(
+
{
+
"observation": {
+
"type": "Kinematics",
+
"absolute": True,
+
"features_range": {
+
"x": [-100, 100],
+
"y": [-100, 100],
+
"vx": [-15, 15],
+
"vy": [-15, 15],
+
},
+
},
+
"action": {"type": "DiscreteMetaAction", "target_speeds": [0, 8, 16]},
+
"incoming_vehicle_destination": None,
+
"collision_reward": -1,
+
"high_speed_reward": 0.2,
+
"right_lane_reward": 0,
+
"lane_change_reward": -0.05,
+
"screen_width": 600,
+
"screen_height": 600,
+
"centering_position": [0.5, 0.6],
+
"duration": 11,
+
"normalize_reward": True,
+
}
+
)
return config
def _reward(self, action: int) -> float:
rewards = self._rewards(action)
-
reward = sum(self.config.get(name, 0) * reward for name, reward in rewards.items())
+
reward = sum(
+
self.config.get(name, 0) * reward for name, reward in rewards.items()
+
)
if self.config["normalize_reward"]:
-
reward = utils.lmap(reward, [self.config["collision_reward"], self.config["high_speed_reward"]], [0, 1])
+
reward = utils.lmap(
+
reward,
+
[self.config["collision_reward"], self.config["high_speed_reward"]],
+
[0, 1],
+
)
reward *= rewards["on_road_reward"]
return reward
def _rewards(self, action: int) -> Dict[Text, float]:
return {
"collision_reward": self.vehicle.crashed,
-
"high_speed_reward":
-
MDPVehicle.get_speed_index(self.vehicle) / (MDPVehicle.DEFAULT_TARGET_SPEEDS.size - 1),
+
"high_speed_reward": MDPVehicle.get_speed_index(self.vehicle)
+
/ (MDPVehicle.DEFAULT_TARGET_SPEEDS.size - 1),
"lane_change_reward": action in [0, 2],
-
"on_road_reward": self.vehicle.on_road
+
"on_road_reward": self.vehicle.on_road,
}
def _is_terminated(self) -> bool:
@@ -369,64 +378,244 @@
Source code for highway_env.envs.roundabout_env
<
alpha = 24 # [deg]
net = RoadNetwork()
-
radii = [radius, radius+4]
+
radii = [radius, radius + 4]
n, c, s = LineType.NONE, LineType.CONTINUOUS, LineType.STRIPED
line = [[c, s], [n, c]]
for lane in [0, 1]:
-
net.add_lane("se", "ex",
-
CircularLane(center, radii[lane], np.deg2rad(90 - alpha), np.deg2rad(alpha),
-
clockwise=False, line_types=line[lane]))
-
net.add_lane("ex", "ee",
-
CircularLane(center, radii[lane], np.deg2rad(alpha), np.deg2rad(-alpha),
-
clockwise=False, line_types=line[lane]))
-
net.add_lane("ee", "nx",
-
CircularLane(center, radii[lane], np.deg2rad(-alpha), np.deg2rad(-90 + alpha),
-
clockwise=False, line_types=line[lane]))
-
net.add_lane("nx", "ne",
-
CircularLane(center, radii[lane], np.deg2rad(-90 + alpha), np.deg2rad(-90 - alpha),
-
clockwise=False, line_types=line[lane]))
-
net.add_lane("ne", "wx",
-
CircularLane(center, radii[lane], np.deg2rad(-90 - alpha), np.deg2rad(-180 + alpha),
-
clockwise=False, line_types=line[lane]))
-
net.add_lane("wx", "we",
-
CircularLane(center, radii[lane], np.deg2rad(-180 + alpha), np.deg2rad(-180 - alpha),
-
clockwise=False, line_types=line[lane]))
-
net.add_lane("we", "sx",
-
CircularLane(center, radii[lane], np.deg2rad(180 - alpha), np.deg2rad(90 + alpha),
-
clockwise=False, line_types=line[lane]))
-
net.add_lane("sx", "se",
-
CircularLane(center, radii[lane], np.deg2rad(90 + alpha), np.deg2rad(90 - alpha),
-
clockwise=False, line_types=line[lane]))
+
net.add_lane(
+
"se",
+
"ex",
+
CircularLane(
+
center,
+
radii[lane],
+
np.deg2rad(90 - alpha),
+
np.deg2rad(alpha),
+
clockwise=False,
+
line_types=line[lane],
+
),
+
)
+
net.add_lane(
+
"ex",
+
"ee",
+
CircularLane(
+
center,
+
radii[lane],
+
np.deg2rad(alpha),
+
np.deg2rad(-alpha),
+
clockwise=False,
+
line_types=line[lane],
+
),
+
)
+
net.add_lane(
+
"ee",
+
"nx",
+
CircularLane(
+
center,
+
radii[lane],
+
np.deg2rad(-alpha),
+
np.deg2rad(-90 + alpha),
+
clockwise=False,
+
line_types=line[lane],
+
),
+
)
+
net.add_lane(
+
"nx",
+
"ne",
+
CircularLane(
+
center,
+
radii[lane],
+
np.deg2rad(-90 + alpha),
+
np.deg2rad(-90 - alpha),
+
clockwise=False,
+
line_types=line[lane],
+
),
+
)
+
net.add_lane(
+
"ne",
+
"wx",
+
CircularLane(
+
center,
+
radii[lane],
+
np.deg2rad(-90 - alpha),
+
np.deg2rad(-180 + alpha),
+
clockwise=False,
+
line_types=line[lane],
+
),
+
)
+
net.add_lane(
+
"wx",
+
"we",
+
CircularLane(
+
center,
+
radii[lane],
+
np.deg2rad(-180 + alpha),
+
np.deg2rad(-180 - alpha),
+
clockwise=False,
+
line_types=line[lane],
+
),
+
)
+
net.add_lane(
+
"we",
+
"sx",
+
CircularLane(
+
center,
+
radii[lane],
+
np.deg2rad(180 - alpha),
+
np.deg2rad(90 + alpha),
+
clockwise=False,
+
line_types=line[lane],
+
),
+
)
+
net.add_lane(
+
"sx",
+
"se",
+
CircularLane(
+
center,
+
radii[lane],
+
np.deg2rad(90 + alpha),
+
np.deg2rad(90 - alpha),
+
clockwise=False,
+
line_types=line[lane],
+
),
+
)
# Access lanes: (r)oad/(s)ine
access = 170 # [m]
dev = 85 # [m]
a = 5 # [m]
-
delta_st = 0.2*dev # [m]
-
-
delta_en = dev-delta_st
-
w = 2*np.pi/dev
-
net.add_lane("ser", "ses", StraightLane([2, access], [2, dev/2], line_types=(s, c)))
-
net.add_lane("ses", "se", SineLane([2+a, dev/2], [2+a, dev/2-delta_st], a, w, -np.pi/2, line_types=(c, c)))
-
net.add_lane("sx", "sxs", SineLane([-2-a, -dev/2+delta_en], [-2-a, dev/2], a, w, -np.pi/2+w*delta_en, line_types=(c, c)))
-
net.add_lane("sxs", "sxr", StraightLane([-2, dev / 2], [-2, access], line_types=(n, c)))
-
-
net.add_lane("eer", "ees", StraightLane([access, -2], [dev / 2, -2], line_types=(s, c)))
-
net.add_lane("ees", "ee", SineLane([dev / 2, -2-a], [dev / 2 - delta_st, -2-a], a, w, -np.pi / 2, line_types=(c, c)))
-
net.add_lane("ex", "exs", SineLane([-dev / 2 + delta_en, 2+a], [dev / 2, 2+a], a, w, -np.pi / 2 + w * delta_en, line_types=(c, c)))
-
net.add_lane("exs", "exr", StraightLane([dev / 2, 2], [access, 2], line_types=(n, c)))
-
-
net.add_lane("ner", "nes", StraightLane([-2, -access], [-2, -dev / 2], line_types=(s, c)))
-
net.add_lane("nes", "ne", SineLane([-2 - a, -dev / 2], [-2 - a, -dev / 2 + delta_st], a, w, -np.pi / 2, line_types=(c, c)))
-
net.add_lane("nx", "nxs", SineLane([2 + a, dev / 2 - delta_en], [2 + a, -dev / 2], a, w, -np.pi / 2 + w * delta_en, line_types=(c, c)))
-
net.add_lane("nxs", "nxr", StraightLane([2, -dev / 2], [2, -access], line_types=(n, c)))
-
-
net.add_lane("wer", "wes", StraightLane([-access, 2], [-dev / 2, 2], line_types=(s, c)))
-
net.add_lane("wes", "we", SineLane([-dev / 2, 2+a], [-dev / 2 + delta_st, 2+a], a, w, -np.pi / 2, line_types=(c, c)))
-
net.add_lane("wx", "wxs", SineLane([dev / 2 - delta_en, -2-a], [-dev / 2, -2-a], a, w, -np.pi / 2 + w * delta_en, line_types=(c, c)))
-
net.add_lane("wxs", "wxr", StraightLane([-dev / 2, -2], [-access, -2], line_types=(n, c)))
-
-
road = Road(network=net, np_random=self.np_random, record_history=self.config["show_trajectories"])
+
delta_st = 0.2 * dev # [m]
+
+
delta_en = dev - delta_st
+
w = 2 * np.pi / dev
+
net.add_lane(
+
"ser", "ses", StraightLane([2, access], [2, dev / 2], line_types=(s, c))
+
)
+
net.add_lane(
+
"ses",
+
"se",
+
SineLane(
+
[2 + a, dev / 2],
+
[2 + a, dev / 2 - delta_st],
+
a,
+
w,
+
-np.pi / 2,
+
line_types=(c, c),
+
),
+
)
+
net.add_lane(
+
"sx",
+
"sxs",
+
SineLane(
+
[-2 - a, -dev / 2 + delta_en],
+
[-2 - a, dev / 2],
+
a,
+
w,
+
-np.pi / 2 + w * delta_en,
+
line_types=(c, c),
+
),
+
)
+
net.add_lane(
+
"sxs", "sxr", StraightLane([-2, dev / 2], [-2, access], line_types=(n, c))
+
)
+
+
net.add_lane(
+
"eer", "ees", StraightLane([access, -2], [dev / 2, -2], line_types=(s, c))
+
)
+
net.add_lane(
+
"ees",
+
"ee",
+
SineLane(
+
[dev / 2, -2 - a],
+
[dev / 2 - delta_st, -2 - a],
+
a,
+
w,
+
-np.pi / 2,
+
line_types=(c, c),
+
),
+
)
+
net.add_lane(
+
"ex",
+
"exs",
+
SineLane(
+
[-dev / 2 + delta_en, 2 + a],
+
[dev / 2, 2 + a],
+
a,
+
w,
+
-np.pi / 2 + w * delta_en,
+
line_types=(c, c),
+
),
+
)
+
net.add_lane(
+
"exs", "exr", StraightLane([dev / 2, 2], [access, 2], line_types=(n, c))
+
)
+
+
net.add_lane(
+
"ner", "nes", StraightLane([-2, -access], [-2, -dev / 2], line_types=(s, c))
+
)
+
net.add_lane(
+
"nes",
+
"ne",
+
SineLane(
+
[-2 - a, -dev / 2],
+
[-2 - a, -dev / 2 + delta_st],
+
a,
+
w,
+
-np.pi / 2,
+
line_types=(c, c),
+
),
+
)
+
net.add_lane(
+
"nx",
+
"nxs",
+
SineLane(
+
[2 + a, dev / 2 - delta_en],
+
[2 + a, -dev / 2],
+
a,
+
w,
+
-np.pi / 2 + w * delta_en,
+
line_types=(c, c),
+
),
+
)
+
net.add_lane(
+
"nxs", "nxr", StraightLane([2, -dev / 2], [2, -access], line_types=(n, c))
+
)
+
+
net.add_lane(
+
"wer", "wes", StraightLane([-access, 2], [-dev / 2, 2], line_types=(s, c))
+
)
+
net.add_lane(
+
"wes",
+
"we",
+
SineLane(
+
[-dev / 2, 2 + a],
+
[-dev / 2 + delta_st, 2 + a],
+
a,
+
w,
+
-np.pi / 2,
+
line_types=(c, c),
+
),
+
)
+
net.add_lane(
+
"wx",
+
"wxs",
+
SineLane(
+
[dev / 2 - delta_en, -2 - a],
+
[-dev / 2, -2 - a],
+
a,
+
w,
+
-np.pi / 2 + w * delta_en,
+
line_types=(c, c),
+
),
+
)
+
net.add_lane(
+
"wxs", "wxr", StraightLane([-dev / 2, -2], [-access, -2], line_types=(n, c))
+
)
+
+
road = Road(
+
network=net,
+
np_random=self.np_random,
+
record_history=self.config["show_trajectories"],
+
)
self.road = road
def _make_vehicles(self) -> None:
@@ -440,10 +629,12 @@
Source code for highway_env.envs.roundabout_env
<
# Ego-vehicle
ego_lane = self.road.network.get_lane(("ser", "ses", 0))
-
ego_vehicle = self.action_type.vehicle_class(self.road,
-
ego_lane.position(125, 0),
-
speed=8,
-
heading=ego_lane.heading_at(140))
+
ego_vehicle = self.action_type.vehicle_class(
+
self.road,
+
ego_lane.position(125, 0),
+
speed=8,
+
heading=ego_lane.heading_at(140),
+
)
try:
ego_vehicle.plan_route_to("nxs")
except AttributeError:
@@ -454,10 +645,12 @@
Source code for highway_env.envs.roundabout_env
<
# Incoming vehicle
destinations = ["exr", "sxr", "nxr"]
other_vehicles_type = utils.class_from_path(self.config["other_vehicles_type"])
-
vehicle = other_vehicles_type.make_on_lane(self.road,
-
("we", "sx", 1),
-
longitudinal=5 + self.np_random.normal()*position_deviation,
-
speed=16 + self.np_random.normal() * speed_deviation)
+
vehicle = other_vehicles_type.make_on_lane(
+
self.road,
+
("we", "sx", 1),
+
longitudinal=5 + self.np_random.normal() * position_deviation,
+
speed=16 + self.np_random.normal() * speed_deviation,
+
)
if self.config["incoming_vehicle_destination"] is not None:
destination = destinations[self.config["incoming_vehicle_destination"]]
@@ -469,19 +662,23 @@
Source code for highway_env.envs.roundabout_env
<
# Other vehicles
for i in list(range(1, 2)) + list(range(-1, 0)):
- vehicle = other_vehicles_type.make_on_lane(self.road,
- ("we", "sx", 0),
- longitudinal=20*i + self.np_random.normal()*position_deviation,
- speed=16 + self.np_random.normal() * speed_deviation)
+ vehicle = other_vehicles_type.make_on_lane(
+ self.road,
+ ("we", "sx", 0),
+ longitudinal=20 * i + self.np_random.normal() * position_deviation,
+ speed=16 + self.np_random.normal() * speed_deviation,
+ )
vehicle.plan_route_to(self.np_random.choice(destinations))
vehicle.randomize_behavior()
self.road.vehicles.append(vehicle)
# Entering vehicle
- vehicle = other_vehicles_type.make_on_lane(self.road,
- ("eer", "ees", 0),
- longitudinal=50 + self.np_random.normal() * position_deviation,
- speed=16 + self.np_random.normal() * speed_deviation)
+ vehicle = other_vehicles_type.make_on_lane(
+ self.road,
+ ("eer", "ees", 0),
+ longitudinal=50 + self.np_random.normal() * position_deviation,
+ speed=16 + self.np_random.normal() * speed_deviation,
+ )
vehicle.plan_route_to(self.np_random.choice(destinations))
vehicle.randomize_behavior()
self.road.vehicles.append(vehicle)
diff --git a/main/_modules/highway_env/road/graphics/index.html b/main/_modules/highway_env/road/graphics/index.html
index df859a6f1..4c5559c42 100644
--- a/main/_modules/highway_env/road/graphics/index.html
+++ b/main/_modules/highway_env/road/graphics/index.html
@@ -291,16 +291,16 @@
Source code for highway_env.road.graphics
-from typing import List, Tuple, Union, TYPE_CHECKING
+from typing import TYPE_CHECKING, List, Tuple, Union
import numpy as np
import pygame
-from highway_env.road.lane import LineType, AbstractLane
+from highway_env.road.lane import AbstractLane, LineType
from highway_env.road.road import Road
from highway_env.utils import Vector
from highway_env.vehicle.graphics import VehicleGraphics
-from highway_env.vehicle.objects import Obstacle, Landmark
+from highway_env.vehicle.objects import Landmark, Obstacle
if TYPE_CHECKING:
from highway_env.vehicle.objects import RoadObject
@@ -324,7 +324,9 @@ Source code for highway_env.road.graphics
SCALING_FACTOR = 1.3
MOVING_FACTOR = 0.1
- def __init__(self, size: Tuple[int, int], flags: object, surf: pygame.SurfaceType) -> None:
+ def __init__(
+ self, size: Tuple[int, int], flags: object, surf: pygame.SurfaceType
+ ) -> None:
super().__init__(size, flags, surf)
self.origin = np.array([0, 0])
self.scaling = self.INITIAL_SCALING
@@ -377,7 +379,10 @@ Source code for highway_env.road.graphics
:return: whether the position is visible
"""
x, y = self.vec2pix(vec)
- return -margin < x < self.get_width() + margin and -margin < y < self.get_height() + margin
+ return (
+ -margin < x < self.get_width() + margin
+ and -margin < y < self.get_height() + margin
+ )
@@ -389,8 +394,11 @@
Source code for highway_env.road.graphics
:param position: a world position [m]
"""
self.origin = position - np.array(
- [self.centering_position[0] * self.get_width() / self.scaling,
- self.centering_position[1] * self.get_height() / self.scaling])
+
[
+
self.centering_position[0] * self.get_width() / self.scaling,
+
self.centering_position[1] * self.get_height() / self.scaling,
+
]
+
)
@@ -440,9 +448,15 @@
Source code for highway_env.road.graphics
:param lane: the lane to be displayed
:param surface: the pygame surface
"""
- stripes_count = int(2 * (surface.get_height() + surface.get_width()) / (cls.STRIPE_SPACING * surface.scaling))
+ stripes_count = int(
+ 2
+ * (surface.get_height() + surface.get_width())
+ / (cls.STRIPE_SPACING * surface.scaling)
+ )
s_origin, _ = lane.local_coordinates(surface.origin)
- s0 = (int(s_origin) // cls.STRIPE_SPACING - stripes_count // 2) * cls.STRIPE_SPACING
+ s0 = (
+ int(s_origin) // cls.STRIPE_SPACING - stripes_count // 2
+ ) * cls.STRIPE_SPACING
for side in range(2):
if lane.line_types[side] == LineType.STRIPED:
cls.striped_line(lane, surface, stripes_count, s0, side)
@@ -455,8 +469,14 @@ Source code for highway_env.road.graphics
[docs]
@classmethod
-
def striped_line(cls, lane: AbstractLane, surface: WorldSurface, stripes_count: int, longitudinal: float,
-
side: int) -> None:
+
def striped_line(
+
cls,
+
lane: AbstractLane,
+
surface: WorldSurface,
+
stripes_count: int,
+
longitudinal: float,
+
side: int,
+
) -> None:
"""
Draw a striped line on one side of a lane, on a surface.
@@ -467,7 +487,11 @@
Source code for highway_env.road.graphics
:param side: which side of the road to draw [0:left, 1:right]
"""
starts = longitudinal + np.arange(stripes_count) * cls.STRIPE_SPACING
- ends = longitudinal + np.arange(stripes_count) * cls.STRIPE_SPACING + cls.STRIPE_LENGTH
+ ends = (
+ longitudinal
+ + np.arange(stripes_count) * cls.STRIPE_SPACING
+ + cls.STRIPE_LENGTH
+ )
lats = [(side - 0.5) * lane.width_at(s) for s in starts]
cls.draw_stripes(lane, surface, starts, ends, lats)
@@ -475,8 +499,14 @@
Source code for highway_env.road.graphics
[docs]
@classmethod
-
def continuous_curve(cls, lane: AbstractLane, surface: WorldSurface, stripes_count: int,
-
longitudinal: float, side: int) -> None:
+
def continuous_curve(
+
cls,
+
lane: AbstractLane,
+
surface: WorldSurface,
+
stripes_count: int,
+
longitudinal: float,
+
side: int,
+
) -> None:
"""
Draw a striped line on one side of a lane, on a surface.
@@ -487,7 +517,11 @@
Source code for highway_env.road.graphics
:param side: which side of the road to draw [0:left, 1:right]
"""
starts = longitudinal + np.arange(stripes_count) * cls.STRIPE_SPACING
- ends = longitudinal + np.arange(stripes_count) * cls.STRIPE_SPACING + cls.STRIPE_SPACING
+ ends = (
+ longitudinal
+ + np.arange(stripes_count) * cls.STRIPE_SPACING
+ + cls.STRIPE_SPACING
+ )
lats = [(side - 0.5) * lane.width_at(s) for s in starts]
cls.draw_stripes(lane, surface, starts, ends, lats)
@@ -495,8 +529,14 @@
Source code for highway_env.road.graphics
[docs]
@classmethod
-
def continuous_line(cls, lane: AbstractLane, surface: WorldSurface, stripes_count: int, longitudinal: float,
-
side: int) -> None:
+
def continuous_line(
+
cls,
+
lane: AbstractLane,
+
surface: WorldSurface,
+
stripes_count: int,
+
longitudinal: float,
+
side: int,
+
) -> None:
"""
Draw a continuous line on one side of a lane, on a surface.
@@ -515,8 +555,14 @@
Source code for highway_env.road.graphics
[docs]
@classmethod
-
def draw_stripes(cls, lane: AbstractLane, surface: WorldSurface,
-
starts: List[float], ends: List[float], lats: List[float]) -> None:
+
def draw_stripes(
+
cls,
+
lane: AbstractLane,
+
surface: WorldSurface,
+
starts: List[float],
+
ends: List[float],
+
lats: List[float],
+
) -> None:
"""
Draw a set of stripes along a lane.
@@ -530,24 +576,44 @@
Source code for highway_env.road.graphics
ends = np.clip(ends, 0, lane.length)
for k, _ in enumerate(starts):
if abs(starts[k] - ends[k]) > 0.5 * cls.STRIPE_LENGTH:
- pygame.draw.line(surface, surface.WHITE,
- (surface.vec2pix(lane.position(starts[k], lats[k]))),
- (surface.vec2pix(lane.position(ends[k], lats[k]))),
- max(surface.pix(cls.STRIPE_WIDTH), 1))
+
pygame.draw.line(
+
surface,
+
surface.WHITE,
+
(surface.vec2pix(lane.position(starts[k], lats[k]))),
+
(surface.vec2pix(lane.position(ends[k], lats[k]))),
+
max(surface.pix(cls.STRIPE_WIDTH), 1),
+
)
@classmethod
- def draw_ground(cls, lane: AbstractLane, surface: WorldSurface, color: Tuple[float], width: float,
- draw_surface: pygame.Surface = None) -> None:
+ def draw_ground(
+ cls,
+ lane: AbstractLane,
+ surface: WorldSurface,
+ color: Tuple[float],
+ width: float,
+ draw_surface: pygame.Surface = None,
+ ) -> None:
draw_surface = draw_surface or surface
- stripes_count = int(2 * (surface.get_height() + surface.get_width()) / (cls.STRIPE_SPACING * surface.scaling))
+ stripes_count = int(
+ 2
+ * (surface.get_height() + surface.get_width())
+ / (cls.STRIPE_SPACING * surface.scaling)
+ )
s_origin, _ = lane.local_coordinates(surface.origin)
- s0 = (int(s_origin) // cls.STRIPE_SPACING - stripes_count // 2) * cls.STRIPE_SPACING
+ s0 = (
+ int(s_origin) // cls.STRIPE_SPACING - stripes_count // 2
+ ) * cls.STRIPE_SPACING
dots = []
for side in range(2):
- longis = np.clip(s0 + np.arange(stripes_count) * cls.STRIPE_SPACING, 0, lane.length)
+ longis = np.clip(
+ s0 + np.arange(stripes_count) * cls.STRIPE_SPACING, 0, lane.length
+ )
lats = [2 * (side - 0.5) * width for _ in longis]
- new_dots = [surface.vec2pix(lane.position(longi, lat)) for longi, lat in zip(longis, lats)]
+ new_dots = [
+ surface.vec2pix(lane.position(longi, lat))
+ for longi, lat in zip(longis, lats)
+ ]
new_dots = reversed(new_dots) if side else new_dots
dots.extend(new_dots)
pygame.draw.polygon(draw_surface, color, dots, 0)
@@ -580,8 +646,12 @@
Source code for highway_env.road.graphics
[docs]
@staticmethod
-
def display_traffic(road: Road, surface: WorldSurface, simulation_frequency: int = 15, offscreen: bool = False) \
-
-> None:
+
def display_traffic(
+
road: Road,
+
surface: WorldSurface,
+
simulation_frequency: int = 15,
+
offscreen: bool = False,
+
) -> None:
"""
Display the road vehicles on a surface.
@@ -592,7 +662,9 @@
Source code for highway_env.road.graphics
"""
if road.record_history:
for v in road.vehicles:
- VehicleGraphics.display_history(v, surface, simulation=simulation_frequency, offscreen=offscreen)
+ VehicleGraphics.display_history(
+ v, surface, simulation=simulation_frequency, offscreen=offscreen
+ )
for v in road.vehicles:
VehicleGraphics.display(v, surface, offscreen=offscreen)
@@ -600,7 +672,9 @@
Source code for highway_env.road.graphics
[docs]
@staticmethod
-
def display_road_objects(road: Road, surface: WorldSurface, offscreen: bool = False) -> None:
+
def display_road_objects(
+
road: Road, surface: WorldSurface, offscreen: bool = False
+
) -> None:
"""
Display the road objects on a surface.
@@ -630,8 +704,13 @@
Source code for highway_env.road.graphics
[docs]
@classmethod
-
def display(cls, object_: 'RoadObject', surface: WorldSurface, transparent: bool = False,
-
offscreen: bool = False):
+
def display(
+
cls,
+
object_: "RoadObject",
+
surface: WorldSurface,
+
transparent: bool = False,
+
offscreen: bool = False,
+
):
"""
Display a road objects on a pygame surface.
@@ -643,30 +722,51 @@
Source code for highway_env.road.graphics
:param offscreen: whether the rendering should be done offscreen or not
"""
o = object_
- s = pygame.Surface((surface.pix(o.LENGTH), surface.pix(o.LENGTH)), pygame.SRCALPHA) # per-pixel alpha
- rect = (0, surface.pix(o.LENGTH / 2 - o.WIDTH / 2), surface.pix(o.LENGTH), surface.pix(o.WIDTH))
+ s = pygame.Surface(
+ (surface.pix(o.LENGTH), surface.pix(o.LENGTH)), pygame.SRCALPHA
+ ) # per-pixel alpha
+ rect = (
+ 0,
+ surface.pix(o.LENGTH / 2 - o.WIDTH / 2),
+ surface.pix(o.LENGTH),
+ surface.pix(o.WIDTH),
+ )
pygame.draw.rect(s, cls.get_color(o, transparent), rect, 0)
pygame.draw.rect(s, cls.BLACK, rect, 1)
- if not offscreen: # convert_alpha throws errors in offscreen mode TODO() Explain why
+ if (
+ not offscreen
+ ): # convert_alpha throws errors in offscreen mode TODO() Explain why
s = pygame.Surface.convert_alpha(s)
h = o.heading if abs(o.heading) > 2 * np.pi / 180 else 0
# Centered rotation
- position = (surface.pos2pix(o.position[0], o.position[1]))
+ position = surface.pos2pix(o.position[0], o.position[1])
cls.blit_rotate(surface, s, position, np.rad2deg(-h))
[docs]
@staticmethod
-
def blit_rotate(surf: pygame.SurfaceType, image: pygame.SurfaceType, pos: Vector, angle: float,
-
origin_pos: Vector = None, show_rect: bool = False) -> None:
+
def blit_rotate(
+
surf: pygame.SurfaceType,
+
image: pygame.SurfaceType,
+
pos: Vector,
+
angle: float,
+
origin_pos: Vector = None,
+
show_rect: bool = False,
+
) -> None:
"""Many thanks to https://stackoverflow.com/a/54714144."""
# calculate the axis aligned bounding box of the rotated image
w, h = image.get_size()
box = [pygame.math.Vector2(p) for p in [(0, 0), (w, 0), (w, -h), (0, -h)]]
box_rotate = [p.rotate(angle) for p in box]
-
min_box = (min(box_rotate, key=lambda p: p[0])[0], min(box_rotate, key=lambda p: p[1])[1])
-
max_box = (max(box_rotate, key=lambda p: p[0])[0], max(box_rotate, key=lambda p: p[1])[1])
+
min_box = (
+
min(box_rotate, key=lambda p: p[0])[0],
+
min(box_rotate, key=lambda p: p[1])[1],
+
)
+
max_box = (
+
max(box_rotate, key=lambda p: p[0])[0],
+
max(box_rotate, key=lambda p: p[1])[1],
+
)
# calculate the translation of the pivot
if origin_pos is None:
@@ -676,8 +776,10 @@
Source code for highway_env.road.graphics
pivot_move = pivot_rotate - pivot
# calculate the upper left origin of the rotated image
- origin = (pos[0] - origin_pos[0] + min_box[0] - pivot_move[0],
- pos[1] - origin_pos[1] - max_box[1] + pivot_move[1])
+ origin = (
+ pos[0] - origin_pos[0] + min_box[0] - pivot_move[0],
+ pos[1] - origin_pos[1] - max_box[1] + pivot_move[1],
+ )
# get a rotated image
rotated_image = pygame.transform.rotate(image, angle)
# rotate and blit the image
@@ -688,7 +790,7 @@ Source code for highway_env.road.graphics
@classmethod
- def get_color(cls, object_: 'RoadObject', transparent: bool = False):
+ def get_color(cls, object_: "RoadObject", transparent: bool = False):
color = cls.DEFAULT_COLOR
if isinstance(object_, Obstacle):
diff --git a/main/_modules/highway_env/road/lane/index.html b/main/_modules/highway_env/road/lane/index.html
index 1ef36e035..16f1a748b 100644
--- a/main/_modules/highway_env/road/lane/index.html
+++ b/main/_modules/highway_env/road/lane/index.html
@@ -292,13 +292,13 @@
Source code for highway_env.road.lane
from abc import ABCMeta, abstractmethod
-from copy import deepcopy
-from typing import Tuple, List, Optional, Union
+from typing import List, Optional, Tuple, Union
+
import numpy as np
from highway_env import utils
from highway_env.road.spline import LinearSpline2D
-from highway_env.utils import wrap_to_pi, Vector, get_class_path, class_from_path
+from highway_env.utils import Vector, class_from_path, get_class_path, wrap_to_pi
@@ -392,8 +392,13 @@
Source code for highway_env.road.lane
[docs]
-
def on_lane(self, position: np.ndarray, longitudinal: float = None, lateral: float = None, margin: float = 0) \
-
-> bool:
+
def on_lane(
+
self,
+
position: np.ndarray,
+
longitudinal: float = None,
+
lateral: float = None,
+
margin: float = 0,
+
) -> bool:
"""
Whether a given world position is on the lane.
@@ -405,8 +410,10 @@
Source code for highway_env.road.lane
"""
if longitudinal is None or lateral is None:
longitudinal, lateral = self.local_coordinates(position)
- is_on = np.abs(lateral) <= self.width_at(longitudinal) / 2 + margin and \
- -self.VEHICLE_LENGTH <= longitudinal < self.length + self.VEHICLE_LENGTH
+ is_on = (
+ np.abs(lateral) <= self.width_at(longitudinal) / 2 + margin
+ and -self.VEHICLE_LENGTH <= longitudinal < self.length + self.VEHICLE_LENGTH
+ )
return is_on
@@ -422,12 +429,16 @@
Source code for highway_env.road.lane
if self.forbidden:
return False
longitudinal, lateral = self.local_coordinates(position)
- is_close = np.abs(lateral) <= 2 * self.width_at(longitudinal) and \
- 0 <= longitudinal < self.length + self.VEHICLE_LENGTH
+ is_close = (
+ np.abs(lateral) <= 2 * self.width_at(longitudinal)
+ and 0 <= longitudinal < self.length + self.VEHICLE_LENGTH
+ )
return is_close
-
def after_end(self, position: np.ndarray, longitudinal: float = None, lateral: float = None) -> bool:
+
def after_end(
+
self, position: np.ndarray, longitudinal: float = None, lateral: float = None
+
) -> bool:
if not longitudinal:
longitudinal, _ = self.local_coordinates(position)
return longitudinal > self.length - self.VEHICLE_LENGTH / 2
@@ -442,13 +453,18 @@
Source code for highway_env.road.lane
[docs]
-
def distance_with_heading(self, position: np.ndarray, heading: Optional[float], heading_weight: float = 1.0):
+
def distance_with_heading(
+
self,
+
position: np.ndarray,
+
heading: Optional[float],
+
heading_weight: float = 1.0,
+
):
"""Compute a weighted distance in position and heading to the lane."""
if heading is None:
return self.distance(position)
s, r = self.local_coordinates(position)
angle = np.abs(self.local_angle(heading, s))
-
return abs(r) + max(s - self.length, 0) + max(0 - s, 0) + heading_weight*angle
+ return abs(r) + max(s - self.length, 0) + max(0 - s, 0) + heading_weight * angle
@@ -479,14 +495,16 @@
Source code for highway_env.road.lane
"""A lane going in straight line."""
- def __init__(self,
- start: Vector,
- end: Vector,
- width: float = AbstractLane.DEFAULT_WIDTH,
- line_types: Tuple[LineType, LineType] = None,
- forbidden: bool = False,
- speed_limit: float = 20,
- priority: int = 0) -> None:
+ def __init__(
+ self,
+ start: Vector,
+ end: Vector,
+ width: float = AbstractLane.DEFAULT_WIDTH,
+ line_types: Tuple[LineType, LineType] = None,
+ forbidden: bool = False,
+ speed_limit: float = 20,
+ priority: int = 0,
+ ) -> None:
"""
New straight lane.
@@ -500,7 +518,9 @@ Source code for highway_env.road.lane
self.start = np.array(start)
self.end = np.array(end)
self.width = width
- self.heading = np.arctan2(self.end[1] - self.start[1], self.end[0] - self.start[0])
+ self.heading = np.arctan2(
+ self.end[1] - self.start[1], self.end[0] - self.start[0]
+ )
self.length = np.linalg.norm(self.end - self.start)
self.line_types = line_types or [LineType.STRIPED, LineType.STRIPED]
self.direction = (self.end - self.start) / self.length
@@ -512,7 +532,11 @@ Source code for highway_env.road.lane
[docs]
def position(self, longitudinal: float, lateral: float) -> np.ndarray:
-
return self.start + longitudinal * self.direction + lateral * self.direction_lateral
+ return (
+ self.start
+ + longitudinal * self.direction
+ + lateral * self.direction_lateral
+ )
@@ -557,8 +581,8 @@
Source code for highway_env.road.lane
"line_types": self.line_types,
"forbidden": self.forbidden,
"speed_limit": self.speed_limit,
- "priority": self.priority
- }
+ "priority": self.priority,
+ },
}
@@ -570,17 +594,19 @@ Source code for highway_env.road.lane
"""A sinusoidal lane."""
- def __init__(self,
- start: Vector,
- end: Vector,
- amplitude: float,
- pulsation: float,
- phase: float,
- width: float = StraightLane.DEFAULT_WIDTH,
- line_types: List[LineType] = None,
- forbidden: bool = False,
- speed_limit: float = 20,
- priority: int = 0) -> None:
+ def __init__(
+ self,
+ start: Vector,
+ end: Vector,
+ amplitude: float,
+ pulsation: float,
+ phase: float,
+ width: float = StraightLane.DEFAULT_WIDTH,
+ line_types: List[LineType] = None,
+ forbidden: bool = False,
+ speed_limit: float = 20,
+ priority: int = 0,
+ ) -> None:
"""
New sinusoidal lane.
@@ -590,7 +616,9 @@ Source code for highway_env.road.lane
:param pulsation: the lane pulsation [rad/m]
:param phase: the lane initial phase [rad]
"""
- super().__init__(start, end, width, line_types, forbidden, speed_limit, priority)
+ super().__init__(
+ start, end, width, line_types, forbidden, speed_limit, priority
+ )
self.amplitude = amplitude
self.pulsation = pulsation
self.phase = phase
@@ -598,22 +626,30 @@ Source code for highway_env.road.lane
[docs]
def position(self, longitudinal: float, lateral: float) -> np.ndarray:
-
return super().position(longitudinal,
-
lateral + self.amplitude * np.sin(self.pulsation * longitudinal + self.phase))
+ return super().position(
+ longitudinal,
+ lateral
+ + self.amplitude * np.sin(self.pulsation * longitudinal + self.phase),
+ )
[docs]
def heading_at(self, longitudinal: float) -> float:
return super().heading_at(longitudinal) + np.arctan(
-
self.amplitude * self.pulsation * np.cos(self.pulsation * longitudinal + self.phase))
+ self.amplitude
+ * self.pulsation
+ * np.cos(self.pulsation * longitudinal + self.phase)
+ )
[docs]
def local_coordinates(self, position: np.ndarray) -> Tuple[float, float]:
longitudinal, lateral = super().local_coordinates(position)
-
return longitudinal, lateral - self.amplitude * np.sin(self.pulsation * longitudinal + self.phase)
+ return longitudinal, lateral - self.amplitude * np.sin(
+ self.pulsation * longitudinal + self.phase
+ )
@@ -629,14 +665,18 @@
Source code for highway_env.road.lane
[docs]
def to_config(self) -> dict:
config = super().to_config()
- config.update({
- "class_path": get_class_path(self.__class__),
- })
- config["config"].update({
- "amplitude": self.amplitude,
- "pulsation": self.pulsation,
- "phase": self.phase
- })
+ config.update(
+ {
+ "class_path": get_class_path(self.__class__),
+ }
+ )
+ config["config"].update(
+ {
+ "amplitude": self.amplitude,
+ "pulsation": self.pulsation,
+ "phase": self.phase,
+ }
+ )
return config
@@ -648,17 +688,19 @@ Source code for highway_env.road.lane
"""A lane going in circle arc."""
- def __init__(self,
- center: Vector,
- radius: float,
- start_phase: float,
- end_phase: float,
- clockwise: bool = True,
- width: float = AbstractLane.DEFAULT_WIDTH,
- line_types: List[LineType] = None,
- forbidden: bool = False,
- speed_limit: float = 20,
- priority: int = 0) -> None:
+ def __init__(
+ self,
+ center: Vector,
+ radius: float,
+ start_phase: float,
+ end_phase: float,
+ clockwise: bool = True,
+ width: float = AbstractLane.DEFAULT_WIDTH,
+ line_types: List[LineType] = None,
+ forbidden: bool = False,
+ speed_limit: float = 20,
+ priority: int = 0,
+ ) -> None:
super().__init__()
self.center = np.array(center)
self.radius = radius
@@ -669,7 +711,7 @@ Source code for highway_env.road.lane
self.width = width
self.line_types = line_types or [LineType.STRIPED, LineType.STRIPED]
self.forbidden = forbidden
- self.length = radius*(end_phase - start_phase) * self.direction
+ self.length = radius * (end_phase - start_phase) * self.direction
self.priority = priority
self.speed_limit = speed_limit
@@ -677,14 +719,16 @@ Source code for highway_env.road.lane
[docs]
def position(self, longitudinal: float, lateral: float) -> np.ndarray:
phi = self.direction * longitudinal / self.radius + self.start_phase
- return self.center + (self.radius - lateral * self.direction)*np.array([np.cos(phi), np.sin(phi)])
+ return self.center + (self.radius - lateral * self.direction) * np.array(
+ [np.cos(phi), np.sin(phi)]
+ )
[docs]
def heading_at(self, longitudinal: float) -> float:
phi = self.direction * longitudinal / self.radius + self.start_phase
-
psi = phi + np.pi/2 * self.direction
+
psi = phi + np.pi / 2 * self.direction
return psi
@@ -701,8 +745,8 @@ Source code for highway_env.road.lane
phi = np.arctan2(delta[1], delta[0])
phi = self.start_phase + utils.wrap_to_pi(phi - self.start_phase)
r = np.linalg.norm(delta)
- longitudinal = self.direction*(phi - self.start_phase)*self.radius
- lateral = self.direction*(self.radius - r)
+ longitudinal = self.direction * (phi - self.start_phase) * self.radius
+ lateral = self.direction * (self.radius - r)
return longitudinal, lateral
@@ -729,8 +773,8 @@ Source code for highway_env.road.lane
"line_types": self.line_types,
"forbidden": self.forbidden,
"speed_limit": self.speed_limit,
- "priority": self.priority
- }
+ "priority": self.priority,
+ },
}
diff --git a/main/_modules/highway_env/road/regulation/index.html b/main/_modules/highway_env/road/regulation/index.html
index 57b24d8a7..f890dc602 100644
--- a/main/_modules/highway_env/road/regulation/index.html
+++ b/main/_modules/highway_env/road/regulation/index.html
@@ -298,7 +298,8 @@ Source code for highway_env.road.regulation
from highway_env import utils
from highway_env.road.road import Road, RoadNetwork
from highway_env.vehicle.controller import ControlledVehicle, MDPVehicle
-from highway_env.vehicle.kinematics import Vehicle, Obstacle
+from highway_env.vehicle.kinematics import Vehicle
+from highway_env.vehicle.objects import Obstacle
@@ -306,10 +307,16 @@
Source code for highway_env.road.regulation
class RegulatedRoad(Road):
YIELDING_COLOR: Tuple[float, float, float] = None
REGULATION_FREQUENCY: int = 2
- YIELD_DURATION: float = 0.
-
- def __init__(self, network: RoadNetwork = None, vehicles: List[Vehicle] = None, obstacles: List[Obstacle] = None,
- np_random: np.random.RandomState = None, record_history: bool = False) -> None:
+ YIELD_DURATION: float = 0.0
+
+ def __init__(
+ self,
+ network: RoadNetwork = None,
+ vehicles: List[Vehicle] = None,
+ obstacles: List[Obstacle] = None,
+ np_random: np.random.RandomState = None,
+ record_history: bool = False,
+ ) -> None:
super().__init__(network, vehicles, obstacles, np_random, record_history)
self.steps = 0
@@ -339,12 +346,16 @@ Source code for highway_env.road.regulation
# Find new conflicts and resolve them
for i in range(len(self.vehicles) - 1):
- for j in range(i+1, len(self.vehicles)):
+ for j in range(i + 1, len(self.vehicles)):
if self.is_conflict_possible(self.vehicles[i], self.vehicles[j]):
- yielding_vehicle = self.respect_priorities(self.vehicles[i], self.vehicles[j])
- if yielding_vehicle is not None and \
- isinstance(yielding_vehicle, ControlledVehicle) and \
- not isinstance(yielding_vehicle, MDPVehicle):
+ yielding_vehicle = self.respect_priorities(
+ self.vehicles[i], self.vehicles[j]
+ )
+ if (
+ yielding_vehicle is not None
+ and isinstance(yielding_vehicle, ControlledVehicle)
+ and not isinstance(yielding_vehicle, MDPVehicle)
+ ):
yielding_vehicle.color = self.YIELDING_COLOR
yielding_vehicle.target_speed = 0
yielding_vehicle.is_yielding = True
@@ -371,19 +382,28 @@ Source code for highway_env.road.regulation
@staticmethod
- def is_conflict_possible(v1: ControlledVehicle, v2: ControlledVehicle, horizon: int = 3, step: float = 0.25) -> bool:
+ def is_conflict_possible(
+ v1: ControlledVehicle,
+ v2: ControlledVehicle,
+ horizon: int = 3,
+ step: float = 0.25,
+ ) -> bool:
times = np.arange(step, horizon, step)
positions_1, headings_1 = v1.predict_trajectory_constant_speed(times)
positions_2, headings_2 = v2.predict_trajectory_constant_speed(times)
- for position_1, heading_1, position_2, heading_2 in zip(positions_1, headings_1, positions_2, headings_2):
+ for position_1, heading_1, position_2, heading_2 in zip(
+ positions_1, headings_1, positions_2, headings_2
+ ):
# Fast spherical pre-check
if np.linalg.norm(position_2 - position_1) > v1.LENGTH:
continue
# Accurate rectangular check
- if utils.rotated_rectangles_intersect((position_1, 1.5*v1.LENGTH, 0.9*v1.WIDTH, heading_1),
- (position_2, 1.5*v2.LENGTH, 0.9*v2.WIDTH, heading_2)):
+ if utils.rotated_rectangles_intersect(
+ (position_1, 1.5 * v1.LENGTH, 0.9 * v1.WIDTH, heading_1),
+ (position_2, 1.5 * v2.LENGTH, 0.9 * v2.WIDTH, heading_2),
+ ):
return True
diff --git a/main/_modules/highway_env/road/road/index.html b/main/_modules/highway_env/road/road/index.html
index aaf71e350..fb6ef1cf8 100644
--- a/main/_modules/highway_env/road/road/index.html
+++ b/main/_modules/highway_env/road/road/index.html
@@ -291,11 +291,12 @@
Source code for highway_env.road.road
-import numpy as np
-import logging
-from typing import List, Tuple, Dict, TYPE_CHECKING, Optional
+import logging
+from typing import TYPE_CHECKING, Dict, List, Optional, Tuple
-from highway_env.road.lane import LineType, StraightLane, AbstractLane, lane_from_config
+import numpy as np
+
+from highway_env.road.lane import AbstractLane, LineType, StraightLane, lane_from_config
from highway_env.vehicle.objects import Landmark
if TYPE_CHECKING:
@@ -341,7 +342,9 @@ Source code for highway_env.road.road
_id = 0
return self.graph[_from][_to][_id]
- def get_closest_lane_index(self, position: np.ndarray, heading: Optional[float] = None) -> LaneIndex:
+ def get_closest_lane_index(
+ self, position: np.ndarray, heading: Optional[float] = None
+ ) -> LaneIndex:
"""
Get the index of the lane closest to a world position.
@@ -357,8 +360,13 @@ Source code for highway_env.road.road
indexes.append((_from, _to, _id))
return indexes[int(np.argmin(distances))]
- def next_lane(self, current_index: LaneIndex, route: Route = None, position: np.ndarray = None,
- np_random: np.random.RandomState = np.random) -> LaneIndex:
+ def next_lane(
+ self,
+ current_index: LaneIndex,
+ route: Route = None,
+ position: np.ndarray = None,
+ np_random: np.random.RandomState = np.random,
+ ) -> LaneIndex:
"""
Get the index of the next lane that should be followed after finishing the current lane.
@@ -376,12 +384,20 @@ Source code for highway_env.road.road
next_to = next_id = None
# Pick next road according to planned route
if route:
- if route[0][:2] == current_index[:2]: # We just finished the first step of the route, drop it.
+ if (
+ route[0][:2] == current_index[:2]
+ ): # We just finished the first step of the route, drop it.
route.pop(0)
- if route and route[0][0] == _to: # Next road in route is starting at the end of current road.
+ if (
+ route and route[0][0] == _to
+ ): # Next road in route is starting at the end of current road.
_, next_to, next_id = route[0]
elif route:
- logger.warning("Route {} does not start after current road {}.".format(route[0], current_index))
+ logger.warning(
+ "Route {} does not start after current road {}.".format(
+ route[0], current_index
+ )
+ )
# Compute current projected (desired) position
long, lat = self.get_lane(current_index).local_coordinates(position)
@@ -390,19 +406,34 @@ Source code for highway_env.road.road
if not next_to:
# Pick the one with the closest lane to projected target position
try:
- lanes_dists = [(next_to,
- *self.next_lane_given_next_road(_from, _to, _id, next_to, next_id, projected_position))
- for next_to in self.graph[_to].keys()] # (next_to, next_id, distance)
+ lanes_dists = [
+ (
+ next_to,
+ *self.next_lane_given_next_road(
+ _from, _to, _id, next_to, next_id, projected_position
+ ),
+ )
+ for next_to in self.graph[_to].keys()
+ ] # (next_to, next_id, distance)
next_to, next_id, _ = min(lanes_dists, key=lambda x: x[-1])
except KeyError:
return current_index
else:
# If it is known, follow it and get the closest lane
- next_id, _ = self.next_lane_given_next_road(_from, _to, _id, next_to, next_id, projected_position)
+ next_id, _ = self.next_lane_given_next_road(
+ _from, _to, _id, next_to, next_id, projected_position
+ )
return _to, next_to, next_id
- def next_lane_given_next_road(self, _from: str, _to: str, _id: int,
- next_to: str, next_id: int, position: np.ndarray) -> Tuple[int, float]:
+ def next_lane_given_next_road(
+ self,
+ _from: str,
+ _to: str,
+ _id: int,
+ next_to: str,
+ next_id: int,
+ position: np.ndarray,
+ ) -> Tuple[int, float]:
# If next road has same number of lane, stay on the same lane
if len(self.graph[_from][_to]) == len(self.graph[_to][next_to]):
if next_id is None:
@@ -410,8 +441,9 @@ Source code for highway_env.road.road
# Else, pick closest lane
else:
lanes = range(len(self.graph[_to][next_to]))
- next_id = min(lanes,
- key=lambda l: self.get_lane((_to, next_to, l)).distance(position))
+ next_id = min(
+ lanes, key=lambda l: self.get_lane((_to, next_to, l)).distance(position)
+ )
return next_id, self.get_lane((_to, next_to, next_id)).distance(position)
def bfs_paths(self, start: str, goal: str) -> List[List[str]]:
@@ -427,7 +459,9 @@ Source code for highway_env.road.road
(node, path) = queue.pop(0)
if node not in self.graph:
yield []
- for _next in sorted([key for key in self.graph[node].keys() if key not in path]):
+ for _next in sorted(
+ [key for key in self.graph[node].keys() if key not in path]
+ ):
if _next == goal:
yield path + [_next]
elif _next in self.graph:
@@ -448,13 +482,16 @@ Source code for highway_env.road.road
:param lane_index: the index of a lane.
:return: all lanes belonging to the same road.
"""
- return [(lane_index[0], lane_index[1], i) for i in range(len(self.graph[lane_index[0]][lane_index[1]]))]
+ return [
+ (lane_index[0], lane_index[1], i)
+ for i in range(len(self.graph[lane_index[0]][lane_index[1]]))
+ ]
def side_lanes(self, lane_index: LaneIndex) -> List[LaneIndex]:
"""
- :param lane_index: the index of a lane.
- :return: indexes of lanes next to a an input lane, to its right or left.
- """
+ :param lane_index: the index of a lane.
+ :return: indexes of lanes next to a an input lane, to its right or left.
+ """
_from, _to, _id = lane_index
lanes = []
if _id > 0:
@@ -464,17 +501,31 @@ Source code for highway_env.road.road
return lanes
@staticmethod
- def is_same_road(lane_index_1: LaneIndex, lane_index_2: LaneIndex, same_lane: bool = False) -> bool:
+ def is_same_road(
+ lane_index_1: LaneIndex, lane_index_2: LaneIndex, same_lane: bool = False
+ ) -> bool:
"""Is lane 1 in the same road as lane 2?"""
- return lane_index_1[:2] == lane_index_2[:2] and (not same_lane or lane_index_1[2] == lane_index_2[2])
+ return lane_index_1[:2] == lane_index_2[:2] and (
+ not same_lane or lane_index_1[2] == lane_index_2[2]
+ )
@staticmethod
- def is_leading_to_road(lane_index_1: LaneIndex, lane_index_2: LaneIndex, same_lane: bool = False) -> bool:
+ def is_leading_to_road(
+ lane_index_1: LaneIndex, lane_index_2: LaneIndex, same_lane: bool = False
+ ) -> bool:
"""Is lane 1 leading to of lane 2?"""
- return lane_index_1[1] == lane_index_2[0] and (not same_lane or lane_index_1[2] == lane_index_2[2])
-
- def is_connected_road(self, lane_index_1: LaneIndex, lane_index_2: LaneIndex, route: Route = None,
- same_lane: bool = False, depth: int = 0) -> bool:
+ return lane_index_1[1] == lane_index_2[0] and (
+ not same_lane or lane_index_1[2] == lane_index_2[2]
+ )
+
+ def is_connected_road(
+ self,
+ lane_index_1: LaneIndex,
+ lane_index_2: LaneIndex,
+ route: Route = None,
+ same_lane: bool = False,
+ depth: int = 0,
+ ) -> bool:
"""
Is the lane 2 leading to a road within lane 1's route?
@@ -486,55 +537,86 @@ Source code for highway_env.road.road
:param depth: search depth from lane 1 along its route
:return: whether the roads are connected
"""
- if RoadNetwork.is_same_road(lane_index_2, lane_index_1, same_lane) \
- or RoadNetwork.is_leading_to_road(lane_index_2, lane_index_1, same_lane):
+ if RoadNetwork.is_same_road(
+ lane_index_2, lane_index_1, same_lane
+ ) or RoadNetwork.is_leading_to_road(lane_index_2, lane_index_1, same_lane):
return True
if depth > 0:
if route and route[0][:2] == lane_index_1[:2]:
# Route is starting at current road, skip it
- return self.is_connected_road(lane_index_1, lane_index_2, route[1:], same_lane, depth)
+ return self.is_connected_road(
+ lane_index_1, lane_index_2, route[1:], same_lane, depth
+ )
elif route and route[0][0] == lane_index_1[1]:
# Route is continuing from current road, follow it
- return self.is_connected_road(route[0], lane_index_2, route[1:], same_lane, depth - 1)
+ return self.is_connected_road(
+ route[0], lane_index_2, route[1:], same_lane, depth - 1
+ )
else:
# Recursively search all roads at intersection
_from, _to, _id = lane_index_1
- return any([self.is_connected_road((_to, l1_to, _id), lane_index_2, route, same_lane, depth - 1)
- for l1_to in self.graph.get(_to, {}).keys()])
+ return any(
+ [
+ self.is_connected_road(
+ (_to, l1_to, _id), lane_index_2, route, same_lane, depth - 1
+ )
+ for l1_to in self.graph.get(_to, {}).keys()
+ ]
+ )
return False
def lanes_list(self) -> List[AbstractLane]:
- return [lane for to in self.graph.values() for ids in to.values() for lane in ids]
+ return [
+ lane for to in self.graph.values() for ids in to.values() for lane in ids
+ ]
def lanes_dict(self) -> Dict[str, AbstractLane]:
- return {(from_, to_, i): lane
- for from_, tos in self.graph.items() for to_, ids in tos.items() for i, lane in enumerate(ids)}
+ return {
+ (from_, to_, i): lane
+ for from_, tos in self.graph.items()
+ for to_, ids in tos.items()
+ for i, lane in enumerate(ids)
+ }
@staticmethod
- def straight_road_network(lanes: int = 4,
- start: float = 0,
- length: float = 10000,
- angle: float = 0,
- speed_limit: float = 30,
- nodes_str: Optional[Tuple[str, str]] = None,
- net: Optional['RoadNetwork'] = None) \
- -> 'RoadNetwork':
+ def straight_road_network(
+ lanes: int = 4,
+ start: float = 0,
+ length: float = 10000,
+ angle: float = 0,
+ speed_limit: float = 30,
+ nodes_str: Optional[Tuple[str, str]] = None,
+ net: Optional["RoadNetwork"] = None,
+ ) -> "RoadNetwork":
net = net or RoadNetwork()
nodes_str = nodes_str or ("0", "1")
for lane in range(lanes):
origin = np.array([start, lane * StraightLane.DEFAULT_WIDTH])
end = np.array([start + length, lane * StraightLane.DEFAULT_WIDTH])
- rotation = np.array([[np.cos(angle), np.sin(angle)], [-np.sin(angle), np.cos(angle)]])
+ rotation = np.array(
+ [[np.cos(angle), np.sin(angle)], [-np.sin(angle), np.cos(angle)]]
+ )
origin = rotation @ origin
end = rotation @ end
- line_types = [LineType.CONTINUOUS_LINE if lane == 0 else LineType.STRIPED,
- LineType.CONTINUOUS_LINE if lane == lanes - 1 else LineType.NONE]
- net.add_lane(*nodes_str, StraightLane(origin, end, line_types=line_types, speed_limit=speed_limit))
+ line_types = [
+ LineType.CONTINUOUS_LINE if lane == 0 else LineType.STRIPED,
+ LineType.CONTINUOUS_LINE if lane == lanes - 1 else LineType.NONE,
+ ]
+ net.add_lane(
+ *nodes_str,
+ StraightLane(
+ origin, end, line_types=line_types, speed_limit=speed_limit
+ )
+ )
return net
- def position_heading_along_route(self, route: Route, longitudinal: float, lateral: float,
- current_lane_index: LaneIndex) \
- -> Tuple[np.ndarray, float]:
+ def position_heading_along_route(
+ self,
+ route: Route,
+ longitudinal: float,
+ lateral: float,
+ current_lane_index: LaneIndex,
+ ) -> Tuple[np.ndarray, float]:
"""
Get the absolute position and heading along a route composed of several lanes at some local coordinates.
@@ -544,13 +626,18 @@ Source code for highway_env.road.road
:param current_lane_index: current lane index of the vehicle
:return: position, heading
"""
+
def _get_route_head_with_id(route_):
lane_index_ = route_[0]
if lane_index_[2] is None:
# We know which road segment will be followed by the vehicle, but not which lane.
# Hypothesis: the vehicle will keep the same lane_id as the current one.
- id_ = (current_lane_index[2]
- if current_lane_index[2] < len(self.graph[current_lane_index[0]][current_lane_index[1]]) else 0)
+ id_ = (
+ current_lane_index[2]
+ if current_lane_index[2]
+ < len(self.graph[current_lane_index[0]][current_lane_index[1]])
+ else 0
+ )
lane_index_ = (lane_index_[0], lane_index_[1], id_)
return lane_index_
@@ -560,8 +647,9 @@ Source code for highway_env.road.road
route = route[1:]
lane_index = _get_route_head_with_id(route)
- return self.get_lane(lane_index).position(longitudinal, lateral),\
- self.get_lane(lane_index).heading_at(longitudinal)
+ return self.get_lane(lane_index).position(longitudinal, lateral), self.get_lane(
+ lane_index
+ ).heading_at(longitudinal)
def random_lane_index(self, np_random: np.random.RandomState) -> LaneIndex:
_from = np_random.choice(list(self.graph.keys()))
@@ -577,9 +665,7 @@ Source code for highway_env.road.road
for _to, lanes_dict in to_dict.items():
net.graph[_from][_to] = []
for lane_dict in lanes_dict:
- net.graph[_from][_to].append(
- lane_from_config(lane_dict)
- )
+ net.graph[_from][_to].append(lane_from_config(lane_dict))
return net
def to_config(self) -> dict:
@@ -589,9 +675,7 @@ Source code for highway_env.road.road
for _to, lanes in to_dict.items():
graph_dict[_from][_to] = []
for lane in lanes:
- graph_dict[_from][_to].append(
- lane.to_config()
- )
+ graph_dict[_from][_to].append(lane.to_config())
return graph_dict
@@ -601,12 +685,14 @@ Source code for highway_env.road.road
"""A road is a set of lanes, and a set of vehicles driving on these lanes."""
- def __init__(self,
- network: RoadNetwork = None,
- vehicles: List['kinematics.Vehicle'] = None,
- road_objects: List['objects.RoadObject'] = None,
- np_random: np.random.RandomState = None,
- record_history: bool = False) -> None:
+ def __init__(
+ self,
+ network: RoadNetwork = None,
+ vehicles: List["kinematics.Vehicle"] = None,
+ road_objects: List["objects.RoadObject"] = None,
+ np_random: np.random.RandomState = None,
+ record_history: bool = False,
+ ) -> None:
"""
New road.
@@ -622,15 +708,28 @@ Source code for highway_env.road.road
self.np_random = np_random if np_random else np.random.RandomState()
self.record_history = record_history
- def close_objects_to(self, vehicle: 'kinematics.Vehicle', distance: float, count: Optional[int] = None,
- see_behind: bool = True, sort: bool = True, vehicles_only: bool = False) -> object:
- vehicles = [v for v in self.vehicles
- if np.linalg.norm(v.position - vehicle.position) < distance
- and v is not vehicle
- and (see_behind or -2 * vehicle.LENGTH < vehicle.lane_distance_to(v))]
- obstacles = [o for o in self.objects
- if np.linalg.norm(o.position - vehicle.position) < distance
- and -2 * vehicle.LENGTH < vehicle.lane_distance_to(o)]
+ def close_objects_to(
+ self,
+ vehicle: "kinematics.Vehicle",
+ distance: float,
+ count: Optional[int] = None,
+ see_behind: bool = True,
+ sort: bool = True,
+ vehicles_only: bool = False,
+ ) -> object:
+ vehicles = [
+ v
+ for v in self.vehicles
+ if np.linalg.norm(v.position - vehicle.position) < distance
+ and v is not vehicle
+ and (see_behind or -2 * vehicle.LENGTH < vehicle.lane_distance_to(v))
+ ]
+ obstacles = [
+ o
+ for o in self.objects
+ if np.linalg.norm(o.position - vehicle.position) < distance
+ and -2 * vehicle.LENGTH < vehicle.lane_distance_to(o)
+ ]
objects_ = vehicles if vehicles_only else vehicles + obstacles
@@ -640,9 +739,17 @@ Source code for highway_env.road.road
objects_ = objects_[:count]
return objects_
- def close_vehicles_to(self, vehicle: 'kinematics.Vehicle', distance: float, count: Optional[int] = None,
- see_behind: bool = True, sort: bool = True) -> object:
- return self.close_objects_to(vehicle, distance, count, see_behind, sort, vehicles_only=True)
+ def close_vehicles_to(
+ self,
+ vehicle: "kinematics.Vehicle",
+ distance: float,
+ count: Optional[int] = None,
+ see_behind: bool = True,
+ sort: bool = True,
+ ) -> object:
+ return self.close_objects_to(
+ vehicle, distance, count, see_behind, sort, vehicles_only=True
+ )
[docs]
@@ -663,7 +770,7 @@
Source code for highway_env.road.road
for vehicle in self.vehicles:
vehicle.step(dt)
for i, vehicle in enumerate(self.vehicles):
- for other in self.vehicles[i+1:]:
+ for other in self.vehicles[i + 1 :]:
vehicle.handle_collisions(other, dt)
for other in self.objects:
vehicle.handle_collisions(other, dt)
@@ -671,8 +778,9 @@
Source code for highway_env.road.road
[docs]
-
def neighbour_vehicles(self, vehicle: 'kinematics.Vehicle', lane_index: LaneIndex = None) \
-
-> Tuple[Optional['kinematics.Vehicle'], Optional['kinematics.Vehicle']]:
+
def neighbour_vehicles(
+
self, vehicle: "kinematics.Vehicle", lane_index: LaneIndex = None
+
) -> Tuple[Optional["kinematics.Vehicle"], Optional["kinematics.Vehicle"]]:
"""
Find the preceding and following vehicles of a given vehicle.
@@ -690,7 +798,9 @@
Source code for highway_env.road.road
s_front = s_rear = None
v_front = v_rear = None
for v in self.vehicles + self.objects:
- if v is not vehicle and not isinstance(v, Landmark): # self.network.is_connected_road(v.lane_index,
+ if v is not vehicle and not isinstance(
+ v, Landmark
+ ): # self.network.is_connected_road(v.lane_index,
# lane_index, same_lane=True):
s_v, lat_v = lane.local_coordinates(v.position)
if not lane.on_lane(v.position, s_v, lat_v, margin=1):
diff --git a/main/_modules/highway_env/vehicle/behavior/index.html b/main/_modules/highway_env/vehicle/behavior/index.html
index cf29cfd9b..636d77965 100644
--- a/main/_modules/highway_env/vehicle/behavior/index.html
+++ b/main/_modules/highway_env/vehicle/behavior/index.html
@@ -291,14 +291,14 @@
Source code for highway_env.vehicle.behavior
-from typing import Tuple, Union
+from typing import Union
import numpy as np
-from highway_env.road.road import Road, Route, LaneIndex
+from highway_env import utils
+from highway_env.road.road import LaneIndex, Road, Route
from highway_env.utils import Vector
from highway_env.vehicle.controller import ControlledVehicle
-from highway_env import utils
from highway_env.vehicle.kinematics import Vehicle
@@ -335,27 +335,33 @@ Source code for highway_env.vehicle.behavior
"""Range of delta when chosen randomly."""
# Lateral policy parameters
- POLITENESS = 0. # in [0, 1]
+ POLITENESS = 0.0 # in [0, 1]
LANE_CHANGE_MIN_ACC_GAIN = 0.2 # [m/s2]
LANE_CHANGE_MAX_BRAKING_IMPOSED = 2.0 # [m/s2]
LANE_CHANGE_DELAY = 1.0 # [s]
- def __init__(self,
- road: Road,
- position: Vector,
- heading: float = 0,
- speed: float = 0,
- target_lane_index: int = None,
- target_speed: float = None,
- route: Route = None,
- enable_lane_change: bool = True,
- timer: float = None):
- super().__init__(road, position, heading, speed, target_lane_index, target_speed, route)
+ def __init__(
+ self,
+ road: Road,
+ position: Vector,
+ heading: float = 0,
+ speed: float = 0,
+ target_lane_index: int = None,
+ target_speed: float = None,
+ route: Route = None,
+ enable_lane_change: bool = True,
+ timer: float = None,
+ ):
+ super().__init__(
+ road, position, heading, speed, target_lane_index, target_speed, route
+ )
self.enable_lane_change = enable_lane_change
- self.timer = timer or (np.sum(self.position)*np.pi) % self.LANE_CHANGE_DELAY
+ self.timer = timer or (np.sum(self.position) * np.pi) % self.LANE_CHANGE_DELAY
def randomize_behavior(self):
- self.DELTA = self.road.np_random.uniform(low=self.DELTA_RANGE[0], high=self.DELTA_RANGE[1])
+ self.DELTA = self.road.np_random.uniform(
+ low=self.DELTA_RANGE[0], high=self.DELTA_RANGE[1]
+ )
[docs]
@@ -369,9 +375,16 @@
Source code for highway_env.vehicle.behavior
:param vehicle: a vehicle
:return: a new vehicle at the same dynamical state
"""
- v = cls(vehicle.road, vehicle.position, heading=vehicle.heading, speed=vehicle.speed,
- target_lane_index=vehicle.target_lane_index, target_speed=vehicle.target_speed,
- route=vehicle.route, timer=getattr(vehicle, 'timer', None))
+ v = cls(
+ vehicle.road,
+ vehicle.position,
+ heading=vehicle.heading,
+ speed=vehicle.speed,
+ target_lane_index=vehicle.target_lane_index,
+ target_speed=vehicle.target_speed,
+ route=vehicle.route,
+ timer=getattr(vehicle, "timer", None),
+ )
return v
@@ -393,24 +406,36 @@
Source code for highway_env.vehicle.behavior
self.follow_road()
if self.enable_lane_change:
self.change_lane_policy()
- action['steering'] = self.steering_control(self.target_lane_index)
- action['steering'] = np.clip(action['steering'], -self.MAX_STEERING_ANGLE, self.MAX_STEERING_ANGLE)
+ action["steering"] = self.steering_control(self.target_lane_index)
+ action["steering"] = np.clip(
+ action["steering"], -self.MAX_STEERING_ANGLE, self.MAX_STEERING_ANGLE
+ )
# Longitudinal: IDM
- front_vehicle, rear_vehicle = self.road.neighbour_vehicles(self, self.lane_index)
- action['acceleration'] = self.acceleration(ego_vehicle=self,
- front_vehicle=front_vehicle,
- rear_vehicle=rear_vehicle)
+ front_vehicle, rear_vehicle = self.road.neighbour_vehicles(
+ self, self.lane_index
+ )
+ action["acceleration"] = self.acceleration(
+ ego_vehicle=self, front_vehicle=front_vehicle, rear_vehicle=rear_vehicle
+ )
# When changing lane, check both current and target lanes
if self.lane_index != self.target_lane_index:
- front_vehicle, rear_vehicle = self.road.neighbour_vehicles(self, self.target_lane_index)
- target_idm_acceleration = self.acceleration(ego_vehicle=self,
- front_vehicle=front_vehicle,
- rear_vehicle=rear_vehicle)
- action['acceleration'] = min(action['acceleration'], target_idm_acceleration)
+ front_vehicle, rear_vehicle = self.road.neighbour_vehicles(
+ self, self.target_lane_index
+ )
+ target_idm_acceleration = self.acceleration(
+ ego_vehicle=self, front_vehicle=front_vehicle, rear_vehicle=rear_vehicle
+ )
+ action["acceleration"] = min(
+ action["acceleration"], target_idm_acceleration
+ )
# action['acceleration'] = self.recover_from_stop(action['acceleration'])
- action['acceleration'] = np.clip(action['acceleration'], -self.ACC_MAX, self.ACC_MAX)
- Vehicle.act(self, action) # Skip ControlledVehicle.act(), or the command will be overriden.
+
action["acceleration"] = np.clip(
+
action["acceleration"], -self.ACC_MAX, self.ACC_MAX
+
)
+
Vehicle.act(
+
self, action
+
) # Skip ControlledVehicle.act(), or the command will be overriden.
@@ -429,10 +454,12 @@
Source code for highway_env.vehicle.behavior
[docs]
- def acceleration(self,
- ego_vehicle: ControlledVehicle,
- front_vehicle: Vehicle = None,
- rear_vehicle: Vehicle = None) -> float:
+ def acceleration(
+ self,
+ ego_vehicle: ControlledVehicle,
+ front_vehicle: Vehicle = None,
+ rear_vehicle: Vehicle = None,
+ ) -> float:
"""
Compute an acceleration command with the Intelligent Driver Model.
@@ -451,20 +478,33 @@ Source code for highway_env.vehicle.behavior
return 0
ego_target_speed = getattr(ego_vehicle, "target_speed", 0)
if ego_vehicle.lane and ego_vehicle.lane.speed_limit is not None:
- ego_target_speed = np.clip(ego_target_speed, 0, ego_vehicle.lane.speed_limit)
- acceleration = self.COMFORT_ACC_MAX * (1 - np.power(
- max(ego_vehicle.speed, 0) / abs(utils.not_zero(ego_target_speed)), self.DELTA))
+ ego_target_speed = np.clip(
+ ego_target_speed, 0, ego_vehicle.lane.speed_limit
+ )
+ acceleration = self.COMFORT_ACC_MAX * (
+ 1
+ - np.power(
+ max(ego_vehicle.speed, 0) / abs(utils.not_zero(ego_target_speed)),
+ self.DELTA,
+ )
+ )
if front_vehicle:
d = ego_vehicle.lane_distance_to(front_vehicle)
- acceleration -= self.COMFORT_ACC_MAX * \
- np.power(self.desired_gap(ego_vehicle, front_vehicle) / utils.not_zero(d), 2)
+ acceleration -= self.COMFORT_ACC_MAX * np.power(
+ self.desired_gap(ego_vehicle, front_vehicle) / utils.not_zero(d), 2
+ )
return acceleration
[docs]
-
def desired_gap(self, ego_vehicle: Vehicle, front_vehicle: Vehicle = None, projected: bool = True) -> float:
+
def desired_gap(
+
self,
+
ego_vehicle: Vehicle,
+
front_vehicle: Vehicle = None,
+
projected: bool = True,
+
) -> float:
"""
Compute the desired distance between a vehicle and its leading vehicle.
@@ -476,9 +516,14 @@
Source code for highway_env.vehicle.behavior
d0 = self.DISTANCE_WANTED
tau = self.TIME_WANTED
ab = -self.COMFORT_ACC_MAX * self.COMFORT_ACC_MIN
- dv = np.dot(ego_vehicle.velocity - front_vehicle.velocity, ego_vehicle.direction) if projected \
+ dv = (
+ np.dot(ego_vehicle.velocity - front_vehicle.velocity, ego_vehicle.direction)
+ if projected
else ego_vehicle.speed - front_vehicle.speed
- d_star = d0 + ego_vehicle.speed * tau + ego_vehicle.speed * dv / (2 * np.sqrt(ab))
+ )
+ d_star = (
+ d0 + ego_vehicle.speed * tau + ego_vehicle.speed * dv / (2 * np.sqrt(ab))
+ )
return d_star
@@ -498,10 +543,12 @@
Source code for highway_env.vehicle.behavior
# If we are on correct route but bad lane: abort it if someone else is already changing into the same lane
if self.lane_index[:2] == self.target_lane_index[:2]:
for v in self.road.vehicles:
- if v is not self \
- and v.lane_index != self.target_lane_index \
- and isinstance(v, ControlledVehicle) \
- and v.target_lane_index == self.target_lane_index:
+ if (
+ v is not self
+ and v.lane_index != self.target_lane_index
+ and isinstance(v, ControlledVehicle)
+ and v.target_lane_index == self.target_lane_index
+ ):
d = self.lane_distance_to(v)
d_star = self.desired_gap(self, v)
if 0 < d < d_star:
@@ -517,7 +564,9 @@ Source code for highway_env.vehicle.behavior
# decide to make a lane change
for lane_index in self.road.network.side_lanes(self.lane_index):
# Is the candidate lane close enough?
- if not self.road.network.get_lane(lane_index).is_reachable_from(self.position):
+ if not self.road.network.get_lane(lane_index).is_reachable_from(
+ self.position
+ ):
continue
# Only change lane when the vehicle is moving
if np.abs(self.speed) < 1:
@@ -542,8 +591,12 @@ Source code for highway_env.vehicle.behavior
"""
# Is the maneuver unsafe for the new following vehicle?
new_preceding, new_following = self.road.neighbour_vehicles(self, lane_index)
- new_following_a = self.acceleration(ego_vehicle=new_following, front_vehicle=new_preceding)
- new_following_pred_a = self.acceleration(ego_vehicle=new_following, front_vehicle=self)
+ new_following_a = self.acceleration(
+ ego_vehicle=new_following, front_vehicle=new_preceding
+ )
+ new_following_pred_a = self.acceleration(
+ ego_vehicle=new_following, front_vehicle=self
+ )
if new_following_pred_a < -self.LANE_CHANGE_MAX_BRAKING_IMPOSED:
return False
@@ -552,7 +605,9 @@ Source code for highway_env.vehicle.behavior
self_pred_a = self.acceleration(ego_vehicle=self, front_vehicle=new_preceding)
if self.route and self.route[0][2] is not None:
# Wrong direction
- if np.sign(lane_index[2] - self.target_lane_index[2]) != np.sign(self.route[0][2] - self.target_lane_index[2]):
+ if np.sign(lane_index[2] - self.target_lane_index[2]) != np.sign(
+ self.route[0][2] - self.target_lane_index[2]
+ ):
return False
# Unsafe braking required
elif self_pred_a < -self.LANE_CHANGE_MAX_BRAKING_IMPOSED:
@@ -561,10 +616,23 @@ Source code for highway_env.vehicle.behavior
# Is there an acceleration advantage for me and/or my followers to change lane?
else:
self_a = self.acceleration(ego_vehicle=self, front_vehicle=old_preceding)
- old_following_a = self.acceleration(ego_vehicle=old_following, front_vehicle=self)
- old_following_pred_a = self.acceleration(ego_vehicle=old_following, front_vehicle=old_preceding)
- jerk = self_pred_a - self_a + self.POLITENESS * (new_following_pred_a - new_following_a
- + old_following_pred_a - old_following_a)
+ old_following_a = self.acceleration(
+ ego_vehicle=old_following, front_vehicle=self
+ )
+ old_following_pred_a = self.acceleration(
+ ego_vehicle=old_following, front_vehicle=old_preceding
+ )
+ jerk = (
+ self_pred_a
+ - self_a
+ + self.POLITENESS
+ * (
+ new_following_pred_a
+ - new_following_a
+ + old_following_pred_a
+ - old_following_a
+ )
+ )
if jerk < self.LANE_CHANGE_MIN_ACC_GAIN:
return False
@@ -586,10 +654,13 @@ Source code for highway_env.vehicle.behavior
# Is the vehicle stopped on the wrong lane?
if self.target_lane_index != self.lane_index and self.speed < stopped_speed:
_, rear = self.road.neighbour_vehicles(self)
- _, new_rear = self.road.neighbour_vehicles(self, self.road.network.get_lane(self.target_lane_index))
+ _, new_rear = self.road.neighbour_vehicles(
+ self, self.road.network.get_lane(self.target_lane_index)
+ )
# Check for free room behind on both lanes
- if (not rear or rear.lane_distance_to(self) > safe_distance) and \
- (not new_rear or new_rear.lane_distance_to(self) > safe_distance):
+ if (not rear or rear.lane_distance_to(self) > safe_distance) and (
+ not new_rear or new_rear.lane_distance_to(self) > safe_distance
+ ):
# Reverse
return -self.COMFORT_ACC_MAX / 2
return acceleration
@@ -604,27 +675,50 @@ Source code for highway_env.vehicle.behavior
"""A Vehicle whose longitudinal and lateral controllers are linear with respect to parameters."""
ACCELERATION_PARAMETERS = [0.3, 0.3, 2.0]
- STEERING_PARAMETERS = [ControlledVehicle.KP_HEADING, ControlledVehicle.KP_HEADING * ControlledVehicle.KP_LATERAL]
-
- ACCELERATION_RANGE = np.array([0.5*np.array(ACCELERATION_PARAMETERS), 1.5*np.array(ACCELERATION_PARAMETERS)])
- STEERING_RANGE = np.array([np.array(STEERING_PARAMETERS) - np.array([0.07, 1.5]),
- np.array(STEERING_PARAMETERS) + np.array([0.07, 1.5])])
+ STEERING_PARAMETERS = [
+ ControlledVehicle.KP_HEADING,
+ ControlledVehicle.KP_HEADING * ControlledVehicle.KP_LATERAL,
+ ]
+
+ ACCELERATION_RANGE = np.array(
+ [
+ 0.5 * np.array(ACCELERATION_PARAMETERS),
+ 1.5 * np.array(ACCELERATION_PARAMETERS),
+ ]
+ )
+ STEERING_RANGE = np.array(
+ [
+ np.array(STEERING_PARAMETERS) - np.array([0.07, 1.5]),
+ np.array(STEERING_PARAMETERS) + np.array([0.07, 1.5]),
+ ]
+ )
TIME_WANTED = 2.5
- def __init__(self,
- road: Road,
- position: Vector,
- heading: float = 0,
- speed: float = 0,
- target_lane_index: int = None,
- target_speed: float = None,
- route: Route = None,
- enable_lane_change: bool = True,
- timer: float = None,
- data: dict = None):
- super().__init__(road, position, heading, speed, target_lane_index, target_speed, route,
- enable_lane_change, timer)
+ def __init__(
+ self,
+ road: Road,
+ position: Vector,
+ heading: float = 0,
+ speed: float = 0,
+ target_lane_index: int = None,
+ target_speed: float = None,
+ route: Route = None,
+ enable_lane_change: bool = True,
+ timer: float = None,
+ data: dict = None,
+ ):
+ super().__init__(
+ road,
+ position,
+ heading,
+ speed,
+ target_lane_index,
+ target_speed,
+ route,
+ enable_lane_change,
+ timer,
+ )
self.data = data if data is not None else {}
self.collecting_data = True
@@ -638,17 +732,22 @@ Source code for highway_env.vehicle.behavior
def randomize_behavior(self):
ua = self.road.np_random.uniform(size=np.shape(self.ACCELERATION_PARAMETERS))
- self.ACCELERATION_PARAMETERS = self.ACCELERATION_RANGE[0] + ua*(self.ACCELERATION_RANGE[1] -
- self.ACCELERATION_RANGE[0])
+ self.ACCELERATION_PARAMETERS = self.ACCELERATION_RANGE[0] + ua * (
+ self.ACCELERATION_RANGE[1] - self.ACCELERATION_RANGE[0]
+ )
ub = self.road.np_random.uniform(size=np.shape(self.STEERING_PARAMETERS))
- self.STEERING_PARAMETERS = self.STEERING_RANGE[0] + ub*(self.STEERING_RANGE[1] - self.STEERING_RANGE[0])
+ self.STEERING_PARAMETERS = self.STEERING_RANGE[0] + ub * (
+ self.STEERING_RANGE[1] - self.STEERING_RANGE[0]
+ )
[docs]
-
def acceleration(self,
-
ego_vehicle: ControlledVehicle,
-
front_vehicle: Vehicle = None,
-
rear_vehicle: Vehicle = None) -> float:
+
def acceleration(
+
self,
+
ego_vehicle: ControlledVehicle,
+
front_vehicle: Vehicle = None,
+
rear_vehicle: Vehicle = None,
+
) -> float:
"""
Compute an acceleration command with a Linear Model.
@@ -664,17 +763,27 @@
Source code for highway_env.vehicle.behavior
:param rear_vehicle: the vehicle following the ego-vehicle
:return: the acceleration command for the ego-vehicle [m/s2]
"""
- return float(np.dot(self.ACCELERATION_PARAMETERS,
- self.acceleration_features(ego_vehicle, front_vehicle, rear_vehicle)))
-
-
-
def acceleration_features(self, ego_vehicle: ControlledVehicle,
-
front_vehicle: Vehicle = None,
-
rear_vehicle: Vehicle = None) -> np.ndarray:
+
return float(
+
np.dot(
+
self.ACCELERATION_PARAMETERS,
+
self.acceleration_features(ego_vehicle, front_vehicle, rear_vehicle),
+
)
+
)
+
+
+ def acceleration_features(
+ self,
+ ego_vehicle: ControlledVehicle,
+ front_vehicle: Vehicle = None,
+ rear_vehicle: Vehicle = None,
+ ) -> np.ndarray:
vt, dv, dp = 0, 0, 0
if ego_vehicle:
vt = ego_vehicle.target_speed - ego_vehicle.speed
- d_safe = self.DISTANCE_WANTED + np.maximum(ego_vehicle.speed, 0) * self.TIME_WANTED
+ d_safe = (
+ self.DISTANCE_WANTED
+ + np.maximum(ego_vehicle.speed, 0) * self.TIME_WANTED
+ )
if front_vehicle:
d = ego_vehicle.lane_distance_to(front_vehicle)
dv = min(front_vehicle.speed - ego_vehicle.speed, 0)
@@ -692,7 +801,12 @@ Source code for highway_env.vehicle.behavior
:param target_lane_index: index of the lane to follow
:return: a steering wheel angle command [rad]
"""
- return float(np.dot(np.array(self.STEERING_PARAMETERS), self.steering_features(target_lane_index)))
+ return float(
+ np.dot(
+ np.array(self.STEERING_PARAMETERS),
+ self.steering_features(target_lane_index),
+ )
+ )
@@ -708,41 +822,28 @@
Source code for highway_env.vehicle.behavior
lane_coords = lane.local_coordinates(self.position)
lane_next_coords = lane_coords[0] + self.speed * self.TAU_PURSUIT
lane_future_heading = lane.heading_at(lane_next_coords)
- features = np.array([utils.wrap_to_pi(lane_future_heading - self.heading) *
- self.LENGTH / utils.not_zero(self.speed),
- -lane_coords[1] * self.LENGTH / (utils.not_zero(self.speed) ** 2)])
+ features = np.array(
+ [
+ utils.wrap_to_pi(lane_future_heading - self.heading)
+ * self.LENGTH
+ / utils.not_zero(self.speed),
+ -lane_coords[1] * self.LENGTH / (utils.not_zero(self.speed) ** 2),
+ ]
+ )
return features
def longitudinal_structure(self):
# Nominal dynamics: integrate speed
-
A = np.array([
-
[0, 0, 1, 0],
-
[0, 0, 0, 1],
-
[0, 0, 0, 0],
-
[0, 0, 0, 0]
-
])
+
A = np.array([[0, 0, 1, 0], [0, 0, 0, 1], [0, 0, 0, 0], [0, 0, 0, 0]])
# Target speed dynamics
-
phi0 = np.array([
-
[0, 0, 0, 0],
-
[0, 0, 0, 0],
-
[0, 0, -1, 0],
-
[0, 0, 0, -1]
-
])
+
phi0 = np.array([[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, -1, 0], [0, 0, 0, -1]])
# Front speed control
-
phi1 = np.array([
-
[0, 0, 0, 0],
-
[0, 0, 0, 0],
-
[0, 0, -1, 1],
-
[0, 0, 0, 0]
-
])
+
phi1 = np.array([[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, -1, 1], [0, 0, 0, 0]])
# Front position control
-
phi2 = np.array([
-
[0, 0, 0, 0],
-
[0, 0, 0, 0],
-
[-1, 1, -self.TIME_WANTED, 0],
-
[0, 0, 0, 0]
-
])
+
phi2 = np.array(
+
[[0, 0, 0, 0], [0, 0, 0, 0], [-1, 1, -self.TIME_WANTED, 0], [0, 0, 0, 0]]
+
)
# Disable speed control
front_vehicle, _ = self.road.neighbour_vehicles(self)
if not front_vehicle or self.speed < front_vehicle.speed:
@@ -760,18 +861,9 @@
Source code for highway_env.vehicle.behavior
return A, phi
def lateral_structure(self):
- A = np.array([
- [0, 1],
- [0, 0]
- ])
- phi0 = np.array([
- [0, 0],
- [0, -1]
- ])
- phi1 = np.array([
- [0, 0],
- [-1, 0]
- ])
+ A = np.array([[0, 1], [0, 0]])
+ phi0 = np.array([[0, 0], [0, -1]])
+ phi1 = np.array([[0, 0], [-1, 0]])
phi = np.array([phi0, phi1])
return A, phi
@@ -783,7 +875,6 @@ Source code for highway_env.vehicle.behavior
def add_features(self, data, lane_index, output_lane=None):
-
front_vehicle, rear_vehicle = self.road.neighbour_vehicles(self)
features = self.acceleration_features(self, front_vehicle, rear_vehicle)
output = np.dot(self.ACCELERATION_PARAMETERS, features)
@@ -811,9 +902,11 @@ Source code for highway_env.vehicle.behavior
MERGE_ACC_GAIN = 0.8
MERGE_VEL_RATIO = 0.75
MERGE_TARGET_VEL = 30
- ACCELERATION_PARAMETERS = [MERGE_ACC_GAIN / ((1 - MERGE_VEL_RATIO) * MERGE_TARGET_VEL),
- MERGE_ACC_GAIN / (MERGE_VEL_RATIO * MERGE_TARGET_VEL),
- 0.5]
+ ACCELERATION_PARAMETERS = [
+ MERGE_ACC_GAIN / ((1 - MERGE_VEL_RATIO) * MERGE_TARGET_VEL),
+ MERGE_ACC_GAIN / (MERGE_VEL_RATIO * MERGE_TARGET_VEL),
+ 0.5,
+ ]
@@ -824,9 +917,11 @@ Source code for highway_env.vehicle.behavior
MERGE_ACC_GAIN = 1.2
MERGE_VEL_RATIO = 0.75
MERGE_TARGET_VEL = 30
- ACCELERATION_PARAMETERS = [MERGE_ACC_GAIN / ((1 - MERGE_VEL_RATIO) * MERGE_TARGET_VEL),
- MERGE_ACC_GAIN / (MERGE_VEL_RATIO * MERGE_TARGET_VEL),
- 2.0]
+ ACCELERATION_PARAMETERS = [
+ MERGE_ACC_GAIN / ((1 - MERGE_VEL_RATIO) * MERGE_TARGET_VEL),
+ MERGE_ACC_GAIN / (MERGE_VEL_RATIO * MERGE_TARGET_VEL),
+ 2.0,
+ ]
diff --git a/main/_modules/highway_env/vehicle/controller/index.html b/main/_modules/highway_env/vehicle/controller/index.html
index 9b7ce1478..74bf52f0d 100644
--- a/main/_modules/highway_env/vehicle/controller/index.html
+++ b/main/_modules/highway_env/vehicle/controller/index.html
@@ -291,12 +291,13 @@
Source code for highway_env.vehicle.controller
-from typing import List, Tuple, Union, Optional
+import copy
+from typing import List, Optional, Tuple, Union
import numpy as np
-import copy
+
from highway_env import utils
-from highway_env.road.road import Road, LaneIndex, Route
+from highway_env.road.road import LaneIndex, Road, Route
from highway_env.utils import Vector
from highway_env.vehicle.kinematics import Vehicle
@@ -326,14 +327,16 @@ Source code for highway_env.vehicle.controller
MAX_STEERING_ANGLE = np.pi / 3 # [rad]
DELTA_SPEED = 5 # [m/s]
- def __init__(self,
- road: Road,
- position: Vector,
- heading: float = 0,
- speed: float = 0,
- target_lane_index: LaneIndex = None,
- target_speed: float = None,
- route: Route = None):
+ def __init__(
+ self,
+ road: Road,
+ position: Vector,
+ heading: float = 0,
+ speed: float = 0,
+ target_lane_index: LaneIndex = None,
+ target_speed: float = None,
+ route: Route = None,
+ ):
super().__init__(road, position, heading, speed)
self.target_lane_index = target_lane_index or self.lane_index
self.target_speed = target_speed or self.speed
@@ -351,9 +354,15 @@
Source code for highway_env.vehicle.controller
:param vehicle: a vehicle
:return: a new vehicle at the same dynamical state
"""
- v = cls(vehicle.road, vehicle.position, heading=vehicle.heading, speed=vehicle.speed,
- target_lane_index=vehicle.target_lane_index, target_speed=vehicle.target_speed,
- route=vehicle.route)
+ v = cls(
+ vehicle.road,
+ vehicle.position,
+ heading=vehicle.heading,
+ speed=vehicle.speed,
+ target_lane_index=vehicle.target_lane_index,
+ target_speed=vehicle.target_speed,
+ route=vehicle.route,
+ )
return v
@@ -370,7 +379,9 @@
Source code for highway_env.vehicle.controller
except KeyError:
path = []
if path:
- self.route = [self.lane_index] + [(path[i], path[i + 1], None) for i in range(len(path) - 1)]
+ self.route = [self.lane_index] + [
+ (path[i], path[i + 1], None) for i in range(len(path) - 1)
+ ]
else:
self.route = [self.lane_index]
return self
@@ -394,18 +405,34 @@
Source code for highway_env.vehicle.controller
self.target_speed -= self.DELTA_SPEED
elif action == "LANE_RIGHT":
_from, _to, _id = self.target_lane_index
- target_lane_index = _from, _to, np.clip(_id + 1, 0, len(self.road.network.graph[_from][_to]) - 1)
- if self.road.network.get_lane(target_lane_index).is_reachable_from(self.position):
+ target_lane_index = (
+ _from,
+ _to,
+ np.clip(_id + 1, 0, len(self.road.network.graph[_from][_to]) - 1),
+ )
+ if self.road.network.get_lane(target_lane_index).is_reachable_from(
+ self.position
+ ):
self.target_lane_index = target_lane_index
elif action == "LANE_LEFT":
_from, _to, _id = self.target_lane_index
- target_lane_index = _from, _to, np.clip(_id - 1, 0, len(self.road.network.graph[_from][_to]) - 1)
- if self.road.network.get_lane(target_lane_index).is_reachable_from(self.position):
+ target_lane_index = (
+ _from,
+ _to,
+ np.clip(_id - 1, 0, len(self.road.network.graph[_from][_to]) - 1),
+ )
+ if self.road.network.get_lane(target_lane_index).is_reachable_from(
+ self.position
+ ):
self.target_lane_index = target_lane_index
- action = {"steering": self.steering_control(self.target_lane_index),
- "acceleration": self.speed_control(self.target_speed)}
- action['steering'] = np.clip(action['steering'], -self.MAX_STEERING_ANGLE, self.MAX_STEERING_ANGLE)
+ action = {
+ "steering": self.steering_control(self.target_lane_index),
+ "acceleration": self.speed_control(self.target_speed),
+ }
+ action["steering"] = np.clip(
+ action["steering"], -self.MAX_STEERING_ANGLE, self.MAX_STEERING_ANGLE
+ )
super().act(action)
@@ -414,10 +441,12 @@
Source code for highway_env.vehicle.controller
def follow_road(self) -> None:
"""At the end of a lane, automatically switch to a next one."""
if self.road.network.get_lane(self.target_lane_index).after_end(self.position):
- self.target_lane_index = self.road.network.next_lane(self.target_lane_index,
- route=self.route,
- position=self.position,
- np_random=self.road.np_random)
+
self.target_lane_index = self.road.network.next_lane(
+
self.target_lane_index,
+
route=self.route,
+
position=self.position,
+
np_random=self.road.np_random,
+
)
@@ -440,16 +469,30 @@
Source code for highway_env.vehicle.controller
lane_future_heading = target_lane.heading_at(lane_next_coords)
# Lateral position control
- lateral_speed_command = - self.KP_LATERAL * lane_coords[1]
+ lateral_speed_command = -self.KP_LATERAL * lane_coords[1]
# Lateral speed to heading
- heading_command = np.arcsin(np.clip(lateral_speed_command / utils.not_zero(self.speed), -1, 1))
- heading_ref = lane_future_heading + np.clip(heading_command, -np.pi/4, np.pi/4)
+ heading_command = np.arcsin(
+ np.clip(lateral_speed_command / utils.not_zero(self.speed), -1, 1)
+ )
+ heading_ref = lane_future_heading + np.clip(
+ heading_command, -np.pi / 4, np.pi / 4
+ )
# Heading control
- heading_rate_command = self.KP_HEADING * utils.wrap_to_pi(heading_ref - self.heading)
+ heading_rate_command = self.KP_HEADING * utils.wrap_to_pi(
+ heading_ref - self.heading
+ )
# Heading rate to steering angle
- slip_angle = np.arcsin(np.clip(self.LENGTH / 2 / utils.not_zero(self.speed) * heading_rate_command, -1, 1))
+ slip_angle = np.arcsin(
+ np.clip(
+ self.LENGTH / 2 / utils.not_zero(self.speed) * heading_rate_command,
+ -1,
+ 1,
+ )
+ )
steering_angle = np.arctan(2 * np.tan(slip_angle))
- steering_angle = np.clip(steering_angle, -self.MAX_STEERING_ANGLE, self.MAX_STEERING_ANGLE)
+ steering_angle = np.clip(
+ steering_angle, -self.MAX_STEERING_ANGLE, self.MAX_STEERING_ANGLE
+ )
return float(steering_angle)
@@ -483,8 +526,11 @@
Source code for highway_env.vehicle.controller
else:
return [self.route]
next_destinations_from = list(next_destinations.keys())
- routes = [self.route[0:index+1] + [(self.route[index][1], destination, self.route[index][2])]
- for destination in next_destinations_from]
+ routes = [
+ self.route[0 : index + 1]
+ + [(self.route[index][1], destination, self.route[index][2])]
+ for destination in next_destinations_from
+ ]
return routes
@@ -508,7 +554,9 @@
Source code for highway_env.vehicle.controller
[docs]
- def predict_trajectory_constant_speed(self, times: np.ndarray) -> Tuple[List[np.ndarray], List[float]]:
+ def predict_trajectory_constant_speed(
+ self, times: np.ndarray
+ ) -> Tuple[List[np.ndarray], List[float]]:
"""
Predict the future positions of the vehicle along its planned route, under constant speed
@@ -517,11 +565,12 @@
Source code for highway_env.vehicle.controller
"""
coordinates = self.lane.local_coordinates(self.position)
route = self.route or [self.lane_index]
- pos_heads = [self.road.network.position_heading_along_route(route,
- coordinates[0] + self.speed * t,
- 0,
- self.lane_index)
- for t in times]
+ pos_heads = [
+ self.road.network.position_heading_along_route(
+ route, coordinates[0] + self.speed * t, 0, self.lane_index
+ )
+ for t in times
+ ]
return tuple(zip(*pos_heads))
@@ -532,17 +581,20 @@
Source code for highway_env.vehicle.controller
class MDPVehicle(ControlledVehicle):
"""A controlled vehicle with a specified discrete range of allowed target speeds."""
+
DEFAULT_TARGET_SPEEDS = np.linspace(20, 30, 3)
- def __init__(self,
- road: Road,
- position: List[float],
- heading: float = 0,
- speed: float = 0,
- target_lane_index: Optional[LaneIndex] = None,
- target_speed: Optional[float] = None,
- target_speeds: Optional[Vector] = None,
- route: Optional[Route] = None) -> None:
+ def __init__(
+ self,
+ road: Road,
+ position: List[float],
+ heading: float = 0,
+ speed: float = 0,
+ target_lane_index: Optional[LaneIndex] = None,
+ target_speed: Optional[float] = None,
+ target_speeds: Optional[Vector] = None,
+ route: Optional[Route] = None,
+ ) -> None:
"""
Initializes an MDPVehicle
@@ -555,8 +607,14 @@
Source code for highway_env.vehicle.controller
:param target_speeds: the discrete list of speeds the vehicle is able to track, through faster/slower actions
:param route: the planned route of the vehicle, to handle intersections
"""
- super().__init__(road, position, heading, speed, target_lane_index, target_speed, route)
- self.target_speeds = np.array(target_speeds) if target_speeds is not None else self.DEFAULT_TARGET_SPEEDS
+ super().__init__(
+ road, position, heading, speed, target_lane_index, target_speed, route
+ )
+ self.target_speeds = (
+ np.array(target_speeds)
+ if target_speeds is not None
+ else self.DEFAULT_TARGET_SPEEDS
+ )
self.speed_index = self.speed_to_index(self.target_speed)
self.target_speed = self.index_to_speed(self.speed_index)
@@ -578,7 +636,9 @@
Source code for highway_env.vehicle.controller
else:
super().act(action)
return
- self.speed_index = int(np.clip(self.speed_index, 0, self.target_speeds.size - 1))
+ self.speed_index = int(
+ np.clip(self.speed_index, 0, self.target_speeds.size - 1)
+ )
self.target_speed = self.index_to_speed(self.speed_index)
super().act()
@@ -606,8 +666,16 @@
Source code for highway_env.vehicle.controller
:param speed: an input speed [m/s]
:return: the index of the closest speed allowed []
"""
- x = (speed - self.target_speeds[0]) / (self.target_speeds[-1] - self.target_speeds[0])
- return np.int64(np.clip(np.round(x * (self.target_speeds.size - 1)), 0, self.target_speeds.size - 1))
+
x = (speed - self.target_speeds[0]) / (
+
self.target_speeds[-1] - self.target_speeds[0]
+
)
+
return np.int64(
+
np.clip(
+
np.round(x * (self.target_speeds.size - 1)),
+
0,
+
self.target_speeds.size - 1,
+
)
+
)
@@ -622,19 +690,33 @@
Source code for highway_env.vehicle.controller
:param speed: an input speed [m/s]
:return: the index of the closest speed allowed []
"""
- x = (speed - cls.DEFAULT_TARGET_SPEEDS[0]) / (cls.DEFAULT_TARGET_SPEEDS[-1] - cls.DEFAULT_TARGET_SPEEDS[0])
- return np.int64(np.clip(
- np.round(x * (cls.DEFAULT_TARGET_SPEEDS.size - 1)), 0, cls.DEFAULT_TARGET_SPEEDS.size - 1))
+
x = (speed - cls.DEFAULT_TARGET_SPEEDS[0]) / (
+
cls.DEFAULT_TARGET_SPEEDS[-1] - cls.DEFAULT_TARGET_SPEEDS[0]
+
)
+
return np.int64(
+
np.clip(
+
np.round(x * (cls.DEFAULT_TARGET_SPEEDS.size - 1)),
+
0,
+
cls.DEFAULT_TARGET_SPEEDS.size - 1,
+
)
+
)
@classmethod
def get_speed_index(cls, vehicle: Vehicle) -> int:
-
return getattr(vehicle, "speed_index", cls.speed_to_index_default(vehicle.speed))
+
return getattr(
+
vehicle, "speed_index", cls.speed_to_index_default(vehicle.speed)
+
)
[docs]
-
def predict_trajectory(self, actions: List, action_duration: float, trajectory_timestep: float, dt: float) \
-
-> List[ControlledVehicle]:
+
def predict_trajectory(
+
self,
+
actions: List,
+
action_duration: float,
+
trajectory_timestep: float,
+
dt: float,
+
) -> List[ControlledVehicle]:
"""
Predict the future trajectory of the vehicle given a sequence of actions.
diff --git a/main/_modules/highway_env/vehicle/kinematics/index.html b/main/_modules/highway_env/vehicle/kinematics/index.html
index 68fab820c..d08ca01d1 100644
--- a/main/_modules/highway_env/vehicle/kinematics/index.html
+++ b/main/_modules/highway_env/vehicle/kinematics/index.html
@@ -291,15 +291,15 @@
Source code for highway_env.vehicle.kinematics
-from typing import Union, Optional, Tuple, List
-import numpy as np
-import copy
+import copy
from collections import deque
+from typing import List, Optional, Tuple, Union
+
+import numpy as np
-from highway_env import utils
-from highway_env.road.road import Road, LaneIndex
-from highway_env.vehicle.objects import RoadObject, Obstacle, Landmark
+from highway_env.road.road import Road
from highway_env.utils import Vector
+from highway_env.vehicle.objects import RoadObject
@@ -319,22 +319,24 @@
Source code for highway_env.vehicle.kinematics
""" Vehicle width [m] """
DEFAULT_INITIAL_SPEEDS = [23, 25]
""" Range for random initial speeds [m/s] """
- MAX_SPEED = 40.
+ MAX_SPEED = 40.0
""" Maximum reachable speed [m/s] """
- MIN_SPEED = -40.
+ MIN_SPEED = -40.0
""" Minimum reachable speed [m/s] """
HISTORY_SIZE = 30
""" Length of the vehicle state history, for trajectory display"""
- def __init__(self,
- road: Road,
- position: Vector,
- heading: float = 0,
- speed: float = 0,
- predition_type: str = 'constant_steering'):
+ def __init__(
+ self,
+ road: Road,
+ position: Vector,
+ heading: float = 0,
+ speed: float = 0,
+ predition_type: str = "constant_steering",
+ ):
super().__init__(road, position, heading, speed)
self.prediction_type = predition_type
- self.action = {'steering': 0, 'acceleration': 0}
+ self.action = {"steering": 0, "acceleration": 0}
self.crashed = False
self.impact = None
self.log = []
@@ -343,13 +345,15 @@
Source code for highway_env.vehicle.kinematics
[docs]
@classmethod
- def create_random(cls, road: Road,
- speed: float = None,
- lane_from: Optional[str] = None,
- lane_to: Optional[str] = None,
- lane_id: Optional[int] = None,
- spacing: float = 1) \
- -> "Vehicle":
+ def create_random(
+ cls,
+ road: Road,
+ speed: float = None,
+ lane_from: Optional[str] = None,
+ lane_to: Optional[str] = None,
+ lane_id: Optional[int] = None,
+ spacing: float = 1,
+ ) -> "Vehicle":
"""
Create a random vehicle on the road.
@@ -366,17 +370,32 @@
Source code for highway_env.vehicle.kinematics
"""
_from = lane_from or road.np_random.choice(list(road.network.graph.keys()))
_to = lane_to or road.np_random.choice(list(road.network.graph[_from].keys()))
- _id = lane_id if lane_id is not None else road.np_random.choice(len(road.network.graph[_from][_to]))
+ _id = (
+ lane_id
+ if lane_id is not None
+ else road.np_random.choice(len(road.network.graph[_from][_to]))
+ )
lane = road.network.get_lane((_from, _to, _id))
if speed is None:
if lane.speed_limit is not None:
- speed = road.np_random.uniform(0.7*lane.speed_limit, 0.8*lane.speed_limit)
+ speed = road.np_random.uniform(
+ 0.7 * lane.speed_limit, 0.8 * lane.speed_limit
+ )
else:
- speed = road.np_random.uniform(Vehicle.DEFAULT_INITIAL_SPEEDS[0], Vehicle.DEFAULT_INITIAL_SPEEDS[1])
- default_spacing = 12+1.0*speed
- offset = spacing * default_spacing * np.exp(-5 / 40 * len(road.network.graph[_from][_to]))
- x0 = np.max([lane.local_coordinates(v.position)[0] for v in road.vehicles]) \
- if len(road.vehicles) else 3*offset
+ speed = road.np_random.uniform(
+ Vehicle.DEFAULT_INITIAL_SPEEDS[0], Vehicle.DEFAULT_INITIAL_SPEEDS[1]
+ )
+ default_spacing = 12 + 1.0 * speed
+ offset = (
+ spacing
+ * default_spacing
+ * np.exp(-5 / 40 * len(road.network.graph[_from][_to]))
+ )
+ x0 = (
+ np.max([lane.local_coordinates(v.position)[0] for v in road.vehicles])
+ if len(road.vehicles)
+ else 3 * offset
+ )
x0 += offset * road.np_random.uniform(0.9, 1.1)
v = cls(road, lane.position(x0, 0), lane.heading_at(x0), speed)
return v
@@ -395,7 +414,7 @@
Source code for highway_env.vehicle.kinematics
:return: a new vehicle at the same dynamical state
"""
v = cls(vehicle.road, vehicle.position, vehicle.heading, vehicle.speed)
- if hasattr(vehicle, 'color'):
+ if hasattr(vehicle, "color"):
v.color = vehicle.color
return v
@@ -425,43 +444,52 @@
Source code for highway_env.vehicle.kinematics
:param dt: timestep of integration of the model [s]
"""
self.clip_actions()
- delta_f = self.action['steering']
+ delta_f = self.action["steering"]
beta = np.arctan(1 / 2 * np.tan(delta_f))
- v = self.speed * np.array([np.cos(self.heading + beta),
- np.sin(self.heading + beta)])
+ v = self.speed * np.array(
+ [np.cos(self.heading + beta), np.sin(self.heading + beta)]
+ )
self.position += v * dt
if self.impact is not None:
self.position += self.impact
self.crashed = True
self.impact = None
self.heading += self.speed * np.sin(beta) / (self.LENGTH / 2) * dt
- self.speed += self.action['acceleration'] * dt
+ self.speed += self.action["acceleration"] * dt
self.on_state_update()
def clip_actions(self) -> None:
if self.crashed:
-
self.action['steering'] = 0
-
self.action['acceleration'] = -1.0*self.speed
-
self.action['steering'] = float(self.action['steering'])
-
self.action['acceleration'] = float(self.action['acceleration'])
+
self.action["steering"] = 0
+
self.action["acceleration"] = -1.0 * self.speed
+
self.action["steering"] = float(self.action["steering"])
+
self.action["acceleration"] = float(self.action["acceleration"])
if self.speed > self.MAX_SPEED:
-
self.action['acceleration'] = min(self.action['acceleration'], 1.0 * (self.MAX_SPEED - self.speed))
+
self.action["acceleration"] = min(
+
self.action["acceleration"], 1.0 * (self.MAX_SPEED - self.speed)
+
)
elif self.speed < self.MIN_SPEED:
-
self.action['acceleration'] = max(self.action['acceleration'], 1.0 * (self.MIN_SPEED - self.speed))
+
self.action["acceleration"] = max(
+
self.action["acceleration"], 1.0 * (self.MIN_SPEED - self.speed)
+
)
def on_state_update(self) -> None:
if self.road:
-
self.lane_index = self.road.network.get_closest_lane_index(self.position, self.heading)
+
self.lane_index = self.road.network.get_closest_lane_index(
+
self.position, self.heading
+
)
self.lane = self.road.network.get_lane(self.lane_index)
if self.road.record_history:
self.history.appendleft(self.create_from(self))
-
def predict_trajectory_constant_speed(self, times: np.ndarray) -> Tuple[List[np.ndarray], List[float]]:
-
if self.prediction_type == 'zero_steering':
-
action = {'acceleration': 0.0, 'steering': 0.0}
-
elif self.prediction_type == 'constant_steering':
-
action = {'acceleration': 0.0, 'steering': self.action['steering']}
+
def predict_trajectory_constant_speed(
+
self, times: np.ndarray
+
) -> Tuple[List[np.ndarray], List[float]]:
+
if self.prediction_type == "zero_steering":
+
action = {"acceleration": 0.0, "steering": 0.0}
+
elif self.prediction_type == "constant_steering":
+
action = {"acceleration": 0.0, "steering": self.action["steering"]}
else:
raise ValueError("Unknown predition type")
@@ -485,7 +513,11 @@
Source code for highway_env.vehicle.kinematics
def destination(self) -> np.ndarray:
if getattr(self, "route", None):
last_lane_index = self.route[-1]
- last_lane_index = last_lane_index if last_lane_index[-1] is not None else (*last_lane_index[:-1], 0)
+ last_lane_index = (
+ last_lane_index
+ if last_lane_index[-1] is not None
+ else (*last_lane_index[:-1], 0)
+ )
last_lane = self.road.network.get_lane(last_lane_index)
return last_lane.position(last_lane.length, 0)
else:
@@ -494,7 +526,9 @@
Source code for highway_env.vehicle.kinematics
@property
def destination_direction(self) -> np.ndarray:
if (self.destination != self.position).any():
- return (self.destination - self.position) / np.linalg.norm(self.destination - self.position)
+ return (self.destination - self.position) / np.linalg.norm(
+ self.destination - self.position
+ )
else:
return np.zeros((2,))
@@ -507,40 +541,49 @@
Source code for highway_env.vehicle.kinematics
else:
return np.zeros((3,))
- def to_dict(self, origin_vehicle: "Vehicle" = None, observe_intentions: bool = True) -> dict:
+ def to_dict(
+ self, origin_vehicle: "Vehicle" = None, observe_intentions: bool = True
+ ) -> dict:
d = {
- 'presence': 1,
- 'x': self.position[0],
- 'y': self.position[1],
- 'vx': self.velocity[0],
- 'vy': self.velocity[1],
- 'heading': self.heading,
- 'cos_h': self.direction[0],
- 'sin_h': self.direction[1],
- 'cos_d': self.destination_direction[0],
- 'sin_d': self.destination_direction[1],
- 'long_off': self.lane_offset[0],
- 'lat_off': self.lane_offset[1],
- 'ang_off': self.lane_offset[2],
+ "presence": 1,
+ "x": self.position[0],
+ "y": self.position[1],
+ "vx": self.velocity[0],
+ "vy": self.velocity[1],
+ "heading": self.heading,
+ "cos_h": self.direction[0],
+ "sin_h": self.direction[1],
+ "cos_d": self.destination_direction[0],
+ "sin_d": self.destination_direction[1],
+ "long_off": self.lane_offset[0],
+ "lat_off": self.lane_offset[1],
+ "ang_off": self.lane_offset[2],
}
if not observe_intentions:
d["cos_d"] = d["sin_d"] = 0
if origin_vehicle:
origin_dict = origin_vehicle.to_dict()
- for key in ['x', 'y', 'vx', 'vy']:
+ for key in ["x", "y", "vx", "vy"]:
d[key] -= origin_dict[key]
return d
def __str__(self):
- return "{} #{}: {}".format(self.__class__.__name__, id(self) % 1000, self.position)
+ return "{} #{}: {}".format(
+ self.__class__.__name__, id(self) % 1000, self.position
+ )
def __repr__(self):
return self.__str__()
[docs]
-
def predict_trajectory(self, actions: List, action_duration: float, trajectory_timestep: float, dt: float) \
-
-> List['Vehicle']:
+
def predict_trajectory(
+
self,
+
actions: List,
+
action_duration: float,
+
trajectory_timestep: float,
+
dt: float,
+
) -> List["Vehicle"]:
"""
Predict the future trajectory of the vehicle given a sequence of actions.
diff --git a/main/observations/index.html b/main/observations/index.html
index f242e39ae..fd365171e 100644
--- a/main/observations/index.html
+++ b/main/observations/index.html
@@ -557,25 +557,25 @@
Example configuration
-
[[ 1. 1. 0. 1. 0. 1.
+[[ 1. 1. 0.04 1. 0. 1.
0. ]
- [ 1. 0.20323725 0.04 -0.07361443 0. 1.
+ [ 1. 0.2116441 -0.04 -0.07987082 0. 1.
0. ]
- [ 1. 0.39618185 0.08 -0.11105874 0. 1.
+ [ 1. 0.40037498 -0.04 -0.14375238 0. 1.
0. ]
- [ 1. 0.6169058 0.04 -0.17033932 0. 1.
+ [ 1. 0.5924493 -0.04 -0.14188124 0. 1.
0. ]
- [ 1. 0.83093834 0.08 -0.0526074 0. 1.
+ [ 1. 0.81080985 0. -0.17013432 0. 1.
0. ]
- [ 1. 1. 0.12 -0.18704522 0. 1.
+ [ 1. 1. 0.04 -0.12747008 0. 1.
0. ]
- [ 1. 1. 0.04 -0.1492452 0. 1.
+ [ 1. 1. 0.04 -0.08804176 0. 1.
0. ]
- [ 1. 1. 0.08 -0.05019206 0. 1.
+ [ 1. 1. 0. -0.11419602 0. 1.
0. ]
- [ 1. 1. 0. -0.07072275 0. 1.
+ [ 1. 1. 0. -0.13449906 0. 1.
0. ]
- [ 1. 1. 0.08 -0.18716832 0. 1.
+ [ 1. 1. 0.04 -0.19995664 0. 1.
0. ]
[ 0. 0. 0. 0. 0. 0.
0. ]
diff --git a/main/searchindex.js b/main/searchindex.js
index 7590d8d4a..827b5ae39 100644
--- a/main/searchindex.js
+++ b/main/searchindex.js
@@ -1 +1 @@
-Search.setIndex({"docnames": ["404", "actions/index", "bibliography/index", "dynamics/index", "dynamics/road/lane", "dynamics/road/regulation", "dynamics/road/road", "dynamics/vehicle/behavior", "dynamics/vehicle/controller", "dynamics/vehicle/kinematics", "environments/highway", "environments/index", "environments/intersection", "environments/merge", "environments/parking", "environments/racetrack", "environments/roundabout", "faq", "graphics/index", "index", "installation", "make_your_own", "multi_agent", "observations/index", "quickstart", "rewards/index", "user_guide"], "filenames": ["404.md", "actions/index.md", "bibliography/index.md", "dynamics/index.md", "dynamics/road/lane.md", "dynamics/road/regulation.md", "dynamics/road/road.md", "dynamics/vehicle/behavior.md", "dynamics/vehicle/controller.md", "dynamics/vehicle/kinematics.md", "environments/highway.md", "environments/index.md", "environments/intersection.md", "environments/merge.md", "environments/parking.md", "environments/racetrack.md", "environments/roundabout.md", "faq.md", "graphics/index.md", "index.md", "installation.md", "make_your_own.md", "multi_agent.md", "observations/index.md", "quickstart.md", "rewards/index.md", "user_guide.md"], "titles": ["404", "Actions", "Bibliography", "Dynamics", "Lane", "Road regulation", "Road", "Behavior", "Control", "Kinematics", "Highway", "The environments", "Intersection", "Merge", "Parking", "Racetrack", "Roundabout", "Frequently Asked Questions", "Graphics", "Welcome to highway-env\u2019s documentation!", "Installation", "Make your own environment", "The Multi-Agent setting", "Observations", "Getting Started", "Rewards", "User Guide"], "terms": {"similarli": 1, "observ": [1, 2, 10, 12, 13, 14, 15, 16, 21, 24, 25, 26], "sever": [1, 7, 10, 12, 17, 21, 23, 24], "type": [1, 4, 10, 12, 13, 14, 15, 16, 21, 22, 23, 24], "can": [1, 4, 6, 7, 8, 10, 12, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23, 24, 25], "us": [1, 7, 8, 9, 14, 18, 19, 20, 21, 23, 24, 25], "everi": [1, 3, 25], "environ": [1, 3, 10, 12, 13, 14, 15, 16, 18, 19, 22, 23, 26], "thei": [1, 5, 7, 13, 18, 23, 25], "ar": [1, 3, 4, 5, 6, 7, 8, 9, 10, 18, 21, 22, 23, 24, 25], "defin": [1, 4, 6, 10, 12, 13, 14, 15, 16, 18, 21, 23, 24, 25], "modul": [1, 21, 23], "each": [1, 5, 6, 8, 9, 12, 17, 18, 22, 23], "come": [1, 12, 23], "default": [1, 7, 8, 9, 18, 21, 23, 24], "which": [1, 4, 5, 6, 7, 8, 12, 14, 17, 18, 20, 21, 22, 23, 24, 25], "chang": [1, 2, 4, 7, 8, 16, 17, 21, 23, 24, 26], "customis": [1, 23], "configur": [1, 18, 22, 25, 26], "For": [1, 6, 7, 17, 22, 23, 24], "instanc": [1, 4, 6, 7, 8, 9, 23, 24], "import": [1, 3, 17, 21, 22, 23, 24], "gymnasium": [1, 18, 21, 22, 23, 24], "gym": [1, 10, 12, 13, 14, 15, 16, 17, 18, 21, 22, 23, 24], "env": [1, 10, 12, 13, 14, 15, 16, 17, 18, 20, 21, 22, 23, 24], "make": [1, 2, 10, 12, 13, 14, 15, 16, 18, 19, 22, 23, 26], "highwai": [1, 11, 13, 15, 18, 20, 22, 23, 24], "v0": [1, 10, 12, 13, 14, 15, 16, 17, 18, 21, 22, 23, 24], "config": [1, 4, 10, 12, 13, 14, 15, 16, 18, 21, 22, 23, 24], "continuousact": [1, 14, 15], "The": [1, 2, 3, 4, 6, 7, 8, 9, 10, 12, 13, 15, 16, 18, 19, 20, 21, 23, 24, 25, 26], "allow": [1, 7, 8, 21], "agent": [1, 10, 12, 13, 14, 15, 18, 21, 23, 25, 26], "directli": [1, 23, 25], "set": [1, 2, 4, 5, 6, 8, 14, 18, 23, 26], "low": [1, 8], "level": [1, 2, 4, 8, 17], "vehicl": [1, 2, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16, 17, 18, 24, 25, 26], "kinemat": [1, 2, 3, 6, 8, 10, 12, 22, 24, 26], "name": [1, 23], "throttl": [1, 8], "steer": [1, 7, 8, 9, 14], "angl": [1, 4, 7, 8, 9, 18, 23], "delta": [1, 7, 8, 9], "enabl": [1, 23], "disabl": 1, "through": [1, 2, 3, 5, 8, 21, 25], "longitudin": [1, 4, 9, 12, 15, 16, 18, 23], "later": [1, 4, 12, 15, 18, 23], "respect": [1, 7, 8, 18, 25], "thu": [1, 17, 25], "space": [1, 7, 9, 14, 18, 21, 23, 26], "either": 1, "1d": [1, 7], "2d": [1, 4, 7], "discreteact": 1, "i": [1, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16, 18, 19, 21, 22, 24, 25], "uniform": [1, 8, 23], "quantiz": 1, "abov": 1, "actions_per_axi": 1, "paramet": [1, 4, 5, 6, 7, 8, 9, 12, 14, 18, 21, 23, 25], "step": [1, 5, 6, 7, 9, 12, 16, 17, 21, 22, 23, 24], "axi": [1, 7, 8, 9, 23], "separ": [1, 18], "discretemetaact": [1, 10, 12, 13, 16, 22, 24], "add": [1, 21], "layer": [1, 23], "speed": [1, 7, 8, 9, 10, 13, 14, 21, 25], "top": [1, 8, 23], "so": [1, 7, 13, 14, 17, 18, 21, 23], "ego": [1, 7, 10, 12, 13, 14, 16, 18, 21, 25], "automat": [1, 8, 16, 21], "follow": [1, 2, 6, 7, 8, 15, 16, 17, 18, 21, 23, 24], "road": [1, 4, 7, 8, 9, 10, 12, 13, 18, 21, 23, 25, 26], "desir": [1, 7, 8, 14, 21, 23, 25], "veloc": [1, 5, 7, 8, 23, 25], "Then": 1, "avail": [1, 10, 24], "consist": [1, 2], "target": [1, 5, 7, 8], "lane": [1, 2, 3, 5, 6, 7, 8, 9, 10, 16, 17, 18, 21, 22, 23, 24], "setpoint": 1, "full": [1, 24], "correspond": [1, 4, 8, 14, 17, 18, 21, 23], "actions_al": [1, 22], "0": [1, 4, 5, 7, 8, 9, 10, 12, 13, 14, 15, 16, 18, 20, 21, 22, 23, 24, 25], "lane_left": 1, "1": [1, 4, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16, 17, 18, 22, 23, 24, 25], "idl": [1, 23, 24], "2": [1, 2, 7, 8, 9, 10, 20, 22, 23, 24], "lane_right": 1, "3": [1, 7, 10, 12, 13, 15, 18, 20, 23, 24], "faster": [1, 8, 23], "4": [1, 7, 10, 15, 18, 23, 24], "slower": [1, 8], "some": [1, 5, 8, 13, 25], "might": 1, "alwai": [1, 18, 23], "edg": [1, 6], "acceler": [1, 7, 8, 9, 14], "decelr": 1, "beyond": 1, "maximum": [1, 7, 9, 21, 23, 25], "minimum": [1, 7, 9, 25], "list": [1, 3, 4, 5, 6, 7, 8, 9, 17, 18, 21, 23, 24], "access": [1, 13, 21, 24], "get_available_act": 1, "method": [1, 4, 5, 7, 8, 9, 16, 21, 25], "take": [1, 5, 7, 23, 24], "an": [1, 5, 6, 7, 8, 9, 12, 18, 19, 21, 22, 23, 25], "unavail": 1, "equival": 1, "intersect": [1, 5, 6, 8, 11, 24], "onli": [1, 7, 9, 21, 22, 24, 25], "while": [1, 9, 10, 13, 15, 16, 17, 21, 22, 24], "perform": [1, 7, 8, 12, 21, 23, 24], "track": [1, 8, 15], "simul": [1, 2, 7, 8, 9, 12, 17, 18, 21, 23], "manual_control": [1, 24], "true": [1, 4, 7, 10, 12, 13, 14, 15, 16, 17, 23, 24], "reset": [1, 17, 18, 21, 22, 23, 24], "done": [1, 16, 17, 18, 22, 23, 24], "fals": [1, 4, 5, 6, 10, 12, 13, 14, 15, 16, 17, 18, 22, 23, 24], "action_spac": [1, 17, 21], "sampl": [1, 17, 21], "ignor": 1, "direct": [1, 7, 8, 9, 23], "arrow": 1, "kei": [1, 16, 18, 23], "eventhandl": 1, "class": [1, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16, 18, 21, 22, 23], "highway_env": [1, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16, 17, 18, 21, 22, 23, 24], "common": [1, 18, 21, 22, 23], "actiontyp": 1, "abstractenv": [1, 18, 21, 23], "kwarg": [1, 23], "sourc": [1, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16, 18, 21, 23], "A": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 13, 14, 15, 18, 21, 22, 23, 24], "specifi": [1, 8, 21, 25], "its": [1, 4, 6, 7, 8, 9, 16, 17, 22, 24], "definit": 1, "how": [1, 3, 7, 22, 24], "execut": [1, 7, 12, 21, 22], "properti": [1, 7, 8, 9, 21], "vehicle_class": [1, 21], "callabl": [1, 18], "abl": [1, 8, 17, 21], "must": [1, 6, 14, 18, 20, 21, 22, 24, 25], "return": [1, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16, 18, 21, 22, 23, 25], "subclass": 1, "act": [1, 6, 7, 8, 9], "int": [1, 4, 6, 7, 8, 9, 12, 18, 21, 23, 24], "ndarrai": [1, 4, 7, 8, 9, 12, 14, 18, 21, 23], "none": [1, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16, 18, 21, 23, 24], "most": [1, 5, 22, 26], "mechan": 1, "actual": [1, 6, 17, 22], "implement": [1, 4, 7, 8, 10, 12, 13, 14, 15, 16, 17, 18, 21, 22, 23, 24], "where": [1, 6, 7, 8, 9, 14, 15, 21, 23, 25], "pre": 1, "process": [1, 2], "appli": [1, 8], "base": [1, 5, 7, 9, 24], "controlled_vehicl": [1, 15, 22, 24], "upon": 1, "If": [1, 7, 8, 9, 16, 19, 21, 23], "first": [1, 5, 17, 18, 21, 22, 23], "acceleration_rang": 1, "tupl": [1, 4, 6, 7, 8, 12, 18, 21, 22, 23], "float": [1, 4, 5, 6, 7, 8, 9, 12, 14, 18, 21, 23], "steering_rang": 1, "speed_rang": 1, "bool": [1, 4, 5, 6, 7, 12, 18, 21, 23], "dynam": [1, 5, 6, 7, 8, 9, 12, 21, 24, 26], "clip": [1, 23], "both": [1, 4, 7, 22, 23], "thi": [1, 4, 7, 10, 12, 13, 16, 17, 20, 21, 22, 23, 24, 25], "order": [1, 9, 17, 22, 23, 25], "interv": 1, "map": [1, 10, 23], "creat": [1, 4, 7, 8, 9, 18, 24, 26], "rang": [1, 7, 8, 9, 10, 23, 24, 25], "valu": [1, 16, 21, 23, 24], "m": [1, 4, 7, 8, 9, 10, 16, 18, 21, 23], "s\u00b2": 1, "rad": [1, 4, 7, 8], "reachabl": [1, 4, 9], "": [1, 5, 6, 7, 8, 9, 10, 12, 13, 16, 17, 18, 21, 22, 23, 24, 25], "whether": [1, 4, 5, 6, 7, 18, 21, 23], "e": [1, 2, 17], "friction": 1, "rather": [1, 25], "than": [1, 7, 17, 23, 25], "5": [1, 7, 9, 10, 12, 13, 14, 15, 16, 20, 22, 23, 24], "x": [1, 4, 9, 12, 14, 18, 23, 25], "7853981633974483": 1, "box": 1, "target_spe": [1, 7, 8], "sequenc": [1, 4, 7, 8, 9, 18, 23], "cruis": [1, 8], "point": [1, 2, 4], "includ": [1, 5, 6, 22], "index": [1, 6, 7, 8, 23], "label": 1, "actions_longi": 1, "actions_lat": 1, "get": [1, 4, 8, 20, 22, 23], "current": [1, 6, 8, 9, 20, 21, 23, 25], "boundari": 1, "maxim": [1, 7], "minim": [1, 7], "multiagentact": [1, 22], "action_config": [1, 22], "dict": [1, 4, 7, 8, 9, 10, 12, 13, 14, 15, 16, 18, 21, 23, 24], "awr": [2, 24], "17": [2, 24], "marcin": 2, "andrychowicz": 2, "filip": 2, "wolski": 2, "alex": 2, "rai": 2, "jona": 2, "schneider": 2, "rachel": 2, "fong": 2, "peter": 2, "welind": 2, "bob": 2, "mcgrew": 2, "josh": 2, "tobin": 2, "pieter": 2, "abbeel": 2, "wojciech": 2, "zaremba": 2, "hindsight": [2, 24], "experi": [2, 22, 24], "replai": [2, 24], "In": [2, 7, 10, 13, 16, 17, 21, 22, 23, 25], "advanc": 2, "neural": 2, "inform": [2, 14, 17, 21, 23], "system": [2, 4, 9, 12, 18], "2017": 2, "arxiv": 2, "1707": 2, "01495": 2, "hm08": [2, 24], "jean": 2, "fran": 2, "\u00e7": 2, "oi": 2, "hren": 2, "r": [2, 7, 8, 25], "\u00e9": 2, "mi": 2, "muno": 2, "optimist": 2, "plan": [2, 8, 16, 24], "determinist": [2, 24], "lectur": 2, "note": [2, 25], "comput": [2, 4, 7, 8, 21], "scienc": 2, "2008": 2, "kth07": [2, 7], "arn": 2, "kest": 2, "martin": 2, "treiber": 2, "dirk": 2, "helb": 2, "gener": [2, 5, 6, 17, 21, 22, 25], "model": [2, 3, 7, 8, 9, 21, 22, 24], "mobil": [2, 7], "car": 2, "transport": 2, "research": 2, "record": [2, 5, 6, 17], "2007": 2, "doi": 2, "10": [2, 7, 12, 23], "3141": 2, "1999": 2, "lm19": [2, 17, 24], "edouard": [2, 19], "leurent": [2, 19], "mercat": 2, "social": [2, 24], "attent": [2, 24], "autonom": [2, 19], "decis": [2, 7, 12, 19, 21], "dens": [2, 12], "traffic": [2, 12, 13, 16], "machin": 2, "learn": [2, 15, 24, 25], "drive": [2, 5, 6, 8, 9, 10, 13, 18, 19, 21, 24, 25], "workshop": 2, "thirti": 2, "third": 2, "confer": 2, "neurip": 2, "2019": [2, 24], "montreal": 2, "canada": 2, "decemb": 2, "1911": 2, "12250": 2, "mk": [2, 25], "15": [2, 10, 12, 13, 14, 15, 16, 17, 18, 23, 24, 25], "volodymyr": 2, "mnih": 2, "korai": 2, "kavukcuoglu": 2, "david": 2, "silver": 2, "andrei": 2, "rusu": 2, "joel": 2, "veness": 2, "marc": 2, "g": [2, 17], "bellemar": 2, "grave": 2, "riedmil": 2, "andrea": 2, "k": [2, 16, 18], "fidjeland": 2, "georg": 2, "ostrovski": 2, "stig": 2, "petersen": 2, "charl": 2, "beatti": 2, "amir": 2, "sadik": 2, "ioanni": 2, "antonogl": 2, "helen": 2, "king": 2, "dharshan": 2, "kumaran": 2, "daan": 2, "wierstra": 2, "shane": 2, "legg": 2, "demi": 2, "hassabi": 2, "human": 2, "control": [2, 3, 7, 14, 15, 16, 21, 26], "deep": [2, 24, 25], "reinforc": [2, 24, 25], "natur": [2, 23], "518": 2, "7540": 2, "529": 2, "533": 2, "2015": 2, "paltchedandrean17": [2, 9], "philip": 2, "polack": 2, "florent": 2, "altch": 2, "brigitt": 2, "d": [2, 7], "andr": 2, "novel": [2, 17], "bicycl": [2, 9], "feasibl": 2, "trajectori": [2, 5, 6, 8, 9, 24, 25], "ieee": 2, "intellig": [2, 7], "symposium": 2, "page": [2, 24], "6": [2, 7, 12, 16, 23], "8": [2, 23, 24], "qsmg17": [2, 17], "qi": 2, "hao": 2, "su": 2, "kaichun": 2, "mo": 2, "leonida": 2, "j": [2, 23], "guiba": 2, "pointnet": 2, "3d": 2, "classif": 2, "segment": 2, "1612": 2, "00593": 2, "thh00": [2, 7], "ansgar": 2, "henneck": 2, "congest": 2, "state": [2, 7, 8, 9, 17, 21, 22, 23, 25], "empir": 2, "microscop": 2, "physic": [2, 3], "review": 2, "statist": 2, "plasma": 2, "fluid": 2, "relat": 2, "interdisciplinari": 2, "topic": 2, "62": 2, "1805": 2, "1824": 2, "2000": 2, "describ": [3, 4, 5, 6, 10, 17, 19, 21, 22, 23], "move": [3, 9, 18, 23], "behav": [3, 5], "time": [3, 5, 7, 8, 16, 25, 26], "There": [3, 24], "two": [3, 5, 7, 8, 15, 17, 18, 22, 23, 25], "section": 3, "affect": 3, "descript": [3, 19, 23, 24], "behavior": [3, 5, 10, 12, 13, 16, 21, 24], "compos": [3, 6, 25], "roadnetwork": [3, 5, 6, 21], "regul": 3, "geometri": [4, 6, 21], "abstractlan": [4, 6, 18], "object": [4, 5, 6, 7, 8, 9, 10, 13, 18, 21, 23], "parametr": [4, 24], "center": [4, 7, 8, 9, 18, 23], "line": [4, 8, 18], "curv": [4, 24], "provid": [4, 8, 17, 18, 19, 21, 24], "local": [4, 6, 17, 18], "coordin": [4, 6, 18, 23], "convers": [4, 23], "between": [4, 5, 7, 8, 9, 18, 23, 25], "longi": 4, "lat": [4, 8, 18], "frenet": 4, "frame": [4, 17, 18, 21, 23], "global": 4, "y": [4, 9, 12, 14, 18, 20, 23, 25], "ensur": 4, "posit": [4, 6, 7, 9, 14, 18, 23], "local_coordin": 4, "main": [4, 13], "straightlan": 4, "sinelan": 4, "circularlan": 4, "central": [4, 12, 22], "metaclass__": 4, "alia": 4, "abcmeta": 4, "abstract": [4, 21], "convert": [4, 8, 18, 23], "world": [4, 23, 26], "heading_at": 4, "head": [4, 7, 9, 14, 23], "given": [4, 6, 7, 8, 9, 14, 17, 18, 21], "width_at": 4, "width": [4, 9, 16, 18], "classmethod": [4, 7, 8, 9, 10, 12, 13, 14, 15, 16, 18, 21], "from_config": 4, "from": [4, 6, 7, 8, 9, 10, 14, 21, 22, 23, 24, 25], "json": [4, 22], "to_config": 4, "write": 4, "serial": 4, "on_lan": 4, "margin": [4, 18], "option": [4, 19, 21], "known": 4, "supplementari": [4, 14], "around": [4, 18, 23], "is_reachable_from": 4, "distanc": [4, 7, 18, 21, 23, 25], "l1": 4, "distance_with_head": 4, "heading_weight": 4, "weight": [4, 7, 14, 23, 25], "local_angl": 4, "long_offset": 4, "non": [4, 7, 8, 23], "normalis": [4, 23], "linetyp": 4, "side": [4, 10, 18], "start": [4, 6, 9, 13, 18, 19], "end": [4, 6, 8, 9, 12, 18, 21, 22], "default_width": 4, "line_typ": 4, "forbidden": 4, "speed_limit": 4, "20": [4, 10, 12, 23, 24], "prioriti": [4, 5], "go": [4, 6], "straight": [4, 10, 23], "new": [4, 5, 6, 7, 8, 9, 17, 21], "determin": [4, 5], "who": [4, 5], "ha": [4, 15, 16, 20, 21, 22, 23, 24, 25], "right": [4, 5, 7, 8, 10, 18, 22, 23], "wai": [4, 5, 12, 17, 24], "amplitud": 4, "pulsat": 4, "phase": 4, "sinusoid": 4, "oscil": 4, "initi": [4, 8, 9, 14, 15, 18, 21, 22], "radiu": 4, "start_phas": 4, "end_phas": 4, "clockwis": 4, "circl": 4, "arc": 4, "polylanefixedwidth": 4, "lane_point": 4, "fix": [4, 21, 23], "approxim": [4, 7], "hermit": 4, "polynomi": 4, "polylan": 4, "left_boundary_point": 4, "right_boundary_point": 4, "regulatedroad": 5, "give": [5, 6, 21, 23], "attribut": [5, 24], "On": 5, "rule": 5, "enforc": 5, "usual": [5, 17], "howev": [5, 17, 24, 25], "try": [5, 7], "predict": [5, 8, 9, 12, 22, 23, 24], "collis": [5, 10, 12, 13, 15, 16, 25, 26], "other": [5, 7, 8, 9, 10, 12, 15, 21, 22, 23], "is_conflict_poss": 5, "when": [5, 7, 8, 10], "case": [5, 6, 17, 23], "arbitr": 5, "respect_prior": 5, "yield": [5, 8, 24, 25], "until": [5, 9, 12, 21], "conflict": 5, "resolv": 5, "network": [5, 6, 8, 21, 23], "obstacl": [5, 6, 23], "np_random": [5, 6], "randomst": [5, 6], "record_histori": [5, 6], "road_object": [5, 6], "landmark": [5, 6], "np": [5, 6], "random": [5, 6, 9, 24], "number": [5, 6, 9, 16, 18, 23, 24, 26], "behaviour": [5, 6, 7, 12, 18, 21, 25], "recent": [5, 6], "should": [5, 6, 7, 17, 18, 21, 22, 23, 25], "displai": [5, 6, 9, 16, 18], "dt": [5, 6, 7, 8, 9], "entiti": [5, 6], "timestep": [5, 6, 7, 8, 9, 12, 21], "enforce_road_rul": 5, "find": [5, 6, 8], "them": [5, 18, 24, 25], "assign": 5, "stop": [5, 7, 9], "static": [5, 18], "v1": 5, "v2": 5, "second": [5, 6, 16, 21, 22], "topologi": [6, 21], "infrastructur": 6, "graph": 6, "repres": [6, 9, 18, 23], "node": [6, 8, 9], "It": [6, 7, 8, 9, 12, 13, 14, 16], "contain": [6, 21, 22, 23], "dictionari": [6, 21, 23, 24], "store": [6, 7, 9], "laneindex": 6, "string": 6, "identifi": 6, "integ": 6, "uniqu": 6, "lab": 6, "pub": 6, "obtain": [6, 24], "road_network": 6, "roadobject": [6, 18], "decid": [6, 7, 22], "action": [6, 7, 8, 9, 10, 12, 13, 14, 15, 16, 17, 18, 21, 24, 26], "neighbour_vehicl": 6, "lane_index": [6, 7], "str": [6, 7, 8, 9, 10, 12, 13, 14, 15, 16, 21, 23], "preced": [6, 7], "whose": [6, 7], "neighbour": [6, 10], "found": [6, 25], "look": [6, 23], "doesn": [6, 7], "t": [6, 7, 16, 23], "have": [6, 7, 14, 21, 25], "also": [6, 10, 13, 17, 18, 23, 24, 25], "anoth": 6, "project": [6, 7, 19, 20, 25], "consid": [6, 19, 23], "simpl": [7, 8, 12, 25], "realist": [7, 25], "dictat": 7, "idmvehicl": [7, 10, 13, 16, 21, 24], "driver": 7, "idm": 7, "dot": [7, 8, 9], "v": [7, 8, 9, 23, 25], "left": [7, 8, 18, 22, 23], "frac": [7, 8, 9, 25], "v_0": 7, "d_0": 7, "tv": 7, "sqrt": 7, "ab": 7, "front": [7, 8, 9, 25], "parametris": 7, "target_veloc": 7, "gap": 7, "time_w": 7, "jam": 7, "distance_w": 7, "b": [7, 25], "deceler": 7, "comfort_acc_max": 7, "comfort_acc_min": 7, "expon": 7, "discret": [7, 8, 26], "overal": 7, "brake": [7, 9, 25], "induc": 7, "accord": 7, "safe": [7, 13, 25], "do": [7, 17, 25], "cut": 7, "tild": 7, "_n": 7, "geq": 7, "b_": 7, "text": [7, 8, 25], "incent": 7, "possibli": 7, "underbrac": 7, "_c": 7, "a_c": 7, "_": [7, 22, 23, 24, 25], "p": [7, 8, 14, 25], "a_n": 7, "_o": 7, "a_o": 7, "old": 7, "a_": 7, "th": 7, "c": [7, 18, 23], "o": [7, 18], "befor": [7, 22], "n": 7, "after": [7, 22, 24], "polit": 7, "coeffici": [7, 25], "gain": [7, 8], "requir": [7, 20, 21], "trigger": 7, "lane_change_min_acc_gain": 7, "impos": 7, "dure": [7, 18], "lane_change_max_braking_impos": 7, "linearvehicl": 7, "linear": [7, 8], "featur": [7, 12, 14, 15, 25], "differ": [7, 17, 23], "lead": [7, 23, 25], "target_lane_index": [7, 8], "rout": [7, 8, 16], "enable_lane_chang": 7, "timer": 7, "polici": [7, 21, 22, 24, 25], "nearbi": [7, 23], "place": [7, 8, 9, 23], "cartesian": [7, 8, 9], "surfac": [7, 8, 9, 26], "horizont": [7, 8, 9], "acc_max": 7, "term": [7, 25], "delta_rang": 7, "chosen": [7, 9, 18], "randomli": [7, 9], "create_from": [7, 8, 9], "controlledvehicl": [7, 8], "exist": [7, 8, 9, 21, 23], "one": [7, 8, 9, 18, 22], "copi": [7, 8, 9, 17, 21], "same": [7, 8, 9], "now": [7, 13, 21, 22, 23], "support": [7, 22], "becaus": [7, 17], "all": [7, 12, 17, 21, 23], "own": [7, 12, 22, 26], "increas": [7, 23, 26], "ego_vehicl": 7, "front_vehicl": 7, "rear_vehicl": 7, "command": [7, 8, 9], "reach": [7, 10, 14], "maintain": [7, 13], "safeti": 7, "w": [7, 18, 23, 25], "doe": [7, 17, 24], "why": 7, "reason": [7, 12, 17], "about": [7, 17, 24], "even": [7, 18], "though": 7, "mai": [7, 23, 25], "s2": [7, 8], "desired_gap": 7, "being": [7, 9, 25], "change_lane_polici": 7, "frequenc": [7, 17, 18, 21], "close": [7, 17, 18, 21], "more": [7, 10, 12, 13, 14, 15, 16, 17, 21], "unsaf": 7, "candid": 7, "recover_from_stop": 7, "wrong": 7, "revers": 7, "maneuv": 7, "suggest": [7, 17], "recov": 7, "stuck": 7, "data": [7, 21, 23], "resp": 7, "lower": [7, 21], "higher": 7, "steering_control": [7, 8], "overrid": 7, "wheel": [7, 8, 9], "steering_featur": 7, "collect": [7, 19, 23], "arrai": [7, 18, 22, 23], "collect_data": 7, "output": [7, 17], "regress": 7, "aggressivevehicl": 7, "defensivevehicl": 7, "call": [8, 10, 12, 13, 14, 15, 16, 17, 18, 21], "proport": 8, "k_p": 8, "v_r": 8, "refer": [8, 21], "kp_a": 8, "speed_control": 8, "deriv": 8, "combin": 8, "invert": 8, "those": [8, 24], "v_": [8, 25], "k_": 8, "delta_": 8, "psi_": 8, "arcsin": 8, "psi_r": 8, "psi_l": 8, "psi": [8, 9, 25], "_r": 8, "l": [8, 9, 18, 23], "variat": 8, "lookahead": 8, "anticip": 8, "turn": 8, "yaw": 8, "rate": 8, "pilot": 8, "high": [8, 10, 13, 14], "cascad": 8, "plan_route_to": 8, "destin": [8, 12, 23, 25], "updat": [8, 9, 18, 20, 22, 23], "follow_road": 8, "At": 8, "switch": 8, "next": [8, 12, 21, 23], "get_routes_at_intersect": 8, "set_route_at_intersect": 8, "_to": 8, "eras": 8, "predict_trajectory_constant_spe": 8, "futur": [8, 9], "along": [8, 18, 23], "under": 8, "constant": [8, 21, 23], "mdpvehicl": 8, "handl": [8, 16, 18], "choos": [8, 25], "els": [8, 23], "forward": [8, 9, 18], "handler": 8, "index_to_spe": 8, "among": 8, "speed_to_index": 8, "closest": [8, 23], "assum": [8, 23], "avoid": [8, 10, 12, 13, 15, 16, 25], "search": 8, "input": [8, 9, 18], "speed_to_index_default": 8, "predict_trajectori": [8, 9], "action_dur": [8, 9], "trajectory_timestep": [8, 9], "durat": [8, 9, 10, 12, 15, 16, 24], "save": [8, 9, 24], "co": [9, 25], "beta": 9, "sin": [9, 25], "tan": 9, "slip": 9, "graviti": 9, "These": [9, 21, 23], "calcul": 9, "appear": 9, "predition_typ": 9, "constant_st": 9, "modifi": [9, 21], "propag": 9, "depend": [9, 17, 20, 21], "length": [9, 18], "default_initial_spe": 9, "23": 9, "25": [9, 23], "max_spe": 9, "40": [9, 10, 24], "min_spe": 9, "history_s": 9, "30": [9, 10, 24], "histori": 9, "create_random": 9, "lane_from": 9, "lane_to": 9, "lane_id": 9, "behind": [9, 23], "last": [9, 21, 23], "densiti": 9, "spawn": 9, "id": [9, 21], "ratio": 9, "repeat": 9, "integr": 9, "1st": 9, "respons": 9, "crash": [9, 16], "overridden": 9, "errat": 9, "complet": 9, "task": [10, 12, 13, 14, 16, 21, 24], "multilan": 10, "popul": [10, 21], "reward": [10, 12, 13, 14, 17, 21, 22, 23, 24, 26], "lanes_count": [10, 24], "vehicles_count": [10, 12, 22, 23, 24], "50": [10, 18, 24], "initial_spac": 10, "collision_reward": [10, 12, 15, 24], "receiv": 10, "collid": [10, 23], "reward_speed_rang": [10, 24], "linearli": 10, "highwayenv": 10, "high_speed_reward": [10, 24], "simulation_frequ": [10, 13, 14, 15, 16, 18, 24], "hz": [10, 13, 16, 17], "policy_frequ": [10, 13, 14, 15, 16, 23, 24], "other_vehicles_typ": [10, 13, 16, 24], "screen_width": [10, 12, 13, 14, 15, 16, 18, 24], "600": [10, 12, 13, 14, 15, 16, 24], "px": [10, 13, 16, 18], "screen_height": [10, 12, 13, 14, 15, 16, 18, 24], "150": [10, 13, 24], "centering_posit": [10, 12, 13, 14, 15, 16, 18, 23, 24], "scale": [10, 12, 13, 14, 15, 16, 18, 23, 24, 25], "show_trajectori": [10, 13, 14, 15, 16, 24], "render_ag": [10, 13, 14, 15, 16, 24], "offscreen_rend": [10, 13, 14, 15, 16, 24], "specif": [10, 12, 13, 14, 15, 16, 18, 23], "default_config": [10, 12, 13, 14, 15, 16, 21], "overload": [10, 12, 13, 14, 15, 16, 21, 25], "x15": 10, "speedup": 10, "fast": [10, 16, 24], "detail": [10, 19], "here": [10, 17, 21, 22, 23, 24], "render_mod": [10, 12, 13, 14, 15, 16, 21, 22, 23, 24], "stai": [10, 23], "rightmost": 10, "merg": [11, 24], "roundabout": [11, 18, 24], "park": [11, 23, 24, 25], "racetrack": [11, 24], "negoti": [12, 13], "quit": 12, "hard": 12, "up": [12, 26], "good": 12, "decentr": 12, "Of": 12, "cours": 12, "could": [12, 22, 25], "achiev": [12, 14, 21], "sophist": 12, "schedul": 12, "light": 12, "keep": [12, 25], "thing": 12, "rudimentari": 12, "wa": [12, 14, 18], "ad": [12, 21], "sometim": 12, "fail": 12, "result": [12, 24], "block": 12, "figur": [12, 22, 23, 24], "fine": 12, "my": [12, 24], "purpos": [12, 19], "sinc": [12, 22, 23, 25], "did": [12, 21], "happen": 12, "too": 12, "often": [12, 25], "expect": [12, 23, 25], "simpli": 12, "wait": 12, "episod": [12, 17, 21, 22, 24, 25], "situat": 12, "But": 12, "agre": 12, "ideal": 12, "welcom": [12, 21], "ani": [12, 14, 21, 23, 25], "contribut": [12, 19], "matter": 12, "presenc": [12, 15], "vx": [12, 14, 23], "vy": [12, 14, 23], "cos_h": [12, 14, 23], "sin_h": [12, 14, 23], "features_rang": [12, 23], "100": [12, 14, 23], "absolut": [12, 23], "flatten": 12, "observe_intent": [12, 23], "13": [12, 23], "o1": 12, "initial_vehicle_count": 12, "spawn_prob": 12, "intersectionenv": [12, 22], "normalize_reward": [12, 24], "intersection_env": 12, "termin": [12, 21, 25], "truncat": [12, 16, 17, 21, 22, 23, 24], "info": [12, 14, 17, 21, 22, 23, 24], "soon": 13, "approach": [13, 16, 23], "junction": 13, "incom": 13, "ramp": 13, "room": 13, "timetocollis": [13, 16, 23], "mergeenv": 13, "merge_env": 13, "goal": [14, 24, 26], "condit": [14, 24], "continu": [14, 15, 18, 26], "appropri": [14, 25], "kinematicsgo": 14, "normal": [14, 23, 25], "300": [14, 15], "7": [14, 15], "parkingenv": 14, "parking_env": 14, "credit": [14, 15], "munir": 14, "jojo": 14, "verg": 14, "idea": [14, 15], "define_spac": [14, 21], "compute_reward": 14, "achieved_go": 14, "desired_go": 14, "proxim": 14, "we": [14, 17, 18, 20, 21, 23, 25], "norm": [14, 25], "lp": 14, "kurtosi": 14, "he": 15, "mani": [15, 18], "thank": [15, 18], "supperted825": 15, "occupancygrid": [15, 23], "on_road": 15, "grid_siz": [15, 23], "18": [15, 23], "grid_step": [15, 23], "as_imag": [15, 23], "align_to_vehicle_ax": [15, 23], "lane_centering_cost": 15, "action_reward": 15, "other_vehicl": 15, "racetrackenv": 15, "racetrack_env": 15, "need": [15, 17], "skill": 15, "see": [15, 17, 21, 22, 23, 24, 25], "http": [15, 18, 19, 20], "github": [15, 19, 20], "com": [15, 18, 19, 20], "eleur": [15, 19, 20, 22, 24], "issu": 15, "231": 15, "flow": 16, "pass": [16, 22, 23], "possibl": [16, 17, 25], "incoming_vehicle_destin": 16, "11": 16, "run": [16, 17, 21, 22, 24], "still": [16, 21], "hasn": 16, "express": 16, "variabl": 16, "equal": 16, "pygam": [16, 18, 20], "window": [16, 18], "height": 16, "smaller": 16, "southeast": 16, "area": [16, 18], "roundaboutenv": 16, "roundabout_env": 16, "feel": 17, "free": 17, "entri": 17, "probabl": 17, "you": [17, 19, 21, 23], "instal": [17, 18, 21], "instead": [17, 25], "work": 17, "repositori": [17, 19], "code": [17, 22], "regist": [17, 26], "register_highway_env": [17, 21], "tend": 17, "sub": 17, "pair": [17, 21, 23], "argu": 17, "inde": 17, "revisit": 17, "scene": [17, 23, 26], "reus": 17, "past": 17, "struggl": 17, "address": [17, 25], "permut": 17, "invari": [17, 25], "architectur": [17, 24], "sensit": 17, "exampl": [17, 21, 22], "dqn": [17, 22, 23, 24], "sb3": [17, 24], "ppo": 17, "grayscal": [17, 26], "imag": [17, 18, 21, 24, 26], "cnn": [17, 24], "suitabl": 17, "singl": [17, 21, 22, 25], "typic": 17, "long": 17, "render": [17, 18, 21, 22, 23, 24], "intermedi": [17, 21], "wrap": [17, 21, 26], "recordvideo": [17, 21], "wrapper": [17, 21], "video_fold": 17, "episode_trigg": 17, "lambda": 17, "send": [17, 22], "unwrap": 17, "set_record_video_wrapp": 17, "ob": [17, 21, 22, 23, 24], "Its": 18, "dimens": 18, "640": 18, "480": 18, "roadsurfac": 18, "locat": [18, 23], "zoom": 18, "By": 18, "offset": [18, 23], "roadgraph": 18, "vehiclegraph": 18, "envview": 18, "viewer": [18, 21], "set_agent_displai": 18, "agent_displai": 18, "callback": 18, "dedic": 18, "set_agent_action_sequ": 18, "handle_ev": 18, "event": 18, "get_imag": 18, "rgb": [18, 23], "channel": [18, 23], "convent": [18, 25], "h": [18, 23], "window_posit": 18, "worldsurfac": 18, "size": [18, 22, 23, 24], "flag": 18, "surf": 18, "pix": 18, "pixel": 18, "pos2pix": 18, "vec2pix": 18, "vec": 18, "is_vis": 18, "visibl": 18, "param": [18, 23], "test": [18, 24], "move_display_window_to": 18, "origin": 18, "lanegraph": 18, "visual": 18, "stripe_spac": 18, "33": 18, "stripe": 18, "stripe_length": 18, "stripe_width": 18, "striped_lin": 18, "stripes_count": 18, "draw": 18, "continuous_curv": 18, "continuous_lin": 18, "would": [18, 23, 25], "drawn": 18, "draw_strip": 18, "display_traff": 18, "offscreen": 18, "without": 18, "screen": 18, "display_road_object": 18, "roadobjectgraph": 18, "object_": 18, "transpar": 18, "color": 18, "rotat": 18, "rectangl": [18, 23], "slightli": 18, "blit_rot": 18, "po": 18, "origin_po": 18, "show_rect": 18, "stackoverflow": 18, "54714144": 18, "gather": 19, "quick": [19, 24], "guid": 19, "custom": 19, "nut": 19, "bolt": 19, "packag": 19, "pleas": 19, "piec": 19, "bibtex": 19, "misc": 19, "author": 19, "titl": [19, 22], "year": 19, "2018": 19, "publish": 19, "journal": 19, "howpublish": 19, "url": 19, "python3": 20, "graphic": [20, 26], "itself": 20, "manual": [20, 21, 26], "sudo": 20, "apt": 20, "python": [20, 21, 22], "dev": 20, "libsdl": 20, "image1": 20, "mixer1": 20, "ttf2": 20, "libsdl1": 20, "libsmpeg": 20, "numpi": 20, "subvers": 20, "libportmidi": 20, "ffmpeg": 20, "libswscal": 20, "libavformat": 20, "libavcodec": 20, "libfreetype6": 20, "gcc": 20, "recommend": 20, "anaconda": 20, "To": [20, 21, 22], "latest": 20, "pip": 20, "user": 20, "git": 20, "pull": 21, "request": 21, "your_env": 21, "py": [21, 22], "yourenv": 21, "inherit": 21, "function": [21, 24, 25], "choic": [21, 25], "_make_road": 21, "self": [21, 22], "field": [21, 22, 23], "action_typ": [21, 23, 24], "freeli": 21, "part": [21, 23], "config_kei": 21, "onc": 21, "other_valu": 21, "__init__": 21, "entry_point": 21, "registr": 21, "hook": 21, "reinstal": 21, "setup": 21, "altern": 21, "That": 21, "themselv": 21, "variou": 21, "involv": 21, "perception_dist": 21, "200": [21, 24], "present": 21, "_reward": [21, 25], "associ": 21, "multi": [21, 26], "vector": 21, "aggreg": 21, "scalar": 21, "insid": [21, 25], "reward_nam": 21, "reward_valu": 21, "_is_termin": 21, "check": [21, 23], "_is_trunc": 21, "_info": 21, "addit": 21, "seed": [21, 22, 24], "prng": 21, "_reset": 21, "_simul": 21, "Will": 21, "_automatic_rend": 21, "ongo": 21, "whole": 21, "video": [21, 22, 24], "been": [21, 22, 25], "captur": 21, "simplifi": 21, "distant": 21, "remov": 21, "meant": 21, "load": [21, 24], "preserv": 21, "optim": [21, 25], "change_vehicl": 21, "vehicle_class_path": 21, "path": [21, 22], "multiagentwrapp": 21, "obstyp": 21, "acttyp": 21, "modular": 21, "transform": 21, "overwritten": 21, "version": 22, "rgb_arrai": [22, 23, 24], "sake": 22, "visualis": 22, "matplotlib": [22, 23, 24], "pyplot": [22, 23, 24], "plt": [22, 23, 24], "inlin": [22, 23, 24], "imshow": [22, 23, 24], "green": 22, "show": [22, 23, 24], "640x480": [22, 23, 24], "ax": [22, 23, 24], "accept": 22, "standard": 22, "ax1": 22, "ax2": 22, "subplot": [22, 23], "nrow": 22, "set_titl": 22, "action_1": 22, "action_2": 22, "what": [22, 23], "As": 22, "far": 22, "multiagentobserv": 22, "observation_config": 22, "pprint": [22, 24], "90797305": 22, "3125": 22, "10906096": 22, "04341291": 22, "33000726": 22, "dtype": 22, "float32": 22, "pseudo": 22, "train": 22, "dummi": 22, "rl": [22, 24], "algorithm": 22, "transit": 22, "def": 22, "next_ob": 22, "dispatch": 22, "obs_i": 22, "action_i": 22, "next_obs_i": 22, "zip": 22, "cd": 22, "script": [22, 24], "evalu": 22, "env_multi_ag": 22, "dqnagent": 22, "ego_attention_2h": 22, "3000": 22, "27": 23, "observation_factori": 23, "kinematicobserv": 23, "f": 23, "v_y": [23, 25], "12": 23, "22": 23, "row": 23, "within": 23, "05": 23, "04": 23, "75": 23, "08": 23, "675": 23, "222": 23, "105": 23, "9": 23, "025": 23, "rel": 23, "except": 23, "075": 23, "172": 23, "065": 23, "fewer": 23, "placehold": 23, "fill": 23, "zero": 23, "detect": 23, "disambigu": 23, "radian": 23, "trigonometr": 23, "cos_d": 23, "sin_d": 23, "long_": 23, "off": 23, "lat_": 23, "ang_": 23, "angular": 23, "sort": 23, "print": 23, "20323725": 23, "07361443": 23, "39618185": 23, "11105874": 23, "6169058": 23, "17033932": 23, "83093834": 23, "0526074": 23, "18704522": 23, "1492452": 23, "05019206": 23, "07072275": 23, "18716832": 23, "grayscaleobserv": 23, "observation_shap": 23, "sum": 23, "stack_siz": 23, "customari": 23, "128": 23, "64": 23, "2989": 23, "5870": 23, "1140": 23, "fig": 23, "ncol": 23, "figsiz": 23, "enumer": 23, "flat": 23, "cmap": 23, "get_cmap": 23, "grai": 23, "1200x500": 23, "three": 23, "actions_index": [23, 24], "occupancygridobserv": 23, "shape": 23, "discretis": 23, "cell": 23, "resolut": 23, "like": 23, "timetocollisionobserv": 23, "hot": 23, "encod": 23, "over": 23, "bin": 23, "25m": 23, "infti": 23, "middl": 23, "bottom": 23, "horizon": 23, "lidarobserv": 23, "divid": 23, "sector": 23, "per": 23, "column": 23, "nearest": 23, "compon": 23, "south": 23, "west": 23, "meter": 23, "awai": 23, "toward": 23, "1m": 23, "maximum_rang": 23, "84": 23, "see_behind": 23, "include_obstacl": 23, "min": [23, 25], "max": [23, 25], "shuffl": 23, "normalize_ob": 23, "df": 23, "datafram": 23, "real": 23, "min_x": 23, "max_x": 23, "min_i": 23, "max_i": 23, "step_x": 23, "step_i": 23, "align": 23, "pos_to_index": 23, "otherwis": 23, "alreadi": 23, "fill_road_layer_by_lan": 23, "layer_index": 23, "lane_perception_dist": 23, "onroad": 23, "offroad": 23, "iter": 23, "regularli": 23, "waypoint": 23, "larg": 23, "small": 23, "fill_road_layer_by_cel": 23, "kinematicsgoalobserv": 23, "exitobserv": 23, "exit_env": 23, "exit": 23, "creation": 24, "ego_spac": 24, "initial_lane_id": 24, "lane_change_reward": 24, "offroad_termin": 24, "real_time_rend": 24, "right_lane_reward": 24, "vehicles_dens": 24, "effect": 24, "librari": 24, "openai": 24, "baselin": 24, "stabl": 24, "baselines3": 24, "mlp": 24, "stable_baselines3": 24, "mlppolici": 24, "policy_kwarg": 24, "net_arch": 24, "256": 24, "learning_r": 24, "5e": 24, "buffer_s": 24, "15000": 24, "learning_start": 24, "batch_siz": 24, "32": 24, "gamma": 24, "train_freq": 24, "gradient_step": 24, "target_update_interv": 24, "verbos": 24, "tensorboard_log": 24, "highway_dqn": 24, "2e4": 24, "_state": 24, "25mn": 24, "laptop": 24, "fp": 24, "14": 24, "better": 24, "vanilla": 24, "q": 24, "extens": 24, "doubl": 24, "duel": 24, "priorit": 24, "improv": 24, "faq": 24, "notebook": 24, "few": 24, "opd": 24, "tutori": 24, "written": 24, "rlss": 24, "demonstr": 24, "principl": 24, "her": 24, "cross": 24, "challeng": 25, "problem": 25, "particular": 25, "wish": 25, "aspect": 25, "straightforward": 25, "adequ": 25, "emerg": 25, "perspect": 25, "robust": 25, "against": 25, "uncertain": 25, "focu": 25, "progress": 25, "quickli": 25, "bound": 25, "shift": 25, "practic": 25, "benefici": 25, "forbid": 25, "neg": 25, "encourag": 25, "prefer": 25, "earli": 25, "caus": 25, "risk": 25, "suffer": 25, "satisfi": 25, "penalti": 25, "collision_penalti": 25, "replac": 25, "s_g": 25, "v_x": 25, "x_g": 25, "y_g": 25, "psi_g": 25, "sum_i": 25, "w_i": 25, "x_i": 25, "euclidean": 25, "narrow": 25, "spike": 25, "occup": 26, "grid": 26, "lidar": 26, "api": 26, "meta": 26, "your": 26, "file": 26, "profit": 26}, "objects": {"highway_env": [[21, 0, 0, "-", "__init__"]], "highway_env.__init__": [[21, 1, 1, "", "register_highway_envs"]], "highway_env.envs.common": [[21, 0, 0, "-", "abstract"], [1, 0, 0, "-", "action"], [18, 0, 0, "-", "graphics"], [23, 0, 0, "-", "observation"]], "highway_env.envs.common.abstract": [[21, 2, 1, "", "AbstractEnv"], [21, 2, 1, "", "MultiAgentWrapper"]], "highway_env.envs.common.abstract.AbstractEnv": [[21, 3, 1, "", "PERCEPTION_DISTANCE"], [21, 4, 1, "", "_automatic_rendering"], [21, 4, 1, "", "_info"], [21, 4, 1, "", "_is_terminated"], [21, 4, 1, "", "_is_truncated"], [21, 4, 1, "", "_reset"], [21, 4, 1, "", "_reward"], [21, 4, 1, "", "_rewards"], [21, 4, 1, "", "_simulate"], [21, 4, 1, "", "change_vehicles"], [21, 4, 1, "", "close"], [21, 4, 1, "", "default_config"], [21, 4, 1, "", "define_spaces"], [21, 4, 1, "", "render"], [21, 4, 1, "", "reset"], [21, 4, 1, "", "simplify"], [21, 4, 1, "", "step"], [21, 5, 1, "", "vehicle"]], "highway_env.envs.common.abstract.MultiAgentWrapper": [[21, 4, 1, "", "step"]], "highway_env.envs.common.action": [[1, 2, 1, "", "ActionType"], [1, 2, 1, "", "ContinuousAction"], [1, 2, 1, "", "DiscreteAction"], [1, 2, 1, "", "DiscreteMetaAction"], [1, 2, 1, "", "MultiAgentAction"]], "highway_env.envs.common.action.ActionType": [[1, 4, 1, "", "act"], [1, 5, 1, "", "controlled_vehicle"], [1, 4, 1, "", "get_available_actions"], [1, 4, 1, "", "space"], [1, 5, 1, "", "vehicle_class"]], "highway_env.envs.common.action.ContinuousAction": [[1, 3, 1, "", "ACCELERATION_RANGE"], [1, 3, 1, "", "STEERING_RANGE"], [1, 4, 1, "", "act"], [1, 4, 1, "", "space"], [1, 5, 1, "", "vehicle_class"]], "highway_env.envs.common.action.DiscreteAction": [[1, 4, 1, "", "act"], [1, 4, 1, "", "space"]], "highway_env.envs.common.action.DiscreteMetaAction": [[1, 3, 1, "", "ACTIONS_ALL"], [1, 3, 1, "", "ACTIONS_LAT"], [1, 3, 1, "", "ACTIONS_LONGI"], [1, 4, 1, "", "act"], [1, 4, 1, "", "get_available_actions"], [1, 4, 1, "", "space"], [1, 5, 1, "", "vehicle_class"]], "highway_env.envs.common.action.MultiAgentAction": [[1, 4, 1, "", "act"], [1, 4, 1, "", "get_available_actions"], [1, 4, 1, "", "space"], [1, 5, 1, "", "vehicle_class"]], "highway_env.envs.common.graphics": [[18, 2, 1, "", "EnvViewer"]], "highway_env.envs.common.graphics.EnvViewer": [[18, 4, 1, "", "close"], [18, 4, 1, "", "display"], [18, 4, 1, "", "get_image"], [18, 4, 1, "", "handle_events"], [18, 4, 1, "", "set_agent_action_sequence"], [18, 4, 1, "", "set_agent_display"], [18, 4, 1, "", "window_position"]], "highway_env.envs.common.observation": [[23, 2, 1, "", "ExitObservation"], [23, 2, 1, "", "GrayscaleObservation"], [23, 2, 1, "", "KinematicObservation"], [23, 2, 1, "", "KinematicsGoalObservation"], [23, 2, 1, "", "OccupancyGridObservation"]], "highway_env.envs.common.observation.ExitObservation": [[23, 4, 1, "", "observe"]], "highway_env.envs.common.observation.GrayscaleObservation": [[23, 4, 1, "", "observe"], [23, 4, 1, "", "space"]], "highway_env.envs.common.observation.KinematicObservation": [[23, 4, 1, "", "normalize_obs"], [23, 4, 1, "", "observe"], [23, 4, 1, "", "space"]], "highway_env.envs.common.observation.KinematicsGoalObservation": [[23, 4, 1, "", "observe"], [23, 4, 1, "", "space"]], "highway_env.envs.common.observation.OccupancyGridObservation": [[23, 4, 1, "", "fill_road_layer_by_cell"], [23, 4, 1, "", "fill_road_layer_by_lanes"], [23, 4, 1, "", "normalize"], [23, 4, 1, "", "observe"], [23, 4, 1, "", "pos_to_index"], [23, 4, 1, "", "space"]], "highway_env.envs.highway_env": [[10, 2, 1, "", "HighwayEnv"]], "highway_env.envs.highway_env.HighwayEnv": [[10, 4, 1, "", "default_config"]], "highway_env.envs.intersection_env": [[12, 2, 1, "", "IntersectionEnv"]], "highway_env.envs.intersection_env.IntersectionEnv": [[12, 4, 1, "", "default_config"], [12, 4, 1, "", "step"]], "highway_env.envs.merge_env": [[13, 2, 1, "", "MergeEnv"]], "highway_env.envs.merge_env.MergeEnv": [[13, 4, 1, "", "default_config"]], "highway_env.envs.parking_env": [[14, 2, 1, "", "ParkingEnv"]], "highway_env.envs.parking_env.ParkingEnv": [[14, 4, 1, "", "compute_reward"], [14, 4, 1, "", "default_config"], [14, 4, 1, "", "define_spaces"]], "highway_env.envs.racetrack_env": [[15, 2, 1, "", "RacetrackEnv"]], "highway_env.envs.racetrack_env.RacetrackEnv": [[15, 4, 1, "", "default_config"]], "highway_env.envs.roundabout_env": [[16, 2, 1, "", "RoundaboutEnv"]], "highway_env.envs.roundabout_env.RoundaboutEnv": [[16, 4, 1, "", "default_config"]], "highway_env.road": [[18, 0, 0, "-", "graphics"], [4, 0, 0, "-", "lane"], [5, 0, 0, "-", "regulation"], [6, 0, 0, "-", "road"]], "highway_env.road.graphics": [[18, 2, 1, "", "LaneGraphics"], [18, 2, 1, "", "RoadGraphics"], [18, 2, 1, "", "RoadObjectGraphics"], [18, 2, 1, "", "WorldSurface"]], "highway_env.road.graphics.LaneGraphics": [[18, 3, 1, "", "STRIPE_LENGTH"], [18, 3, 1, "", "STRIPE_SPACING"], [18, 3, 1, "", "STRIPE_WIDTH"], [18, 4, 1, "", "continuous_curve"], [18, 4, 1, "", "continuous_line"], [18, 4, 1, "", "display"], [18, 4, 1, "", "draw_stripes"], [18, 4, 1, "", "striped_line"]], "highway_env.road.graphics.RoadGraphics": [[18, 4, 1, "", "display"], [18, 4, 1, "", "display_road_objects"], [18, 4, 1, "", "display_traffic"]], "highway_env.road.graphics.RoadObjectGraphics": [[18, 4, 1, "", "blit_rotate"], [18, 4, 1, "", "display"]], "highway_env.road.graphics.WorldSurface": [[18, 4, 1, "", "handle_event"], [18, 4, 1, "", "is_visible"], [18, 4, 1, "", "move_display_window_to"], [18, 4, 1, "", "pix"], [18, 4, 1, "", "pos2pix"], [18, 4, 1, "", "vec2pix"]], "highway_env.road.lane": [[4, 2, 1, "", "AbstractLane"], [4, 2, 1, "", "CircularLane"], [4, 2, 1, "", "LineType"], [4, 2, 1, "", "PolyLane"], [4, 2, 1, "", "PolyLaneFixedWidth"], [4, 2, 1, "", "SineLane"], [4, 2, 1, "", "StraightLane"]], "highway_env.road.lane.AbstractLane": [[4, 4, 1, "", "distance"], [4, 4, 1, "", "distance_with_heading"], [4, 4, 1, "", "from_config"], [4, 4, 1, "", "heading_at"], [4, 4, 1, "", "is_reachable_from"], [4, 4, 1, "", "local_angle"], [4, 4, 1, "", "local_coordinates"], [4, 3, 1, "", "metaclass__"], [4, 4, 1, "", "on_lane"], [4, 4, 1, "", "position"], [4, 4, 1, "", "to_config"], [4, 4, 1, "", "width_at"]], "highway_env.road.lane.CircularLane": [[4, 4, 1, "", "from_config"], [4, 4, 1, "", "heading_at"], [4, 4, 1, "", "local_coordinates"], [4, 4, 1, "", "position"], [4, 4, 1, "", "to_config"], [4, 4, 1, "", "width_at"]], "highway_env.road.lane.PolyLane": [[4, 4, 1, "", "to_config"], [4, 4, 1, "", "width_at"]], "highway_env.road.lane.PolyLaneFixedWidth": [[4, 4, 1, "", "from_config"], [4, 4, 1, "", "heading_at"], [4, 4, 1, "", "local_coordinates"], [4, 4, 1, "", "position"], [4, 4, 1, "", "to_config"], [4, 4, 1, "", "width_at"]], "highway_env.road.lane.SineLane": [[4, 4, 1, "", "from_config"], [4, 4, 1, "", "heading_at"], [4, 4, 1, "", "local_coordinates"], [4, 4, 1, "", "position"], [4, 4, 1, "", "to_config"]], "highway_env.road.lane.StraightLane": [[4, 4, 1, "", "from_config"], [4, 4, 1, "", "heading_at"], [4, 4, 1, "", "local_coordinates"], [4, 4, 1, "", "position"], [4, 4, 1, "", "to_config"], [4, 4, 1, "", "width_at"]], "highway_env.road.regulation": [[5, 2, 1, "", "RegulatedRoad"]], "highway_env.road.regulation.RegulatedRoad": [[5, 4, 1, "", "enforce_road_rules"], [5, 4, 1, "", "respect_priorities"], [5, 4, 1, "", "step"]], "highway_env.road.road": [[6, 2, 1, "", "Road"]], "highway_env.road.road.Road": [[6, 4, 1, "", "act"], [6, 4, 1, "", "neighbour_vehicles"], [6, 4, 1, "", "step"]], "highway_env.vehicle": [[7, 0, 0, "-", "behavior"], [8, 0, 0, "-", "controller"], [18, 0, 0, "-", "graphics"], [9, 0, 0, "-", "kinematics"]], "highway_env.vehicle.behavior": [[7, 2, 1, "", "AggressiveVehicle"], [7, 2, 1, "", "DefensiveVehicle"], [7, 2, 1, "", "IDMVehicle"], [7, 2, 1, "", "LinearVehicle"]], "highway_env.vehicle.behavior.AggressiveVehicle": [[7, 3, 1, "", "target_speed"]], "highway_env.vehicle.behavior.DefensiveVehicle": [[7, 3, 1, "", "target_speed"]], "highway_env.vehicle.behavior.IDMVehicle": [[7, 3, 1, "", "ACC_MAX"], [7, 3, 1, "", "COMFORT_ACC_MAX"], [7, 3, 1, "", "COMFORT_ACC_MIN"], [7, 3, 1, "", "DELTA"], [7, 3, 1, "", "DELTA_RANGE"], [7, 3, 1, "", "DISTANCE_WANTED"], [7, 3, 1, "", "TIME_WANTED"], [7, 4, 1, "", "acceleration"], [7, 4, 1, "", "act"], [7, 4, 1, "", "change_lane_policy"], [7, 4, 1, "", "create_from"], [7, 4, 1, "", "desired_gap"], [7, 4, 1, "", "mobil"], [7, 4, 1, "", "recover_from_stop"], [7, 4, 1, "", "step"], [7, 3, 1, "", "target_speed"]], "highway_env.vehicle.behavior.LinearVehicle": [[7, 3, 1, "", "TIME_WANTED"], [7, 4, 1, "", "acceleration"], [7, 4, 1, "", "act"], [7, 4, 1, "", "collect_data"], [7, 4, 1, "", "steering_control"], [7, 4, 1, "", "steering_features"], [7, 3, 1, "", "target_speed"]], "highway_env.vehicle.controller": [[8, 2, 1, "", "ControlledVehicle"], [8, 2, 1, "", "MDPVehicle"]], "highway_env.vehicle.controller.ControlledVehicle": [[8, 4, 1, "", "act"], [8, 4, 1, "", "create_from"], [8, 4, 1, "", "follow_road"], [8, 4, 1, "", "get_routes_at_intersection"], [8, 4, 1, "", "plan_route_to"], [8, 4, 1, "", "predict_trajectory_constant_speed"], [8, 4, 1, "", "set_route_at_intersection"], [8, 4, 1, "", "speed_control"], [8, 4, 1, "", "steering_control"], [8, 3, 1, "", "target_speed"]], "highway_env.vehicle.controller.MDPVehicle": [[8, 4, 1, "", "act"], [8, 4, 1, "", "index_to_speed"], [8, 4, 1, "", "predict_trajectory"], [8, 4, 1, "", "speed_to_index"], [8, 4, 1, "", "speed_to_index_default"], [8, 3, 1, "", "target_speed"]], "highway_env.vehicle.kinematics": [[9, 2, 1, "", "Vehicle"]], "highway_env.vehicle.kinematics.Vehicle": [[9, 3, 1, "", "DEFAULT_INITIAL_SPEEDS"], [9, 3, 1, "", "HISTORY_SIZE"], [9, 3, 1, "", "LENGTH"], [9, 3, 1, "", "MAX_SPEED"], [9, 3, 1, "", "MIN_SPEED"], [9, 3, 1, "", "WIDTH"], [9, 4, 1, "", "act"], [9, 4, 1, "", "create_from"], [9, 4, 1, "", "create_random"], [9, 4, 1, "", "predict_trajectory"], [9, 4, 1, "", "step"]]}, "objtypes": {"0": "py:module", "1": "py:function", "2": "py:class", "3": "py:attribute", "4": "py:method", "5": "py:property"}, "objnames": {"0": ["py", "module", "Python module"], "1": ["py", "function", "Python function"], "2": ["py", "class", "Python class"], "3": ["py", "attribute", "Python attribute"], "4": ["py", "method", "Python method"], "5": ["py", "property", "Python property"]}, "titleterms": {"404": 0, "page": 0, "Not": 0, "found": 0, "action": [1, 22], "continu": 1, "discret": 1, "meta": 1, "manual": 1, "control": [1, 8, 22], "api": [1, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16, 18, 21, 23], "bibliographi": 2, "dynam": 3, "road": [3, 5, 6], "vehicl": [3, 21, 22, 23], "lane": 4, "regul": 5, "behavior": 7, "longitudin": [7, 8], "later": [7, 8], "posit": 8, "head": 8, "kinemat": [9, 17, 23], "highwai": [10, 17, 19], "usag": [10, 12, 13, 14, 15, 16], "default": [10, 12, 13, 14, 15, 16], "configur": [10, 12, 13, 14, 15, 16, 21, 23, 24], "faster": 10, "variant": 10, "The": [11, 22], "environ": [11, 17, 21, 24, 25], "intersect": 12, "merg": 13, "park": 14, "racetrack": 15, "roundabout": 16, "frequent": 17, "ask": 17, "question": 17, "when": 17, "i": [17, 23], "try": 17, "make": [17, 21, 24], "an": [17, 24], "get": [17, 24], "error": 17, "gymnasium": 17, "namenotfound": 17, "doesn": 17, "t": 17, "exist": 17, "train": [17, 24], "agent": [17, 22, 24], "us": 17, "observ": [17, 22, 23], "mlp": 17, "model": 17, "result": 17, "polici": 17, "optim": 17, "why": 17, "my": 17, "video": 17, "ar": 17, "too": 17, "fast": 17, "have": 17, "low": 17, "framer": 17, "graphic": 18, "world": 18, "surfac": 18, "scene": [18, 21], "welcom": 19, "env": 19, "": 19, "document": 19, "how": 19, "cite": 19, "thi": 19, "work": 19, "instal": 20, "prerequisit": 20, "ubuntu": 20, "window": 20, "10": 20, "stabl": 20, "releas": 20, "develop": 20, "version": 20, "your": 21, "own": 21, "set": [21, 22], "up": [21, 22], "file": 21, "creat": 21, "regist": 21, "profit": 21, "multi": 22, "increas": 22, "number": 22, "chang": 22, "space": 22, "wrap": 22, "exampl": [23, 24], "grayscal": 23, "imag": 23, "illustr": 23, "stack": 23, "mechan": 23, "occup": 23, "grid": 23, "presenc": 23, "featur": 23, "one": 23, "close": 23, "north": 23, "farther": 23, "east": 23, "v_x": 23, "drive": 23, "same": 23, "speed": 23, "ego": 23, "bit": 23, "slower": 23, "time": 23, "collis": 23, "lidar": 23, "start": 24, "all": 24, "googl": 24, "colab": 24, "reward": 25, "most": 25, "goal": 25, "user": 26, "guid": 26}, "envversion": {"sphinx.domains.c": 3, "sphinx.domains.changeset": 1, "sphinx.domains.citation": 1, "sphinx.domains.cpp": 9, "sphinx.domains.index": 1, "sphinx.domains.javascript": 3, "sphinx.domains.math": 2, "sphinx.domains.python": 4, "sphinx.domains.rst": 2, "sphinx.domains.std": 2, "sphinx.ext.viewcode": 1, "sphinxcontrib.bibtex": 9, "sphinx": 60}, "alltitles": {"404": [[0, "id1"]], "Page Not Found": [[0, "page-not-found"]], "Actions": [[1, "actions"]], "Continuous Actions": [[1, "continuous-actions"]], "Discrete Actions": [[1, "discrete-actions"]], "Discrete Meta-Actions": [[1, "discrete-meta-actions"]], "Manual control": [[1, "manual-control"]], "API": [[1, "module-highway_env.envs.common.action"], [4, "module-highway_env.road.lane"], [5, "module-highway_env.road.regulation"], [6, "module-highway_env.road.road"], [7, "module-highway_env.vehicle.behavior"], [8, "module-highway_env.vehicle.controller"], [9, "module-highway_env.vehicle.kinematics"], [10, "api"], [12, "api"], [13, "api"], [14, "api"], [15, "api"], [16, "api"], [18, "module-highway_env.envs.common.graphics"], [21, "module-highway_env.__init__"], [23, "module-highway_env.envs.common.observation"]], "Bibliography": [[2, "bibliography"]], "Dynamics": [[3, "dynamics"]], "Roads": [[3, "roads"]], "Vehicles": [[3, "vehicles"]], "Lane": [[4, "lane"]], "Road regulation": [[5, "road-regulation"]], "Road": [[6, "road"]], "Behavior": [[7, "behavior"]], "Longitudinal Behavior": [[7, "longitudinal-behavior"]], "Lateral Behavior": [[7, "lateral-behavior"]], "Control": [[8, "control"]], "Longitudinal controller": [[8, "longitudinal-controller"]], "Lateral controller": [[8, "lateral-controller"]], "Position control": [[8, "position-control"]], "Heading control": [[8, "heading-control"]], "Kinematics": [[9, "kinematics"], [23, "kinematics"]], "Highway": [[10, "highway"]], "Usage": [[10, "usage"], [12, "usage"], [13, "usage"], [14, "usage"], [15, "usage"], [16, "usage"]], "Default configuration": [[10, "default-configuration"], [12, "default-configuration"], [13, "default-configuration"], [14, "default-configuration"], [15, "default-configuration"], [16, "default-configuration"]], "Faster variant": [[10, "faster-variant"]], "The environments": [[11, "the-environments"]], "Intersection": [[12, "intersection"]], "Merge": [[13, "merge"]], "Parking": [[14, "parking"]], "Racetrack": [[15, "racetrack"]], "Roundabout": [[16, "roundabout"]], "Frequently Asked Questions": [[17, "frequently-asked-questions"]], "When I try to make an environment, I get an error gymnasium.error.NameNotFound: Environment highway doesn't exist.": [[17, "when-i-try-to-make-an-environment-i-get-an-error-gymnasium-error-namenotfound-environment-highway-doesn-t-exist"]], "I try to train an agent using the Kinematics Observation and an MLP model, but the resulting policy is not optimal. Why?": [[17, "i-try-to-train-an-agent-using-the-kinematics-observation-and-an-mlp-model-but-the-resulting-policy-is-not-optimal-why"]], "My videos are too fast / have a low framerate.": [[17, "my-videos-are-too-fast-have-a-low-framerate"]], "Graphics": [[18, "id1"]], "World surface": [[18, "world-surface"]], "Scene graphics": [[18, "scene-graphics"]], "Welcome to highway-env\u2019s documentation!": [[19, "welcome-to-highway-env-s-documentation"]], "How to cite this work?": [[19, "how-to-cite-this-work"]], "Installation": [[20, "installation"]], "Prerequisites": [[20, "prerequisites"]], "Ubuntu": [[20, "ubuntu"]], "Windows 10": [[20, "windows-10"]], "Stable release": [[20, "stable-release"]], "Development version": [[20, "development-version"]], "Make your own environment": [[21, "make-your-own-environment"]], "Set up files": [[21, "set-up-files"]], "Create the scene": [[21, "create-the-scene"]], "Create the vehicles": [[21, "create-the-vehicles"]], "Make the environment configurable": [[21, "make-the-environment-configurable"]], "Register the environment": [[21, "register-the-environment"]], "Profit": [[21, "profit"]], "The Multi-Agent setting": [[22, "the-multi-agent-setting"]], "Increase the number of controlled vehicles": [[22, "increase-the-number-of-controlled-vehicles"]], "Change the action space": [[22, "change-the-action-space"]], "Change the observation space": [[22, "change-the-observation-space"]], "Wrapping it up": [[22, "wrapping-it-up"]], "Observations": [[23, "id1"]], "Example configuration": [[23, "example-configuration"], [23, "grayscale-example-configuration"], [23, "id4"], [23, "id5"], [23, "id6"]], "Grayscale Image": [[23, "grayscale-image"]], "Illustration of the stack mechanism": [[23, "illustration-of-the-stack-mechanism"]], "Occupancy grid": [[23, "occupancy-grid"]], "presence feature: one vehicle is close to the north, and one is farther to the east.": [[23, "id7"]], "v_x feature: the north vehicle drives at the same speed as the ego-vehicle, and the east vehicle a bit slower": [[23, "id8"]], "Time to collision": [[23, "time-to-collision"]], "Lidar": [[23, "lidar"]], "the Lidar observation": [[23, "id9"]], "Getting Started": [[24, "getting-started"]], "Making an environment": [[24, "making-an-environment"]], "All the environments": [[24, "all-the-environments"]], "Configuring an environment": [[24, "configuring-an-environment"]], "Training an agent": [[24, "training-an-agent"]], "Examples on Google Colab": [[24, "examples-on-google-colab"]], "Rewards": [[25, "rewards"]], "Most environments": [[25, "most-environments"]], "Goal environments": [[25, "goal-environments"]], "User Guide": [[26, "user-guide"]]}, "indexentries": {"acceleration_range (highway_env.envs.common.action.continuousaction attribute)": [[1, "highway_env.envs.common.action.ContinuousAction.ACCELERATION_RANGE"]], "actions_all (highway_env.envs.common.action.discretemetaaction attribute)": [[1, "highway_env.envs.common.action.DiscreteMetaAction.ACTIONS_ALL"]], "actions_lat (highway_env.envs.common.action.discretemetaaction attribute)": [[1, "highway_env.envs.common.action.DiscreteMetaAction.ACTIONS_LAT"]], "actions_longi (highway_env.envs.common.action.discretemetaaction attribute)": [[1, "highway_env.envs.common.action.DiscreteMetaAction.ACTIONS_LONGI"]], "actiontype (class in highway_env.envs.common.action)": [[1, "highway_env.envs.common.action.ActionType"]], "continuousaction (class in highway_env.envs.common.action)": [[1, "highway_env.envs.common.action.ContinuousAction"]], "discreteaction (class in highway_env.envs.common.action)": [[1, "highway_env.envs.common.action.DiscreteAction"]], "discretemetaaction (class in highway_env.envs.common.action)": [[1, "highway_env.envs.common.action.DiscreteMetaAction"]], "multiagentaction (class in highway_env.envs.common.action)": [[1, "highway_env.envs.common.action.MultiAgentAction"]], "steering_range (highway_env.envs.common.action.continuousaction attribute)": [[1, "highway_env.envs.common.action.ContinuousAction.STEERING_RANGE"]], "act() (highway_env.envs.common.action.actiontype method)": [[1, "highway_env.envs.common.action.ActionType.act"]], "act() (highway_env.envs.common.action.continuousaction method)": [[1, "highway_env.envs.common.action.ContinuousAction.act"]], "act() (highway_env.envs.common.action.discreteaction method)": [[1, "highway_env.envs.common.action.DiscreteAction.act"]], "act() (highway_env.envs.common.action.discretemetaaction method)": [[1, "highway_env.envs.common.action.DiscreteMetaAction.act"]], "act() (highway_env.envs.common.action.multiagentaction method)": [[1, "highway_env.envs.common.action.MultiAgentAction.act"]], "controlled_vehicle (highway_env.envs.common.action.actiontype property)": [[1, "highway_env.envs.common.action.ActionType.controlled_vehicle"]], "get_available_actions() (highway_env.envs.common.action.actiontype method)": [[1, "highway_env.envs.common.action.ActionType.get_available_actions"]], "get_available_actions() (highway_env.envs.common.action.discretemetaaction method)": [[1, "highway_env.envs.common.action.DiscreteMetaAction.get_available_actions"]], "get_available_actions() (highway_env.envs.common.action.multiagentaction method)": [[1, "highway_env.envs.common.action.MultiAgentAction.get_available_actions"]], "highway_env.envs.common.action": [[1, "module-highway_env.envs.common.action"]], "module": [[1, "module-highway_env.envs.common.action"], [4, "module-highway_env.road.lane"], [5, "module-highway_env.road.regulation"], [6, "module-highway_env.road.road"], [7, "module-highway_env.vehicle.behavior"], [8, "module-highway_env.vehicle.controller"], [9, "module-highway_env.vehicle.kinematics"], [18, "module-highway_env.envs.common.graphics"], [18, "module-highway_env.road.graphics"], [18, "module-highway_env.vehicle.graphics"], [21, "module-highway_env.__init__"], [21, "module-highway_env.envs.common.abstract"], [23, "module-highway_env.envs.common.observation"]], "space() (highway_env.envs.common.action.actiontype method)": [[1, "highway_env.envs.common.action.ActionType.space"]], "space() (highway_env.envs.common.action.continuousaction method)": [[1, "highway_env.envs.common.action.ContinuousAction.space"]], "space() (highway_env.envs.common.action.discreteaction method)": [[1, "highway_env.envs.common.action.DiscreteAction.space"]], "space() (highway_env.envs.common.action.discretemetaaction method)": [[1, "highway_env.envs.common.action.DiscreteMetaAction.space"]], "space() (highway_env.envs.common.action.multiagentaction method)": [[1, "highway_env.envs.common.action.MultiAgentAction.space"]], "vehicle_class (highway_env.envs.common.action.actiontype property)": [[1, "highway_env.envs.common.action.ActionType.vehicle_class"]], "vehicle_class (highway_env.envs.common.action.continuousaction property)": [[1, "highway_env.envs.common.action.ContinuousAction.vehicle_class"]], "vehicle_class (highway_env.envs.common.action.discretemetaaction property)": [[1, "highway_env.envs.common.action.DiscreteMetaAction.vehicle_class"]], "vehicle_class (highway_env.envs.common.action.multiagentaction property)": [[1, "highway_env.envs.common.action.MultiAgentAction.vehicle_class"]], "abstractlane (class in highway_env.road.lane)": [[4, "highway_env.road.lane.AbstractLane"]], "circularlane (class in highway_env.road.lane)": [[4, "highway_env.road.lane.CircularLane"]], "linetype (class in highway_env.road.lane)": [[4, "highway_env.road.lane.LineType"]], "polylane (class in highway_env.road.lane)": [[4, "highway_env.road.lane.PolyLane"]], "polylanefixedwidth (class in highway_env.road.lane)": [[4, "highway_env.road.lane.PolyLaneFixedWidth"]], "sinelane (class in highway_env.road.lane)": [[4, "highway_env.road.lane.SineLane"]], "straightlane (class in highway_env.road.lane)": [[4, "highway_env.road.lane.StraightLane"]], "distance() (highway_env.road.lane.abstractlane method)": [[4, "highway_env.road.lane.AbstractLane.distance"]], "distance_with_heading() (highway_env.road.lane.abstractlane method)": [[4, "highway_env.road.lane.AbstractLane.distance_with_heading"]], "from_config() (highway_env.road.lane.abstractlane class method)": [[4, "highway_env.road.lane.AbstractLane.from_config"]], "from_config() (highway_env.road.lane.circularlane class method)": [[4, "highway_env.road.lane.CircularLane.from_config"]], "from_config() (highway_env.road.lane.polylanefixedwidth class method)": [[4, "highway_env.road.lane.PolyLaneFixedWidth.from_config"]], "from_config() (highway_env.road.lane.sinelane class method)": [[4, "highway_env.road.lane.SineLane.from_config"]], "from_config() (highway_env.road.lane.straightlane class method)": [[4, "highway_env.road.lane.StraightLane.from_config"]], "heading_at() (highway_env.road.lane.abstractlane method)": [[4, "highway_env.road.lane.AbstractLane.heading_at"]], "heading_at() (highway_env.road.lane.circularlane method)": [[4, "highway_env.road.lane.CircularLane.heading_at"]], "heading_at() (highway_env.road.lane.polylanefixedwidth method)": [[4, "highway_env.road.lane.PolyLaneFixedWidth.heading_at"]], "heading_at() (highway_env.road.lane.sinelane method)": [[4, "highway_env.road.lane.SineLane.heading_at"]], "heading_at() (highway_env.road.lane.straightlane method)": [[4, "highway_env.road.lane.StraightLane.heading_at"]], "highway_env.road.lane": [[4, "module-highway_env.road.lane"]], "is_reachable_from() (highway_env.road.lane.abstractlane method)": [[4, "highway_env.road.lane.AbstractLane.is_reachable_from"]], "local_angle() (highway_env.road.lane.abstractlane method)": [[4, "highway_env.road.lane.AbstractLane.local_angle"]], "local_coordinates() (highway_env.road.lane.abstractlane method)": [[4, "highway_env.road.lane.AbstractLane.local_coordinates"]], "local_coordinates() (highway_env.road.lane.circularlane method)": [[4, "highway_env.road.lane.CircularLane.local_coordinates"]], "local_coordinates() (highway_env.road.lane.polylanefixedwidth method)": [[4, "highway_env.road.lane.PolyLaneFixedWidth.local_coordinates"]], "local_coordinates() (highway_env.road.lane.sinelane method)": [[4, "highway_env.road.lane.SineLane.local_coordinates"]], "local_coordinates() (highway_env.road.lane.straightlane method)": [[4, "highway_env.road.lane.StraightLane.local_coordinates"]], "metaclass__ (highway_env.road.lane.abstractlane attribute)": [[4, "highway_env.road.lane.AbstractLane.metaclass__"]], "on_lane() (highway_env.road.lane.abstractlane method)": [[4, "highway_env.road.lane.AbstractLane.on_lane"]], "position() (highway_env.road.lane.abstractlane method)": [[4, "highway_env.road.lane.AbstractLane.position"]], "position() (highway_env.road.lane.circularlane method)": [[4, "highway_env.road.lane.CircularLane.position"]], "position() (highway_env.road.lane.polylanefixedwidth method)": [[4, "highway_env.road.lane.PolyLaneFixedWidth.position"]], "position() (highway_env.road.lane.sinelane method)": [[4, "highway_env.road.lane.SineLane.position"]], "position() (highway_env.road.lane.straightlane method)": [[4, "highway_env.road.lane.StraightLane.position"]], "to_config() (highway_env.road.lane.abstractlane method)": [[4, "highway_env.road.lane.AbstractLane.to_config"]], "to_config() (highway_env.road.lane.circularlane method)": [[4, "highway_env.road.lane.CircularLane.to_config"]], "to_config() (highway_env.road.lane.polylane method)": [[4, "highway_env.road.lane.PolyLane.to_config"]], "to_config() (highway_env.road.lane.polylanefixedwidth method)": [[4, "highway_env.road.lane.PolyLaneFixedWidth.to_config"]], "to_config() (highway_env.road.lane.sinelane method)": [[4, "highway_env.road.lane.SineLane.to_config"]], "to_config() (highway_env.road.lane.straightlane method)": [[4, "highway_env.road.lane.StraightLane.to_config"]], "width_at() (highway_env.road.lane.abstractlane method)": [[4, "highway_env.road.lane.AbstractLane.width_at"]], "width_at() (highway_env.road.lane.circularlane method)": [[4, "highway_env.road.lane.CircularLane.width_at"]], "width_at() (highway_env.road.lane.polylane method)": [[4, "highway_env.road.lane.PolyLane.width_at"]], "width_at() (highway_env.road.lane.polylanefixedwidth method)": [[4, "highway_env.road.lane.PolyLaneFixedWidth.width_at"]], "width_at() (highway_env.road.lane.straightlane method)": [[4, "highway_env.road.lane.StraightLane.width_at"]], "regulatedroad (class in highway_env.road.regulation)": [[5, "highway_env.road.regulation.RegulatedRoad"]], "enforce_road_rules() (highway_env.road.regulation.regulatedroad method)": [[5, "highway_env.road.regulation.RegulatedRoad.enforce_road_rules"]], "highway_env.road.regulation": [[5, "module-highway_env.road.regulation"]], "respect_priorities() (highway_env.road.regulation.regulatedroad static method)": [[5, "highway_env.road.regulation.RegulatedRoad.respect_priorities"]], "step() (highway_env.road.regulation.regulatedroad method)": [[5, "highway_env.road.regulation.RegulatedRoad.step"]], "road (class in highway_env.road.road)": [[6, "highway_env.road.road.Road"]], "act() (highway_env.road.road.road method)": [[6, "highway_env.road.road.Road.act"]], "highway_env.road.road": [[6, "module-highway_env.road.road"]], "neighbour_vehicles() (highway_env.road.road.road method)": [[6, "highway_env.road.road.Road.neighbour_vehicles"]], "step() (highway_env.road.road.road method)": [[6, "highway_env.road.road.Road.step"]], "acc_max (highway_env.vehicle.behavior.idmvehicle attribute)": [[7, "highway_env.vehicle.behavior.IDMVehicle.ACC_MAX"]], "aggressivevehicle (class in highway_env.vehicle.behavior)": [[7, "highway_env.vehicle.behavior.AggressiveVehicle"]], "comfort_acc_max (highway_env.vehicle.behavior.idmvehicle attribute)": [[7, "highway_env.vehicle.behavior.IDMVehicle.COMFORT_ACC_MAX"]], "comfort_acc_min (highway_env.vehicle.behavior.idmvehicle attribute)": [[7, "highway_env.vehicle.behavior.IDMVehicle.COMFORT_ACC_MIN"]], "delta (highway_env.vehicle.behavior.idmvehicle attribute)": [[7, "highway_env.vehicle.behavior.IDMVehicle.DELTA"]], "delta_range (highway_env.vehicle.behavior.idmvehicle attribute)": [[7, "highway_env.vehicle.behavior.IDMVehicle.DELTA_RANGE"]], "distance_wanted (highway_env.vehicle.behavior.idmvehicle attribute)": [[7, "highway_env.vehicle.behavior.IDMVehicle.DISTANCE_WANTED"]], "defensivevehicle (class in highway_env.vehicle.behavior)": [[7, "highway_env.vehicle.behavior.DefensiveVehicle"]], "idmvehicle (class in highway_env.vehicle.behavior)": [[7, "highway_env.vehicle.behavior.IDMVehicle"]], "linearvehicle (class in highway_env.vehicle.behavior)": [[7, "highway_env.vehicle.behavior.LinearVehicle"]], "time_wanted (highway_env.vehicle.behavior.idmvehicle attribute)": [[7, "highway_env.vehicle.behavior.IDMVehicle.TIME_WANTED"]], "time_wanted (highway_env.vehicle.behavior.linearvehicle attribute)": [[7, "highway_env.vehicle.behavior.LinearVehicle.TIME_WANTED"]], "acceleration() (highway_env.vehicle.behavior.idmvehicle method)": [[7, "highway_env.vehicle.behavior.IDMVehicle.acceleration"]], "acceleration() (highway_env.vehicle.behavior.linearvehicle method)": [[7, "highway_env.vehicle.behavior.LinearVehicle.acceleration"]], "act() (highway_env.vehicle.behavior.idmvehicle method)": [[7, "highway_env.vehicle.behavior.IDMVehicle.act"]], "act() (highway_env.vehicle.behavior.linearvehicle method)": [[7, "highway_env.vehicle.behavior.LinearVehicle.act"]], "change_lane_policy() (highway_env.vehicle.behavior.idmvehicle method)": [[7, "highway_env.vehicle.behavior.IDMVehicle.change_lane_policy"]], "collect_data() (highway_env.vehicle.behavior.linearvehicle method)": [[7, "highway_env.vehicle.behavior.LinearVehicle.collect_data"]], "create_from() (highway_env.vehicle.behavior.idmvehicle class method)": [[7, "highway_env.vehicle.behavior.IDMVehicle.create_from"]], "desired_gap() (highway_env.vehicle.behavior.idmvehicle method)": [[7, "highway_env.vehicle.behavior.IDMVehicle.desired_gap"]], "highway_env.vehicle.behavior": [[7, "module-highway_env.vehicle.behavior"]], "mobil() (highway_env.vehicle.behavior.idmvehicle method)": [[7, "highway_env.vehicle.behavior.IDMVehicle.mobil"]], "recover_from_stop() (highway_env.vehicle.behavior.idmvehicle method)": [[7, "highway_env.vehicle.behavior.IDMVehicle.recover_from_stop"]], "steering_control() (highway_env.vehicle.behavior.linearvehicle method)": [[7, "highway_env.vehicle.behavior.LinearVehicle.steering_control"]], "steering_features() (highway_env.vehicle.behavior.linearvehicle method)": [[7, "highway_env.vehicle.behavior.LinearVehicle.steering_features"]], "step() (highway_env.vehicle.behavior.idmvehicle method)": [[7, "highway_env.vehicle.behavior.IDMVehicle.step"]], "target_speed (highway_env.vehicle.behavior.aggressivevehicle attribute)": [[7, "highway_env.vehicle.behavior.AggressiveVehicle.target_speed"]], "target_speed (highway_env.vehicle.behavior.defensivevehicle attribute)": [[7, "highway_env.vehicle.behavior.DefensiveVehicle.target_speed"]], "target_speed (highway_env.vehicle.behavior.idmvehicle attribute)": [[7, "highway_env.vehicle.behavior.IDMVehicle.target_speed"]], "target_speed (highway_env.vehicle.behavior.linearvehicle attribute)": [[7, "highway_env.vehicle.behavior.LinearVehicle.target_speed"]], "controlledvehicle (class in highway_env.vehicle.controller)": [[8, "highway_env.vehicle.controller.ControlledVehicle"]], "mdpvehicle (class in highway_env.vehicle.controller)": [[8, "highway_env.vehicle.controller.MDPVehicle"]], "act() (highway_env.vehicle.controller.controlledvehicle method)": [[8, "highway_env.vehicle.controller.ControlledVehicle.act"]], "act() (highway_env.vehicle.controller.mdpvehicle method)": [[8, "highway_env.vehicle.controller.MDPVehicle.act"]], "create_from() (highway_env.vehicle.controller.controlledvehicle class method)": [[8, "highway_env.vehicle.controller.ControlledVehicle.create_from"]], "follow_road() (highway_env.vehicle.controller.controlledvehicle method)": [[8, "highway_env.vehicle.controller.ControlledVehicle.follow_road"]], "get_routes_at_intersection() (highway_env.vehicle.controller.controlledvehicle method)": [[8, "highway_env.vehicle.controller.ControlledVehicle.get_routes_at_intersection"]], "highway_env.vehicle.controller": [[8, "module-highway_env.vehicle.controller"]], "index_to_speed() (highway_env.vehicle.controller.mdpvehicle method)": [[8, "highway_env.vehicle.controller.MDPVehicle.index_to_speed"]], "plan_route_to() (highway_env.vehicle.controller.controlledvehicle method)": [[8, "highway_env.vehicle.controller.ControlledVehicle.plan_route_to"]], "predict_trajectory() (highway_env.vehicle.controller.mdpvehicle method)": [[8, "highway_env.vehicle.controller.MDPVehicle.predict_trajectory"]], "predict_trajectory_constant_speed() (highway_env.vehicle.controller.controlledvehicle method)": [[8, "highway_env.vehicle.controller.ControlledVehicle.predict_trajectory_constant_speed"]], "set_route_at_intersection() (highway_env.vehicle.controller.controlledvehicle method)": [[8, "highway_env.vehicle.controller.ControlledVehicle.set_route_at_intersection"]], "speed_control() (highway_env.vehicle.controller.controlledvehicle method)": [[8, "highway_env.vehicle.controller.ControlledVehicle.speed_control"]], "speed_to_index() (highway_env.vehicle.controller.mdpvehicle method)": [[8, "highway_env.vehicle.controller.MDPVehicle.speed_to_index"]], "speed_to_index_default() (highway_env.vehicle.controller.mdpvehicle class method)": [[8, "highway_env.vehicle.controller.MDPVehicle.speed_to_index_default"]], "steering_control() (highway_env.vehicle.controller.controlledvehicle method)": [[8, "highway_env.vehicle.controller.ControlledVehicle.steering_control"]], "target_speed (highway_env.vehicle.controller.controlledvehicle attribute)": [[8, "highway_env.vehicle.controller.ControlledVehicle.target_speed"]], "target_speed (highway_env.vehicle.controller.mdpvehicle attribute)": [[8, "highway_env.vehicle.controller.MDPVehicle.target_speed"]], "default_initial_speeds (highway_env.vehicle.kinematics.vehicle attribute)": [[9, "highway_env.vehicle.kinematics.Vehicle.DEFAULT_INITIAL_SPEEDS"]], "history_size (highway_env.vehicle.kinematics.vehicle attribute)": [[9, "highway_env.vehicle.kinematics.Vehicle.HISTORY_SIZE"]], "length (highway_env.vehicle.kinematics.vehicle attribute)": [[9, "highway_env.vehicle.kinematics.Vehicle.LENGTH"]], "max_speed (highway_env.vehicle.kinematics.vehicle attribute)": [[9, "highway_env.vehicle.kinematics.Vehicle.MAX_SPEED"]], "min_speed (highway_env.vehicle.kinematics.vehicle attribute)": [[9, "highway_env.vehicle.kinematics.Vehicle.MIN_SPEED"]], "vehicle (class in highway_env.vehicle.kinematics)": [[9, "highway_env.vehicle.kinematics.Vehicle"]], "width (highway_env.vehicle.kinematics.vehicle attribute)": [[9, "highway_env.vehicle.kinematics.Vehicle.WIDTH"]], "act() (highway_env.vehicle.kinematics.vehicle method)": [[9, "highway_env.vehicle.kinematics.Vehicle.act"]], "create_from() (highway_env.vehicle.kinematics.vehicle class method)": [[9, "highway_env.vehicle.kinematics.Vehicle.create_from"]], "create_random() (highway_env.vehicle.kinematics.vehicle class method)": [[9, "highway_env.vehicle.kinematics.Vehicle.create_random"]], "highway_env.vehicle.kinematics": [[9, "module-highway_env.vehicle.kinematics"]], "predict_trajectory() (highway_env.vehicle.kinematics.vehicle method)": [[9, "highway_env.vehicle.kinematics.Vehicle.predict_trajectory"]], "step() (highway_env.vehicle.kinematics.vehicle method)": [[9, "highway_env.vehicle.kinematics.Vehicle.step"]], "highwayenv (class in highway_env.envs.highway_env)": [[10, "highway_env.envs.highway_env.HighwayEnv"]], "default_config() (highway_env.envs.highway_env.highwayenv class method)": [[10, "highway_env.envs.highway_env.HighwayEnv.default_config"]], "intersectionenv (class in highway_env.envs.intersection_env)": [[12, "highway_env.envs.intersection_env.IntersectionEnv"]], "default_config() (highway_env.envs.intersection_env.intersectionenv class method)": [[12, "highway_env.envs.intersection_env.IntersectionEnv.default_config"]], "step() (highway_env.envs.intersection_env.intersectionenv method)": [[12, "highway_env.envs.intersection_env.IntersectionEnv.step"]], "mergeenv (class in highway_env.envs.merge_env)": [[13, "highway_env.envs.merge_env.MergeEnv"]], "default_config() (highway_env.envs.merge_env.mergeenv class method)": [[13, "highway_env.envs.merge_env.MergeEnv.default_config"]], "parkingenv (class in highway_env.envs.parking_env)": [[14, "highway_env.envs.parking_env.ParkingEnv"]], "compute_reward() (highway_env.envs.parking_env.parkingenv method)": [[14, "highway_env.envs.parking_env.ParkingEnv.compute_reward"]], "default_config() (highway_env.envs.parking_env.parkingenv class method)": [[14, "highway_env.envs.parking_env.ParkingEnv.default_config"]], "define_spaces() (highway_env.envs.parking_env.parkingenv method)": [[14, "highway_env.envs.parking_env.ParkingEnv.define_spaces"]], "racetrackenv (class in highway_env.envs.racetrack_env)": [[15, "highway_env.envs.racetrack_env.RacetrackEnv"]], "default_config() (highway_env.envs.racetrack_env.racetrackenv class method)": [[15, "highway_env.envs.racetrack_env.RacetrackEnv.default_config"]], "roundaboutenv (class in highway_env.envs.roundabout_env)": [[16, "highway_env.envs.roundabout_env.RoundaboutEnv"]], "default_config() (highway_env.envs.roundabout_env.roundaboutenv class method)": [[16, "highway_env.envs.roundabout_env.RoundaboutEnv.default_config"]], "envviewer (class in highway_env.envs.common.graphics)": [[18, "highway_env.envs.common.graphics.EnvViewer"]], "lanegraphics (class in highway_env.road.graphics)": [[18, "highway_env.road.graphics.LaneGraphics"]], "roadgraphics (class in highway_env.road.graphics)": [[18, "highway_env.road.graphics.RoadGraphics"]], "roadobjectgraphics (class in highway_env.road.graphics)": [[18, "highway_env.road.graphics.RoadObjectGraphics"]], "stripe_length (highway_env.road.graphics.lanegraphics attribute)": [[18, "highway_env.road.graphics.LaneGraphics.STRIPE_LENGTH"]], "stripe_spacing (highway_env.road.graphics.lanegraphics attribute)": [[18, "highway_env.road.graphics.LaneGraphics.STRIPE_SPACING"]], "stripe_width (highway_env.road.graphics.lanegraphics attribute)": [[18, "highway_env.road.graphics.LaneGraphics.STRIPE_WIDTH"]], "worldsurface (class in highway_env.road.graphics)": [[18, "highway_env.road.graphics.WorldSurface"]], "blit_rotate() (highway_env.road.graphics.roadobjectgraphics static method)": [[18, "highway_env.road.graphics.RoadObjectGraphics.blit_rotate"]], "close() (highway_env.envs.common.graphics.envviewer method)": [[18, "highway_env.envs.common.graphics.EnvViewer.close"]], "continuous_curve() (highway_env.road.graphics.lanegraphics class method)": [[18, "highway_env.road.graphics.LaneGraphics.continuous_curve"]], "continuous_line() (highway_env.road.graphics.lanegraphics class method)": [[18, "highway_env.road.graphics.LaneGraphics.continuous_line"]], "display() (highway_env.envs.common.graphics.envviewer method)": [[18, "highway_env.envs.common.graphics.EnvViewer.display"]], "display() (highway_env.road.graphics.lanegraphics class method)": [[18, "highway_env.road.graphics.LaneGraphics.display"]], "display() (highway_env.road.graphics.roadgraphics static method)": [[18, "highway_env.road.graphics.RoadGraphics.display"]], "display() (highway_env.road.graphics.roadobjectgraphics class method)": [[18, "highway_env.road.graphics.RoadObjectGraphics.display"]], "display_road_objects() (highway_env.road.graphics.roadgraphics static method)": [[18, "highway_env.road.graphics.RoadGraphics.display_road_objects"]], "display_traffic() (highway_env.road.graphics.roadgraphics static method)": [[18, "highway_env.road.graphics.RoadGraphics.display_traffic"]], "draw_stripes() (highway_env.road.graphics.lanegraphics class method)": [[18, "highway_env.road.graphics.LaneGraphics.draw_stripes"]], "get_image() (highway_env.envs.common.graphics.envviewer method)": [[18, "highway_env.envs.common.graphics.EnvViewer.get_image"]], "handle_event() (highway_env.road.graphics.worldsurface method)": [[18, "highway_env.road.graphics.WorldSurface.handle_event"]], "handle_events() (highway_env.envs.common.graphics.envviewer method)": [[18, "highway_env.envs.common.graphics.EnvViewer.handle_events"]], "highway_env.envs.common.graphics": [[18, "module-highway_env.envs.common.graphics"]], "highway_env.road.graphics": [[18, "module-highway_env.road.graphics"]], "highway_env.vehicle.graphics": [[18, "module-highway_env.vehicle.graphics"]], "is_visible() (highway_env.road.graphics.worldsurface method)": [[18, "highway_env.road.graphics.WorldSurface.is_visible"]], "move_display_window_to() (highway_env.road.graphics.worldsurface method)": [[18, "highway_env.road.graphics.WorldSurface.move_display_window_to"]], "pix() (highway_env.road.graphics.worldsurface method)": [[18, "highway_env.road.graphics.WorldSurface.pix"]], "pos2pix() (highway_env.road.graphics.worldsurface method)": [[18, "highway_env.road.graphics.WorldSurface.pos2pix"]], "set_agent_action_sequence() (highway_env.envs.common.graphics.envviewer method)": [[18, "highway_env.envs.common.graphics.EnvViewer.set_agent_action_sequence"]], "set_agent_display() (highway_env.envs.common.graphics.envviewer method)": [[18, "highway_env.envs.common.graphics.EnvViewer.set_agent_display"]], "striped_line() (highway_env.road.graphics.lanegraphics class method)": [[18, "highway_env.road.graphics.LaneGraphics.striped_line"]], "vec2pix() (highway_env.road.graphics.worldsurface method)": [[18, "highway_env.road.graphics.WorldSurface.vec2pix"]], "window_position() (highway_env.envs.common.graphics.envviewer method)": [[18, "highway_env.envs.common.graphics.EnvViewer.window_position"]], "abstractenv (class in highway_env.envs.common.abstract)": [[21, "highway_env.envs.common.abstract.AbstractEnv"]], "multiagentwrapper (class in highway_env.envs.common.abstract)": [[21, "highway_env.envs.common.abstract.MultiAgentWrapper"]], "perception_distance (highway_env.envs.common.abstract.abstractenv attribute)": [[21, "highway_env.envs.common.abstract.AbstractEnv.PERCEPTION_DISTANCE"]], "_automatic_rendering() (highway_env.envs.common.abstract.abstractenv method)": [[21, "highway_env.envs.common.abstract.AbstractEnv._automatic_rendering"]], "_info() (highway_env.envs.common.abstract.abstractenv method)": [[21, "highway_env.envs.common.abstract.AbstractEnv._info"]], "_is_terminated() (highway_env.envs.common.abstract.abstractenv method)": [[21, "highway_env.envs.common.abstract.AbstractEnv._is_terminated"]], "_is_truncated() (highway_env.envs.common.abstract.abstractenv method)": [[21, "highway_env.envs.common.abstract.AbstractEnv._is_truncated"]], "_reset() (highway_env.envs.common.abstract.abstractenv method)": [[21, "highway_env.envs.common.abstract.AbstractEnv._reset"]], "_reward() (highway_env.envs.common.abstract.abstractenv method)": [[21, "highway_env.envs.common.abstract.AbstractEnv._reward"]], "_rewards() (highway_env.envs.common.abstract.abstractenv method)": [[21, "highway_env.envs.common.abstract.AbstractEnv._rewards"]], "_simulate() (highway_env.envs.common.abstract.abstractenv method)": [[21, "highway_env.envs.common.abstract.AbstractEnv._simulate"]], "change_vehicles() (highway_env.envs.common.abstract.abstractenv method)": [[21, "highway_env.envs.common.abstract.AbstractEnv.change_vehicles"]], "close() (highway_env.envs.common.abstract.abstractenv method)": [[21, "highway_env.envs.common.abstract.AbstractEnv.close"]], "default_config() (highway_env.envs.common.abstract.abstractenv class method)": [[21, "highway_env.envs.common.abstract.AbstractEnv.default_config"]], "define_spaces() (highway_env.envs.common.abstract.abstractenv method)": [[21, "highway_env.envs.common.abstract.AbstractEnv.define_spaces"]], "highway_env.__init__": [[21, "module-highway_env.__init__"]], "highway_env.envs.common.abstract": [[21, "module-highway_env.envs.common.abstract"]], "register_highway_envs() (in module highway_env.__init__)": [[21, "highway_env.__init__.register_highway_envs"]], "render() (highway_env.envs.common.abstract.abstractenv method)": [[21, "highway_env.envs.common.abstract.AbstractEnv.render"]], "reset() (highway_env.envs.common.abstract.abstractenv method)": [[21, "highway_env.envs.common.abstract.AbstractEnv.reset"]], "simplify() (highway_env.envs.common.abstract.abstractenv method)": [[21, "highway_env.envs.common.abstract.AbstractEnv.simplify"]], "step() (highway_env.envs.common.abstract.abstractenv method)": [[21, "highway_env.envs.common.abstract.AbstractEnv.step"]], "step() (highway_env.envs.common.abstract.multiagentwrapper method)": [[21, "highway_env.envs.common.abstract.MultiAgentWrapper.step"]], "vehicle (highway_env.envs.common.abstract.abstractenv property)": [[21, "highway_env.envs.common.abstract.AbstractEnv.vehicle"]], "exitobservation (class in highway_env.envs.common.observation)": [[23, "highway_env.envs.common.observation.ExitObservation"]], "grayscaleobservation (class in highway_env.envs.common.observation)": [[23, "highway_env.envs.common.observation.GrayscaleObservation"]], "kinematicobservation (class in highway_env.envs.common.observation)": [[23, "highway_env.envs.common.observation.KinematicObservation"]], "kinematicsgoalobservation (class in highway_env.envs.common.observation)": [[23, "highway_env.envs.common.observation.KinematicsGoalObservation"]], "occupancygridobservation (class in highway_env.envs.common.observation)": [[23, "highway_env.envs.common.observation.OccupancyGridObservation"]], "fill_road_layer_by_cell() (highway_env.envs.common.observation.occupancygridobservation method)": [[23, "highway_env.envs.common.observation.OccupancyGridObservation.fill_road_layer_by_cell"]], "fill_road_layer_by_lanes() (highway_env.envs.common.observation.occupancygridobservation method)": [[23, "highway_env.envs.common.observation.OccupancyGridObservation.fill_road_layer_by_lanes"]], "highway_env.envs.common.observation": [[23, "module-highway_env.envs.common.observation"]], "normalize() (highway_env.envs.common.observation.occupancygridobservation method)": [[23, "highway_env.envs.common.observation.OccupancyGridObservation.normalize"]], "normalize_obs() (highway_env.envs.common.observation.kinematicobservation method)": [[23, "highway_env.envs.common.observation.KinematicObservation.normalize_obs"]], "observe() (highway_env.envs.common.observation.exitobservation method)": [[23, "highway_env.envs.common.observation.ExitObservation.observe"]], "observe() (highway_env.envs.common.observation.grayscaleobservation method)": [[23, "highway_env.envs.common.observation.GrayscaleObservation.observe"]], "observe() (highway_env.envs.common.observation.kinematicobservation method)": [[23, "highway_env.envs.common.observation.KinematicObservation.observe"]], "observe() (highway_env.envs.common.observation.kinematicsgoalobservation method)": [[23, "highway_env.envs.common.observation.KinematicsGoalObservation.observe"]], "observe() (highway_env.envs.common.observation.occupancygridobservation method)": [[23, "highway_env.envs.common.observation.OccupancyGridObservation.observe"]], "pos_to_index() (highway_env.envs.common.observation.occupancygridobservation method)": [[23, "highway_env.envs.common.observation.OccupancyGridObservation.pos_to_index"]], "space() (highway_env.envs.common.observation.grayscaleobservation method)": [[23, "highway_env.envs.common.observation.GrayscaleObservation.space"]], "space() (highway_env.envs.common.observation.kinematicobservation method)": [[23, "highway_env.envs.common.observation.KinematicObservation.space"]], "space() (highway_env.envs.common.observation.kinematicsgoalobservation method)": [[23, "highway_env.envs.common.observation.KinematicsGoalObservation.space"]], "space() (highway_env.envs.common.observation.occupancygridobservation method)": [[23, "highway_env.envs.common.observation.OccupancyGridObservation.space"]]}})
\ No newline at end of file
+Search.setIndex({"docnames": ["404", "actions/index", "bibliography/index", "dynamics/index", "dynamics/road/lane", "dynamics/road/regulation", "dynamics/road/road", "dynamics/vehicle/behavior", "dynamics/vehicle/controller", "dynamics/vehicle/kinematics", "environments/highway", "environments/index", "environments/intersection", "environments/merge", "environments/parking", "environments/racetrack", "environments/roundabout", "faq", "graphics/index", "index", "installation", "make_your_own", "multi_agent", "observations/index", "quickstart", "rewards/index", "user_guide"], "filenames": ["404.md", "actions/index.md", "bibliography/index.md", "dynamics/index.md", "dynamics/road/lane.md", "dynamics/road/regulation.md", "dynamics/road/road.md", "dynamics/vehicle/behavior.md", "dynamics/vehicle/controller.md", "dynamics/vehicle/kinematics.md", "environments/highway.md", "environments/index.md", "environments/intersection.md", "environments/merge.md", "environments/parking.md", "environments/racetrack.md", "environments/roundabout.md", "faq.md", "graphics/index.md", "index.md", "installation.md", "make_your_own.md", "multi_agent.md", "observations/index.md", "quickstart.md", "rewards/index.md", "user_guide.md"], "titles": ["404", "Actions", "Bibliography", "Dynamics", "Lane", "Road regulation", "Road", "Behavior", "Control", "Kinematics", "Highway", "The environments", "Intersection", "Merge", "Parking", "Racetrack", "Roundabout", "Frequently Asked Questions", "Graphics", "Welcome to highway-env\u2019s documentation!", "Installation", "Make your own environment", "The Multi-Agent setting", "Observations", "Getting Started", "Rewards", "User Guide"], "terms": {"similarli": 1, "observ": [1, 2, 10, 12, 13, 14, 15, 16, 21, 24, 25, 26], "sever": [1, 7, 10, 12, 17, 21, 23, 24], "type": [1, 4, 10, 12, 13, 14, 15, 16, 21, 22, 23, 24], "can": [1, 4, 6, 7, 8, 10, 12, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23, 24, 25], "us": [1, 7, 8, 9, 14, 18, 19, 20, 21, 23, 24, 25], "everi": [1, 3, 25], "environ": [1, 3, 10, 12, 13, 14, 15, 16, 18, 19, 22, 23, 26], "thei": [1, 5, 7, 13, 18, 23, 25], "ar": [1, 3, 4, 5, 6, 7, 8, 9, 10, 18, 21, 22, 23, 24, 25], "defin": [1, 4, 6, 10, 12, 13, 14, 15, 16, 18, 21, 23, 24, 25], "modul": [1, 21, 23], "each": [1, 5, 6, 8, 9, 12, 17, 18, 22, 23], "come": [1, 12, 23], "default": [1, 7, 8, 9, 18, 21, 23, 24], "which": [1, 4, 5, 6, 7, 8, 12, 14, 17, 18, 20, 21, 22, 23, 24, 25], "chang": [1, 2, 4, 7, 8, 16, 17, 21, 23, 24, 26], "customis": [1, 23], "configur": [1, 18, 22, 25, 26], "For": [1, 6, 7, 17, 22, 23, 24], "instanc": [1, 4, 6, 7, 8, 9, 23, 24], "import": [1, 3, 17, 21, 22, 23, 24], "gymnasium": [1, 18, 21, 22, 23, 24], "gym": [1, 10, 12, 13, 14, 15, 16, 17, 18, 21, 22, 23, 24], "env": [1, 10, 12, 13, 14, 15, 16, 17, 18, 20, 21, 22, 23, 24], "make": [1, 2, 10, 12, 13, 14, 15, 16, 18, 19, 22, 23, 26], "highwai": [1, 11, 13, 15, 18, 20, 22, 23, 24], "v0": [1, 10, 12, 13, 14, 15, 16, 17, 18, 21, 22, 23, 24], "config": [1, 4, 10, 12, 13, 14, 15, 16, 18, 21, 22, 23, 24], "continuousact": [1, 14, 15], "The": [1, 2, 3, 4, 6, 7, 8, 9, 10, 12, 13, 15, 16, 18, 19, 20, 21, 23, 24, 25, 26], "allow": [1, 7, 8, 21], "agent": [1, 10, 12, 13, 14, 15, 18, 21, 23, 25, 26], "directli": [1, 23, 25], "set": [1, 2, 4, 5, 6, 8, 14, 18, 23, 26], "low": [1, 8], "level": [1, 2, 4, 8, 17], "vehicl": [1, 2, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16, 17, 18, 24, 25, 26], "kinemat": [1, 2, 3, 6, 8, 10, 12, 22, 24, 26], "name": [1, 23], "throttl": [1, 8], "steer": [1, 7, 8, 9, 14], "angl": [1, 4, 7, 8, 9, 18, 23], "delta": [1, 7, 8, 9], "enabl": [1, 23], "disabl": 1, "through": [1, 2, 3, 5, 8, 21, 25], "longitudin": [1, 4, 9, 12, 15, 16, 18, 23], "later": [1, 4, 12, 15, 18, 23], "respect": [1, 7, 8, 18, 25], "thu": [1, 17, 25], "space": [1, 7, 9, 14, 18, 21, 23, 26], "either": 1, "1d": [1, 7], "2d": [1, 4, 7], "discreteact": 1, "i": [1, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16, 18, 19, 21, 22, 24, 25], "uniform": [1, 8, 23], "quantiz": 1, "abov": 1, "actions_per_axi": 1, "paramet": [1, 4, 5, 6, 7, 8, 9, 12, 14, 18, 21, 23, 25], "step": [1, 5, 6, 7, 9, 12, 16, 17, 21, 22, 23, 24], "axi": [1, 7, 8, 9, 23], "separ": [1, 18], "discretemetaact": [1, 10, 12, 13, 16, 22, 24], "add": [1, 21], "layer": [1, 23], "speed": [1, 7, 8, 9, 10, 13, 14, 21, 25], "top": [1, 8, 23], "so": [1, 7, 13, 14, 17, 18, 21, 23], "ego": [1, 7, 10, 12, 13, 14, 16, 18, 21, 25], "automat": [1, 8, 16, 21], "follow": [1, 2, 6, 7, 8, 15, 16, 17, 18, 21, 23, 24], "road": [1, 4, 7, 8, 9, 10, 12, 13, 18, 21, 23, 25, 26], "desir": [1, 7, 8, 14, 21, 23, 25], "veloc": [1, 5, 7, 8, 23, 25], "Then": 1, "avail": [1, 10, 24], "consist": [1, 2], "target": [1, 5, 7, 8], "lane": [1, 2, 3, 5, 6, 7, 8, 9, 10, 16, 17, 18, 21, 22, 23, 24], "setpoint": 1, "full": [1, 24], "correspond": [1, 4, 8, 14, 17, 18, 21, 23], "actions_al": [1, 22], "0": [1, 4, 5, 7, 8, 9, 10, 12, 13, 14, 15, 16, 18, 20, 21, 22, 23, 24, 25], "lane_left": 1, "1": [1, 4, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16, 17, 18, 22, 23, 24, 25], "idl": [1, 23, 24], "2": [1, 2, 7, 8, 9, 10, 20, 22, 23, 24], "lane_right": 1, "3": [1, 7, 10, 12, 13, 15, 18, 20, 23, 24], "faster": [1, 8, 23], "4": [1, 7, 10, 15, 18, 23, 24], "slower": [1, 8], "some": [1, 5, 8, 13, 25], "might": 1, "alwai": [1, 18, 23], "edg": [1, 6], "acceler": [1, 7, 8, 9, 14], "decelr": 1, "beyond": 1, "maximum": [1, 7, 9, 21, 23, 25], "minimum": [1, 7, 9, 25], "list": [1, 3, 4, 5, 6, 7, 8, 9, 17, 18, 21, 23, 24], "access": [1, 13, 21, 24], "get_available_act": 1, "method": [1, 4, 5, 7, 8, 9, 16, 21, 25], "take": [1, 5, 7, 23, 24], "an": [1, 5, 6, 7, 8, 9, 12, 18, 19, 21, 22, 23, 25], "unavail": 1, "equival": 1, "intersect": [1, 5, 6, 8, 11, 24], "onli": [1, 7, 9, 21, 22, 24, 25], "while": [1, 9, 10, 13, 15, 16, 17, 21, 22, 24], "perform": [1, 7, 8, 12, 21, 23, 24], "track": [1, 8, 15], "simul": [1, 2, 7, 8, 9, 12, 17, 18, 21, 23], "manual_control": [1, 24], "true": [1, 4, 7, 10, 12, 13, 14, 15, 16, 17, 23, 24], "reset": [1, 17, 18, 21, 22, 23, 24], "done": [1, 16, 17, 18, 22, 23, 24], "fals": [1, 4, 5, 6, 10, 12, 13, 14, 15, 16, 17, 18, 22, 23, 24], "action_spac": [1, 17, 21], "sampl": [1, 17, 21], "ignor": 1, "direct": [1, 7, 8, 9, 23], "arrow": 1, "kei": [1, 16, 18, 23], "eventhandl": 1, "class": [1, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16, 18, 21, 22, 23], "highway_env": [1, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16, 17, 18, 21, 22, 23, 24], "common": [1, 18, 21, 22, 23], "actiontyp": 1, "abstractenv": [1, 18, 21, 23], "kwarg": [1, 23], "sourc": [1, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16, 18, 21, 23], "A": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 13, 14, 15, 18, 21, 22, 23, 24], "specifi": [1, 8, 21, 25], "its": [1, 4, 6, 7, 8, 9, 16, 17, 22, 24], "definit": 1, "how": [1, 3, 7, 22, 24], "execut": [1, 7, 12, 21, 22], "properti": [1, 7, 8, 9, 21], "vehicle_class": [1, 21], "callabl": [1, 18], "abl": [1, 8, 17, 21], "must": [1, 6, 14, 18, 20, 21, 22, 24, 25], "return": [1, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16, 18, 21, 22, 23, 25], "subclass": 1, "act": [1, 6, 7, 8, 9], "int": [1, 4, 6, 7, 8, 9, 12, 18, 21, 23, 24], "ndarrai": [1, 4, 7, 8, 9, 12, 14, 18, 21, 23], "none": [1, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16, 18, 21, 23, 24], "most": [1, 5, 22, 26], "mechan": 1, "actual": [1, 6, 17, 22], "implement": [1, 4, 7, 8, 10, 12, 13, 14, 15, 16, 17, 18, 21, 22, 23, 24], "where": [1, 6, 7, 8, 9, 14, 15, 21, 23, 25], "pre": 1, "process": [1, 2], "appli": [1, 8], "base": [1, 5, 7, 9, 24], "controlled_vehicl": [1, 15, 22, 24], "upon": 1, "If": [1, 7, 8, 9, 16, 19, 21, 23], "first": [1, 5, 17, 18, 21, 22, 23], "acceleration_rang": 1, "tupl": [1, 4, 6, 7, 8, 12, 18, 21, 22, 23], "float": [1, 4, 5, 6, 7, 8, 9, 12, 14, 18, 21, 23], "steering_rang": 1, "speed_rang": 1, "bool": [1, 4, 5, 6, 7, 12, 18, 21, 23], "dynam": [1, 5, 6, 7, 8, 9, 12, 21, 24, 26], "clip": [1, 23], "both": [1, 4, 7, 22, 23], "thi": [1, 4, 7, 10, 12, 13, 16, 17, 20, 21, 22, 23, 24, 25], "order": [1, 9, 17, 22, 23, 25], "interv": 1, "map": [1, 10, 23], "creat": [1, 4, 7, 8, 9, 18, 24, 26], "rang": [1, 7, 8, 9, 10, 23, 24, 25], "valu": [1, 16, 21, 23, 24], "m": [1, 4, 7, 8, 9, 10, 16, 18, 21, 23], "s\u00b2": 1, "rad": [1, 4, 7, 8], "reachabl": [1, 4, 9], "": [1, 5, 6, 7, 8, 9, 10, 12, 13, 16, 17, 18, 21, 22, 23, 24, 25], "whether": [1, 4, 5, 6, 7, 18, 21, 23], "e": [1, 2, 17], "friction": 1, "rather": [1, 25], "than": [1, 7, 17, 23, 25], "5": [1, 7, 9, 10, 12, 13, 14, 15, 16, 20, 22, 23, 24], "x": [1, 4, 9, 12, 14, 18, 23, 25], "7853981633974483": 1, "box": 1, "target_spe": [1, 7, 8], "sequenc": [1, 4, 7, 8, 9, 18, 23], "cruis": [1, 8], "point": [1, 2, 4], "includ": [1, 5, 6, 22], "index": [1, 6, 7, 8, 23], "label": 1, "actions_longi": 1, "actions_lat": 1, "get": [1, 4, 8, 20, 22, 23], "current": [1, 6, 8, 9, 20, 21, 23, 25], "boundari": 1, "maxim": [1, 7], "minim": [1, 7], "multiagentact": [1, 22], "action_config": [1, 22], "dict": [1, 4, 7, 8, 9, 10, 12, 13, 14, 15, 16, 18, 21, 23, 24], "awr": [2, 24], "17": [2, 24], "marcin": 2, "andrychowicz": 2, "filip": 2, "wolski": 2, "alex": 2, "rai": 2, "jona": 2, "schneider": 2, "rachel": 2, "fong": 2, "peter": 2, "welind": 2, "bob": 2, "mcgrew": 2, "josh": 2, "tobin": 2, "pieter": 2, "abbeel": 2, "wojciech": 2, "zaremba": 2, "hindsight": [2, 24], "experi": [2, 22, 24], "replai": [2, 24], "In": [2, 7, 10, 13, 16, 17, 21, 22, 23, 25], "advanc": 2, "neural": 2, "inform": [2, 14, 17, 21, 23], "system": [2, 4, 9, 12, 18], "2017": 2, "arxiv": 2, "1707": 2, "01495": 2, "hm08": [2, 24], "jean": 2, "fran": 2, "\u00e7": 2, "oi": 2, "hren": 2, "r": [2, 7, 8, 25], "\u00e9": 2, "mi": 2, "muno": 2, "optimist": 2, "plan": [2, 8, 16, 24], "determinist": [2, 24], "lectur": 2, "note": [2, 25], "comput": [2, 4, 7, 8, 21], "scienc": 2, "2008": 2, "kth07": [2, 7], "arn": 2, "kest": 2, "martin": 2, "treiber": 2, "dirk": 2, "helb": 2, "gener": [2, 5, 6, 17, 21, 22, 25], "model": [2, 3, 7, 8, 9, 21, 22, 24], "mobil": [2, 7], "car": 2, "transport": 2, "research": 2, "record": [2, 5, 6, 17], "2007": 2, "doi": 2, "10": [2, 7, 12, 23], "3141": 2, "1999": 2, "lm19": [2, 17, 24], "edouard": [2, 19], "leurent": [2, 19], "mercat": 2, "social": [2, 24], "attent": [2, 24], "autonom": [2, 19], "decis": [2, 7, 12, 19, 21], "dens": [2, 12], "traffic": [2, 12, 13, 16], "machin": 2, "learn": [2, 15, 24, 25], "drive": [2, 5, 6, 8, 9, 10, 13, 18, 19, 21, 24, 25], "workshop": 2, "thirti": 2, "third": 2, "confer": 2, "neurip": 2, "2019": [2, 24], "montreal": 2, "canada": 2, "decemb": 2, "1911": 2, "12250": 2, "mk": [2, 25], "15": [2, 10, 12, 13, 14, 15, 16, 17, 18, 23, 24, 25], "volodymyr": 2, "mnih": 2, "korai": 2, "kavukcuoglu": 2, "david": 2, "silver": 2, "andrei": 2, "rusu": 2, "joel": 2, "veness": 2, "marc": 2, "g": [2, 17], "bellemar": 2, "grave": 2, "riedmil": 2, "andrea": 2, "k": [2, 16, 18], "fidjeland": 2, "georg": 2, "ostrovski": 2, "stig": 2, "petersen": 2, "charl": 2, "beatti": 2, "amir": 2, "sadik": 2, "ioanni": 2, "antonogl": 2, "helen": 2, "king": 2, "dharshan": 2, "kumaran": 2, "daan": 2, "wierstra": 2, "shane": 2, "legg": 2, "demi": 2, "hassabi": 2, "human": 2, "control": [2, 3, 7, 14, 15, 16, 21, 26], "deep": [2, 24, 25], "reinforc": [2, 24, 25], "natur": [2, 23], "518": 2, "7540": 2, "529": 2, "533": 2, "2015": 2, "paltchedandrean17": [2, 9], "philip": 2, "polack": 2, "florent": 2, "altch": 2, "brigitt": 2, "d": [2, 7], "andr": 2, "novel": [2, 17], "bicycl": [2, 9], "feasibl": 2, "trajectori": [2, 5, 6, 8, 9, 24, 25], "ieee": 2, "intellig": [2, 7], "symposium": 2, "page": [2, 24], "6": [2, 7, 12, 16, 23], "8": [2, 23, 24], "qsmg17": [2, 17], "qi": 2, "hao": 2, "su": 2, "kaichun": 2, "mo": 2, "leonida": 2, "j": [2, 23], "guiba": 2, "pointnet": 2, "3d": 2, "classif": 2, "segment": 2, "1612": 2, "00593": 2, "thh00": [2, 7], "ansgar": 2, "henneck": 2, "congest": 2, "state": [2, 7, 8, 9, 17, 21, 22, 23, 25], "empir": 2, "microscop": 2, "physic": [2, 3], "review": 2, "statist": 2, "plasma": 2, "fluid": 2, "relat": 2, "interdisciplinari": 2, "topic": 2, "62": 2, "1805": 2, "1824": 2, "2000": 2, "describ": [3, 4, 5, 6, 10, 17, 19, 21, 22, 23], "move": [3, 9, 18, 23], "behav": [3, 5], "time": [3, 5, 7, 8, 16, 25, 26], "There": [3, 24], "two": [3, 5, 7, 8, 15, 17, 18, 22, 23, 25], "section": 3, "affect": 3, "descript": [3, 19, 23, 24], "behavior": [3, 5, 10, 12, 13, 16, 21, 24], "compos": [3, 6, 25], "roadnetwork": [3, 5, 6, 21], "regul": 3, "geometri": [4, 6, 21], "abstractlan": [4, 6, 18], "object": [4, 5, 6, 7, 8, 9, 10, 13, 18, 21, 23], "parametr": [4, 24], "center": [4, 7, 8, 9, 18, 23], "line": [4, 8, 18], "curv": [4, 24], "provid": [4, 8, 17, 18, 19, 21, 24], "local": [4, 6, 17, 18], "coordin": [4, 6, 18, 23], "convers": [4, 23], "between": [4, 5, 7, 8, 9, 18, 23, 25], "longi": 4, "lat": [4, 8, 18], "frenet": 4, "frame": [4, 17, 18, 21, 23], "global": 4, "y": [4, 9, 12, 14, 18, 20, 23, 25], "ensur": 4, "posit": [4, 6, 7, 9, 14, 18, 23], "local_coordin": 4, "main": [4, 13], "straightlan": 4, "sinelan": 4, "circularlan": 4, "central": [4, 12, 22], "metaclass__": 4, "alia": 4, "abcmeta": 4, "abstract": [4, 21], "convert": [4, 8, 18, 23], "world": [4, 23, 26], "heading_at": 4, "head": [4, 7, 9, 14, 23], "given": [4, 6, 7, 8, 9, 14, 17, 18, 21], "width_at": 4, "width": [4, 9, 16, 18], "classmethod": [4, 7, 8, 9, 10, 12, 13, 14, 15, 16, 18, 21], "from_config": 4, "from": [4, 6, 7, 8, 9, 10, 14, 21, 22, 23, 24, 25], "json": [4, 22], "to_config": 4, "write": 4, "serial": 4, "on_lan": 4, "margin": [4, 18], "option": [4, 19, 21], "known": 4, "supplementari": [4, 14], "around": [4, 18, 23], "is_reachable_from": 4, "distanc": [4, 7, 18, 21, 23, 25], "l1": 4, "distance_with_head": 4, "heading_weight": 4, "weight": [4, 7, 14, 23, 25], "local_angl": 4, "long_offset": 4, "non": [4, 7, 8, 23], "normalis": [4, 23], "linetyp": 4, "side": [4, 10, 18], "start": [4, 6, 9, 13, 18, 19], "end": [4, 6, 8, 9, 12, 18, 21, 22], "default_width": 4, "line_typ": 4, "forbidden": 4, "speed_limit": 4, "20": [4, 10, 12, 23, 24], "prioriti": [4, 5], "go": [4, 6], "straight": [4, 10, 23], "new": [4, 5, 6, 7, 8, 9, 17, 21], "determin": [4, 5], "who": [4, 5], "ha": [4, 15, 16, 20, 21, 22, 23, 24, 25], "right": [4, 5, 7, 8, 10, 18, 22, 23], "wai": [4, 5, 12, 17, 24], "amplitud": 4, "pulsat": 4, "phase": 4, "sinusoid": 4, "oscil": 4, "initi": [4, 8, 9, 14, 15, 18, 21, 22], "radiu": 4, "start_phas": 4, "end_phas": 4, "clockwis": 4, "circl": 4, "arc": 4, "polylanefixedwidth": 4, "lane_point": 4, "fix": [4, 21, 23], "approxim": [4, 7], "hermit": 4, "polynomi": 4, "polylan": 4, "left_boundary_point": 4, "right_boundary_point": 4, "regulatedroad": 5, "give": [5, 6, 21, 23], "attribut": [5, 24], "On": 5, "rule": 5, "enforc": 5, "usual": [5, 17], "howev": [5, 17, 24, 25], "try": [5, 7], "predict": [5, 8, 9, 12, 22, 23, 24], "collis": [5, 10, 12, 13, 15, 16, 25, 26], "other": [5, 7, 8, 9, 10, 12, 15, 21, 22, 23], "is_conflict_poss": 5, "when": [5, 7, 8, 10], "case": [5, 6, 17, 23], "arbitr": 5, "respect_prior": 5, "yield": [5, 8, 24, 25], "until": [5, 9, 12, 21], "conflict": 5, "resolv": 5, "network": [5, 6, 8, 21, 23], "obstacl": [5, 6, 23], "np_random": [5, 6], "randomst": [5, 6], "record_histori": [5, 6], "road_object": [5, 6], "landmark": [5, 6], "np": [5, 6], "random": [5, 6, 9, 24], "number": [5, 6, 9, 16, 18, 23, 24, 26], "behaviour": [5, 6, 7, 12, 18, 21, 25], "recent": [5, 6], "should": [5, 6, 7, 17, 18, 21, 22, 23, 25], "displai": [5, 6, 9, 16, 18], "dt": [5, 6, 7, 8, 9], "entiti": [5, 6], "timestep": [5, 6, 7, 8, 9, 12, 21], "enforce_road_rul": 5, "find": [5, 6, 8], "them": [5, 18, 24, 25], "assign": 5, "stop": [5, 7, 9], "static": [5, 18], "v1": 5, "v2": 5, "second": [5, 6, 16, 21, 22], "topologi": [6, 21], "infrastructur": 6, "graph": 6, "repres": [6, 9, 18, 23], "node": [6, 8, 9], "It": [6, 7, 8, 9, 12, 13, 14, 16], "contain": [6, 21, 22, 23], "dictionari": [6, 21, 23, 24], "store": [6, 7, 9], "laneindex": 6, "string": 6, "identifi": 6, "integ": 6, "uniqu": 6, "lab": 6, "pub": 6, "obtain": [6, 24], "road_network": 6, "roadobject": [6, 18], "decid": [6, 7, 22], "action": [6, 7, 8, 9, 10, 12, 13, 14, 15, 16, 17, 18, 21, 24, 26], "neighbour_vehicl": 6, "lane_index": [6, 7], "str": [6, 7, 8, 9, 10, 12, 13, 14, 15, 16, 21, 23], "preced": [6, 7], "whose": [6, 7], "neighbour": [6, 10], "found": [6, 25], "look": [6, 23], "doesn": [6, 7], "t": [6, 7, 16, 23], "have": [6, 7, 14, 21, 25], "also": [6, 10, 13, 17, 18, 23, 24, 25], "anoth": 6, "project": [6, 7, 19, 20, 25], "consid": [6, 19, 23], "simpl": [7, 8, 12, 25], "realist": [7, 25], "dictat": 7, "idmvehicl": [7, 10, 13, 16, 21, 24], "driver": 7, "idm": 7, "dot": [7, 8, 9], "v": [7, 8, 9, 23, 25], "left": [7, 8, 18, 22, 23], "frac": [7, 8, 9, 25], "v_0": 7, "d_0": 7, "tv": 7, "sqrt": 7, "ab": 7, "front": [7, 8, 9, 25], "parametris": 7, "target_veloc": 7, "gap": 7, "time_w": 7, "jam": 7, "distance_w": 7, "b": [7, 25], "deceler": 7, "comfort_acc_max": 7, "comfort_acc_min": 7, "expon": 7, "discret": [7, 8, 26], "overal": 7, "brake": [7, 9, 25], "induc": 7, "accord": 7, "safe": [7, 13, 25], "do": [7, 17, 25], "cut": 7, "tild": 7, "_n": 7, "geq": 7, "b_": 7, "text": [7, 8, 25], "incent": 7, "possibli": 7, "underbrac": 7, "_c": 7, "a_c": 7, "_": [7, 22, 23, 24, 25], "p": [7, 8, 14, 25], "a_n": 7, "_o": 7, "a_o": 7, "old": 7, "a_": 7, "th": 7, "c": [7, 18, 23], "o": [7, 18], "befor": [7, 22], "n": 7, "after": [7, 22, 24], "polit": 7, "coeffici": [7, 25], "gain": [7, 8], "requir": [7, 20, 21], "trigger": 7, "lane_change_min_acc_gain": 7, "impos": 7, "dure": [7, 18], "lane_change_max_braking_impos": 7, "linearvehicl": 7, "linear": [7, 8], "featur": [7, 12, 14, 15, 25], "differ": [7, 17, 23], "lead": [7, 23, 25], "target_lane_index": [7, 8], "rout": [7, 8, 16], "enable_lane_chang": 7, "timer": 7, "polici": [7, 21, 22, 24, 25], "nearbi": [7, 23], "place": [7, 8, 9, 23], "cartesian": [7, 8, 9], "surfac": [7, 8, 9, 26], "horizont": [7, 8, 9], "acc_max": 7, "term": [7, 25], "delta_rang": 7, "chosen": [7, 9, 18], "randomli": [7, 9], "create_from": [7, 8, 9], "controlledvehicl": [7, 8], "exist": [7, 8, 9, 21, 23], "one": [7, 8, 9, 18, 22], "copi": [7, 8, 9, 17, 21], "same": [7, 8, 9], "now": [7, 13, 21, 22, 23], "support": [7, 22], "becaus": [7, 17], "all": [7, 12, 17, 21, 23], "own": [7, 12, 22, 26], "increas": [7, 23, 26], "ego_vehicl": 7, "front_vehicl": 7, "rear_vehicl": 7, "command": [7, 8, 9], "reach": [7, 10, 14], "maintain": [7, 13], "safeti": 7, "w": [7, 18, 23, 25], "doe": [7, 17, 24], "why": 7, "reason": [7, 12, 17], "about": [7, 17, 24], "even": [7, 18], "though": 7, "mai": [7, 23, 25], "s2": [7, 8], "desired_gap": 7, "being": [7, 9, 25], "change_lane_polici": 7, "frequenc": [7, 17, 18, 21], "close": [7, 17, 18, 21], "more": [7, 10, 12, 13, 14, 15, 16, 17, 21], "unsaf": 7, "candid": 7, "recover_from_stop": 7, "wrong": 7, "revers": 7, "maneuv": 7, "suggest": [7, 17], "recov": 7, "stuck": 7, "data": [7, 21, 23], "resp": 7, "lower": [7, 21], "higher": 7, "steering_control": [7, 8], "overrid": 7, "wheel": [7, 8, 9], "steering_featur": 7, "collect": [7, 19, 23], "arrai": [7, 18, 22, 23], "collect_data": 7, "output": [7, 17], "regress": 7, "aggressivevehicl": 7, "defensivevehicl": 7, "call": [8, 10, 12, 13, 14, 15, 16, 17, 18, 21], "proport": 8, "k_p": 8, "v_r": 8, "refer": [8, 21], "kp_a": 8, "speed_control": 8, "deriv": 8, "combin": 8, "invert": 8, "those": [8, 24], "v_": [8, 25], "k_": 8, "delta_": 8, "psi_": 8, "arcsin": 8, "psi_r": 8, "psi_l": 8, "psi": [8, 9, 25], "_r": 8, "l": [8, 9, 18, 23], "variat": 8, "lookahead": 8, "anticip": 8, "turn": 8, "yaw": 8, "rate": 8, "pilot": 8, "high": [8, 10, 13, 14], "cascad": 8, "plan_route_to": 8, "destin": [8, 12, 23, 25], "updat": [8, 9, 18, 20, 22, 23], "follow_road": 8, "At": 8, "switch": 8, "next": [8, 12, 21, 23], "get_routes_at_intersect": 8, "set_route_at_intersect": 8, "_to": 8, "eras": 8, "predict_trajectory_constant_spe": 8, "futur": [8, 9], "along": [8, 18, 23], "under": 8, "constant": [8, 21, 23], "mdpvehicl": 8, "handl": [8, 16, 18], "choos": [8, 25], "els": [8, 23], "forward": [8, 9, 18], "handler": 8, "index_to_spe": 8, "among": 8, "speed_to_index": 8, "closest": [8, 23], "assum": [8, 23], "avoid": [8, 10, 12, 13, 15, 16, 25], "search": 8, "input": [8, 9, 18], "speed_to_index_default": 8, "predict_trajectori": [8, 9], "action_dur": [8, 9], "trajectory_timestep": [8, 9], "durat": [8, 9, 10, 12, 15, 16, 24], "save": [8, 9, 24], "co": [9, 25], "beta": 9, "sin": [9, 25], "tan": 9, "slip": 9, "graviti": 9, "These": [9, 21, 23], "calcul": 9, "appear": 9, "predition_typ": 9, "constant_st": 9, "modifi": [9, 21], "propag": 9, "depend": [9, 17, 20, 21], "length": [9, 18], "default_initial_spe": 9, "23": 9, "25": [9, 23], "max_spe": 9, "40": [9, 10, 24], "min_spe": 9, "history_s": 9, "30": [9, 10, 24], "histori": 9, "create_random": 9, "lane_from": 9, "lane_to": 9, "lane_id": 9, "behind": [9, 23], "last": [9, 21, 23], "densiti": 9, "spawn": 9, "id": [9, 21], "ratio": 9, "repeat": 9, "integr": 9, "1st": 9, "respons": 9, "crash": [9, 16], "overridden": 9, "errat": 9, "complet": 9, "task": [10, 12, 13, 14, 16, 21, 24], "multilan": 10, "popul": [10, 21], "reward": [10, 12, 13, 14, 17, 21, 22, 23, 24, 26], "lanes_count": [10, 24], "vehicles_count": [10, 12, 22, 23, 24], "50": [10, 18, 24], "initial_spac": 10, "collision_reward": [10, 12, 15, 24], "receiv": 10, "collid": [10, 23], "reward_speed_rang": [10, 24], "linearli": 10, "highwayenv": 10, "high_speed_reward": [10, 24], "simulation_frequ": [10, 13, 14, 15, 16, 18, 24], "hz": [10, 13, 16, 17], "policy_frequ": [10, 13, 14, 15, 16, 23, 24], "other_vehicles_typ": [10, 13, 16, 24], "screen_width": [10, 12, 13, 14, 15, 16, 18, 24], "600": [10, 12, 13, 14, 15, 16, 24], "px": [10, 13, 16, 18], "screen_height": [10, 12, 13, 14, 15, 16, 18, 24], "150": [10, 13, 24], "centering_posit": [10, 12, 13, 14, 15, 16, 18, 23, 24], "scale": [10, 12, 13, 14, 15, 16, 18, 23, 24, 25], "show_trajectori": [10, 13, 14, 15, 16, 24], "render_ag": [10, 13, 14, 15, 16, 24], "offscreen_rend": [10, 13, 14, 15, 16, 24], "specif": [10, 12, 13, 14, 15, 16, 18, 23], "default_config": [10, 12, 13, 14, 15, 16, 21], "overload": [10, 12, 13, 14, 15, 16, 21, 25], "x15": 10, "speedup": 10, "fast": [10, 16, 24], "detail": [10, 19], "here": [10, 17, 21, 22, 23, 24], "render_mod": [10, 12, 13, 14, 15, 16, 21, 22, 23, 24], "stai": [10, 23], "rightmost": 10, "merg": [11, 24], "roundabout": [11, 18, 24], "park": [11, 23, 24, 25], "racetrack": [11, 24], "negoti": [12, 13], "quit": 12, "hard": 12, "up": [12, 26], "good": 12, "decentr": 12, "Of": 12, "cours": 12, "could": [12, 22, 25], "achiev": [12, 14, 21], "sophist": 12, "schedul": 12, "light": 12, "keep": [12, 25], "thing": 12, "rudimentari": 12, "wa": [12, 14, 18], "ad": [12, 21], "sometim": 12, "fail": 12, "result": [12, 24], "block": 12, "figur": [12, 22, 23, 24], "fine": 12, "my": [12, 24], "purpos": [12, 19], "sinc": [12, 22, 23, 25], "did": [12, 21], "happen": 12, "too": 12, "often": [12, 25], "expect": [12, 23, 25], "simpli": 12, "wait": 12, "episod": [12, 17, 21, 22, 24, 25], "situat": 12, "But": 12, "agre": 12, "ideal": 12, "welcom": [12, 21], "ani": [12, 14, 21, 23, 25], "contribut": [12, 19], "matter": 12, "presenc": [12, 15], "vx": [12, 14, 23], "vy": [12, 14, 23], "cos_h": [12, 14, 23], "sin_h": [12, 14, 23], "features_rang": [12, 23], "100": [12, 14, 23], "absolut": [12, 23], "flatten": 12, "observe_intent": [12, 23], "13": [12, 23], "o1": 12, "initial_vehicle_count": 12, "spawn_prob": 12, "intersectionenv": [12, 22], "normalize_reward": [12, 24], "intersection_env": 12, "termin": [12, 21, 25], "truncat": [12, 16, 17, 21, 22, 23, 24], "info": [12, 14, 17, 21, 22, 23, 24], "soon": 13, "approach": [13, 16, 23], "junction": 13, "incom": 13, "ramp": 13, "room": 13, "timetocollis": [13, 16, 23], "mergeenv": 13, "merge_env": 13, "goal": [14, 24, 26], "condit": [14, 24], "continu": [14, 15, 18, 26], "appropri": [14, 25], "kinematicsgo": 14, "normal": [14, 23, 25], "300": [14, 15], "7": [14, 15], "parkingenv": 14, "parking_env": 14, "credit": [14, 15], "munir": 14, "jojo": 14, "verg": 14, "idea": [14, 15], "define_spac": [14, 21], "compute_reward": 14, "achieved_go": 14, "desired_go": 14, "proxim": 14, "we": [14, 17, 18, 20, 21, 23, 25], "norm": [14, 25], "lp": 14, "kurtosi": 14, "he": 15, "mani": [15, 18], "thank": [15, 18], "supperted825": 15, "occupancygrid": [15, 23], "on_road": 15, "grid_siz": [15, 23], "18": [15, 23], "grid_step": [15, 23], "as_imag": [15, 23], "align_to_vehicle_ax": [15, 23], "lane_centering_cost": 15, "action_reward": 15, "other_vehicl": 15, "racetrackenv": 15, "racetrack_env": 15, "need": [15, 17], "skill": 15, "see": [15, 17, 21, 22, 23, 24, 25], "http": [15, 18, 19, 20], "github": [15, 19, 20], "com": [15, 18, 19, 20], "eleur": [15, 19, 20, 22, 24], "issu": 15, "231": 15, "flow": 16, "pass": [16, 22, 23], "possibl": [16, 17, 25], "incoming_vehicle_destin": 16, "11": 16, "run": [16, 17, 21, 22, 24], "still": [16, 21], "hasn": 16, "express": 16, "variabl": 16, "equal": 16, "pygam": [16, 18, 20], "window": [16, 18], "height": 16, "smaller": 16, "southeast": 16, "area": [16, 18], "roundaboutenv": 16, "roundabout_env": 16, "feel": 17, "free": 17, "entri": 17, "probabl": 17, "you": [17, 19, 21, 23], "instal": [17, 18, 21], "instead": [17, 25], "work": 17, "repositori": [17, 19], "code": [17, 22], "regist": [17, 26], "register_highway_env": [17, 21], "tend": 17, "sub": 17, "pair": [17, 21, 23], "argu": 17, "inde": 17, "revisit": 17, "scene": [17, 23, 26], "reus": 17, "past": 17, "struggl": 17, "address": [17, 25], "permut": 17, "invari": [17, 25], "architectur": [17, 24], "sensit": 17, "exampl": [17, 21, 22], "dqn": [17, 22, 23, 24], "sb3": [17, 24], "ppo": 17, "grayscal": [17, 26], "imag": [17, 18, 21, 24, 26], "cnn": [17, 24], "suitabl": 17, "singl": [17, 21, 22, 25], "typic": 17, "long": 17, "render": [17, 18, 21, 22, 23, 24], "intermedi": [17, 21], "wrap": [17, 21, 26], "recordvideo": [17, 21], "wrapper": [17, 21], "video_fold": 17, "episode_trigg": 17, "lambda": 17, "send": [17, 22], "unwrap": 17, "set_record_video_wrapp": 17, "ob": [17, 21, 22, 23, 24], "Its": 18, "dimens": 18, "640": 18, "480": 18, "roadsurfac": 18, "locat": [18, 23], "zoom": 18, "By": 18, "offset": [18, 23], "roadgraph": 18, "vehiclegraph": 18, "envview": 18, "viewer": [18, 21], "set_agent_displai": 18, "agent_displai": 18, "callback": 18, "dedic": 18, "set_agent_action_sequ": 18, "handle_ev": 18, "event": 18, "get_imag": 18, "rgb": [18, 23], "channel": [18, 23], "convent": [18, 25], "h": [18, 23], "window_posit": 18, "worldsurfac": 18, "size": [18, 22, 23, 24], "flag": 18, "surf": 18, "pix": 18, "pixel": 18, "pos2pix": 18, "vec2pix": 18, "vec": 18, "is_vis": 18, "visibl": 18, "param": [18, 23], "test": [18, 24], "move_display_window_to": 18, "origin": 18, "lanegraph": 18, "visual": 18, "stripe_spac": 18, "33": 18, "stripe": 18, "stripe_length": 18, "stripe_width": 18, "striped_lin": 18, "stripes_count": 18, "draw": 18, "continuous_curv": 18, "continuous_lin": 18, "would": [18, 23, 25], "drawn": 18, "draw_strip": 18, "display_traff": 18, "offscreen": 18, "without": 18, "screen": 18, "display_road_object": 18, "roadobjectgraph": 18, "object_": 18, "transpar": 18, "color": 18, "rotat": 18, "rectangl": [18, 23], "slightli": 18, "blit_rot": 18, "po": 18, "origin_po": 18, "show_rect": 18, "stackoverflow": 18, "54714144": 18, "gather": 19, "quick": [19, 24], "guid": 19, "custom": 19, "nut": 19, "bolt": 19, "packag": 19, "pleas": 19, "piec": 19, "bibtex": 19, "misc": 19, "author": 19, "titl": [19, 22], "year": 19, "2018": 19, "publish": 19, "journal": 19, "howpublish": 19, "url": 19, "python3": 20, "graphic": [20, 26], "itself": 20, "manual": [20, 21, 26], "sudo": 20, "apt": 20, "python": [20, 21, 22], "dev": 20, "libsdl": 20, "image1": 20, "mixer1": 20, "ttf2": 20, "libsdl1": 20, "libsmpeg": 20, "numpi": 20, "subvers": 20, "libportmidi": 20, "ffmpeg": 20, "libswscal": 20, "libavformat": 20, "libavcodec": 20, "libfreetype6": 20, "gcc": 20, "recommend": 20, "anaconda": 20, "To": [20, 21, 22], "latest": 20, "pip": 20, "user": 20, "git": 20, "pull": 21, "request": 21, "your_env": 21, "py": [21, 22], "yourenv": 21, "inherit": 21, "function": [21, 24, 25], "choic": [21, 25], "_make_road": 21, "self": [21, 22], "field": [21, 22, 23], "action_typ": [21, 23, 24], "freeli": 21, "part": [21, 23], "config_kei": 21, "onc": 21, "other_valu": 21, "__init__": 21, "entry_point": 21, "registr": 21, "hook": 21, "reinstal": 21, "setup": 21, "altern": 21, "That": 21, "themselv": 21, "variou": 21, "involv": 21, "perception_dist": 21, "200": [21, 24], "present": 21, "_reward": [21, 25], "associ": 21, "multi": [21, 26], "vector": 21, "aggreg": 21, "scalar": 21, "insid": [21, 25], "reward_nam": 21, "reward_valu": 21, "_is_termin": 21, "check": [21, 23], "_is_trunc": 21, "_info": 21, "addit": 21, "seed": [21, 22, 24], "prng": 21, "_reset": 21, "_simul": 21, "Will": 21, "_automatic_rend": 21, "ongo": 21, "whole": 21, "video": [21, 22, 24], "been": [21, 22, 25], "captur": 21, "simplifi": 21, "distant": 21, "remov": 21, "meant": 21, "load": [21, 24], "preserv": 21, "optim": [21, 25], "change_vehicl": 21, "vehicle_class_path": 21, "path": [21, 22], "multiagentwrapp": 21, "obstyp": 21, "acttyp": 21, "modular": 21, "transform": 21, "overwritten": 21, "version": 22, "rgb_arrai": [22, 23, 24], "sake": 22, "visualis": 22, "matplotlib": [22, 23, 24], "pyplot": [22, 23, 24], "plt": [22, 23, 24], "inlin": [22, 23, 24], "imshow": [22, 23, 24], "green": 22, "show": [22, 23, 24], "640x480": [22, 23, 24], "ax": [22, 23, 24], "accept": 22, "standard": 22, "ax1": 22, "ax2": 22, "subplot": [22, 23], "nrow": 22, "set_titl": 22, "action_1": 22, "action_2": 22, "what": [22, 23], "As": 22, "far": 22, "multiagentobserv": 22, "observation_config": 22, "pprint": [22, 24], "90797305": 22, "3125": 22, "10906096": 22, "04341291": 22, "33000726": 22, "dtype": 22, "float32": 22, "pseudo": 22, "train": 22, "dummi": 22, "rl": [22, 24], "algorithm": 22, "transit": 22, "def": 22, "next_ob": 22, "dispatch": 22, "obs_i": 22, "action_i": 22, "next_obs_i": 22, "zip": 22, "cd": 22, "script": [22, 24], "evalu": 22, "env_multi_ag": 22, "dqnagent": 22, "ego_attention_2h": 22, "3000": 22, "27": 23, "observation_factori": 23, "kinematicobserv": 23, "f": 23, "v_y": [23, 25], "12": 23, "22": 23, "row": 23, "within": 23, "05": 23, "04": 23, "75": 23, "08": 23, "675": 23, "222": 23, "105": 23, "9": 23, "025": 23, "rel": 23, "except": 23, "075": 23, "172": 23, "065": 23, "fewer": 23, "placehold": 23, "fill": 23, "zero": 23, "detect": 23, "disambigu": 23, "radian": 23, "trigonometr": 23, "cos_d": 23, "sin_d": 23, "long_": 23, "off": 23, "lat_": 23, "ang_": 23, "angular": 23, "sort": 23, "print": 23, "2116441": 23, "07987082": 23, "40037498": 23, "14375238": 23, "5924493": 23, "14188124": 23, "81080985": 23, "17013432": 23, "12747008": 23, "08804176": 23, "11419602": 23, "13449906": 23, "19995664": 23, "grayscaleobserv": 23, "observation_shap": 23, "sum": 23, "stack_siz": 23, "customari": 23, "128": 23, "64": 23, "2989": 23, "5870": 23, "1140": 23, "fig": 23, "ncol": 23, "figsiz": 23, "enumer": 23, "flat": 23, "cmap": 23, "get_cmap": 23, "grai": 23, "1200x500": 23, "three": 23, "actions_index": [23, 24], "occupancygridobserv": 23, "shape": 23, "discretis": 23, "cell": 23, "resolut": 23, "like": 23, "timetocollisionobserv": 23, "hot": 23, "encod": 23, "over": 23, "bin": 23, "25m": 23, "infti": 23, "middl": 23, "bottom": 23, "horizon": 23, "lidarobserv": 23, "divid": 23, "sector": 23, "per": 23, "column": 23, "nearest": 23, "compon": 23, "south": 23, "west": 23, "meter": 23, "awai": 23, "toward": 23, "1m": 23, "maximum_rang": 23, "84": 23, "see_behind": 23, "include_obstacl": 23, "min": [23, 25], "max": [23, 25], "shuffl": 23, "normalize_ob": 23, "df": 23, "datafram": 23, "real": 23, "min_x": 23, "max_x": 23, "min_i": 23, "max_i": 23, "step_x": 23, "step_i": 23, "align": 23, "pos_to_index": 23, "otherwis": 23, "alreadi": 23, "fill_road_layer_by_lan": 23, "layer_index": 23, "lane_perception_dist": 23, "onroad": 23, "offroad": 23, "iter": 23, "regularli": 23, "waypoint": 23, "larg": 23, "small": 23, "fill_road_layer_by_cel": 23, "kinematicsgoalobserv": 23, "exitobserv": 23, "exit_env": 23, "exit": 23, "creation": 24, "ego_spac": 24, "initial_lane_id": 24, "lane_change_reward": 24, "offroad_termin": 24, "real_time_rend": 24, "right_lane_reward": 24, "vehicles_dens": 24, "effect": 24, "librari": 24, "openai": 24, "baselin": 24, "stabl": 24, "baselines3": 24, "mlp": 24, "stable_baselines3": 24, "mlppolici": 24, "policy_kwarg": 24, "net_arch": 24, "256": 24, "learning_r": 24, "5e": 24, "buffer_s": 24, "15000": 24, "learning_start": 24, "batch_siz": 24, "32": 24, "gamma": 24, "train_freq": 24, "gradient_step": 24, "target_update_interv": 24, "verbos": 24, "tensorboard_log": 24, "highway_dqn": 24, "2e4": 24, "_state": 24, "25mn": 24, "laptop": 24, "fp": 24, "14": 24, "better": 24, "vanilla": 24, "q": 24, "extens": 24, "doubl": 24, "duel": 24, "priorit": 24, "improv": 24, "faq": 24, "notebook": 24, "few": 24, "opd": 24, "tutori": 24, "written": 24, "rlss": 24, "demonstr": 24, "principl": 24, "her": 24, "cross": 24, "challeng": 25, "problem": 25, "particular": 25, "wish": 25, "aspect": 25, "straightforward": 25, "adequ": 25, "emerg": 25, "perspect": 25, "robust": 25, "against": 25, "uncertain": 25, "focu": 25, "progress": 25, "quickli": 25, "bound": 25, "shift": 25, "practic": 25, "benefici": 25, "forbid": 25, "neg": 25, "encourag": 25, "prefer": 25, "earli": 25, "caus": 25, "risk": 25, "suffer": 25, "satisfi": 25, "penalti": 25, "collision_penalti": 25, "replac": 25, "s_g": 25, "v_x": 25, "x_g": 25, "y_g": 25, "psi_g": 25, "sum_i": 25, "w_i": 25, "x_i": 25, "euclidean": 25, "narrow": 25, "spike": 25, "occup": 26, "grid": 26, "lidar": 26, "api": 26, "meta": 26, "your": 26, "file": 26, "profit": 26}, "objects": {"highway_env": [[21, 0, 0, "-", "__init__"]], "highway_env.__init__": [[21, 1, 1, "", "register_highway_envs"]], "highway_env.envs.common": [[21, 0, 0, "-", "abstract"], [1, 0, 0, "-", "action"], [18, 0, 0, "-", "graphics"], [23, 0, 0, "-", "observation"]], "highway_env.envs.common.abstract": [[21, 2, 1, "", "AbstractEnv"], [21, 2, 1, "", "MultiAgentWrapper"]], "highway_env.envs.common.abstract.AbstractEnv": [[21, 3, 1, "", "PERCEPTION_DISTANCE"], [21, 4, 1, "", "_automatic_rendering"], [21, 4, 1, "", "_info"], [21, 4, 1, "", "_is_terminated"], [21, 4, 1, "", "_is_truncated"], [21, 4, 1, "", "_reset"], [21, 4, 1, "", "_reward"], [21, 4, 1, "", "_rewards"], [21, 4, 1, "", "_simulate"], [21, 4, 1, "", "change_vehicles"], [21, 4, 1, "", "close"], [21, 4, 1, "", "default_config"], [21, 4, 1, "", "define_spaces"], [21, 4, 1, "", "render"], [21, 4, 1, "", "reset"], [21, 4, 1, "", "simplify"], [21, 4, 1, "", "step"], [21, 5, 1, "", "vehicle"]], "highway_env.envs.common.abstract.MultiAgentWrapper": [[21, 4, 1, "", "step"]], "highway_env.envs.common.action": [[1, 2, 1, "", "ActionType"], [1, 2, 1, "", "ContinuousAction"], [1, 2, 1, "", "DiscreteAction"], [1, 2, 1, "", "DiscreteMetaAction"], [1, 2, 1, "", "MultiAgentAction"]], "highway_env.envs.common.action.ActionType": [[1, 4, 1, "", "act"], [1, 5, 1, "", "controlled_vehicle"], [1, 4, 1, "", "get_available_actions"], [1, 4, 1, "", "space"], [1, 5, 1, "", "vehicle_class"]], "highway_env.envs.common.action.ContinuousAction": [[1, 3, 1, "", "ACCELERATION_RANGE"], [1, 3, 1, "", "STEERING_RANGE"], [1, 4, 1, "", "act"], [1, 4, 1, "", "space"], [1, 5, 1, "", "vehicle_class"]], "highway_env.envs.common.action.DiscreteAction": [[1, 4, 1, "", "act"], [1, 4, 1, "", "space"]], "highway_env.envs.common.action.DiscreteMetaAction": [[1, 3, 1, "", "ACTIONS_ALL"], [1, 3, 1, "", "ACTIONS_LAT"], [1, 3, 1, "", "ACTIONS_LONGI"], [1, 4, 1, "", "act"], [1, 4, 1, "", "get_available_actions"], [1, 4, 1, "", "space"], [1, 5, 1, "", "vehicle_class"]], "highway_env.envs.common.action.MultiAgentAction": [[1, 4, 1, "", "act"], [1, 4, 1, "", "get_available_actions"], [1, 4, 1, "", "space"], [1, 5, 1, "", "vehicle_class"]], "highway_env.envs.common.graphics": [[18, 2, 1, "", "EnvViewer"]], "highway_env.envs.common.graphics.EnvViewer": [[18, 4, 1, "", "close"], [18, 4, 1, "", "display"], [18, 4, 1, "", "get_image"], [18, 4, 1, "", "handle_events"], [18, 4, 1, "", "set_agent_action_sequence"], [18, 4, 1, "", "set_agent_display"], [18, 4, 1, "", "window_position"]], "highway_env.envs.common.observation": [[23, 2, 1, "", "ExitObservation"], [23, 2, 1, "", "GrayscaleObservation"], [23, 2, 1, "", "KinematicObservation"], [23, 2, 1, "", "KinematicsGoalObservation"], [23, 2, 1, "", "OccupancyGridObservation"]], "highway_env.envs.common.observation.ExitObservation": [[23, 4, 1, "", "observe"]], "highway_env.envs.common.observation.GrayscaleObservation": [[23, 4, 1, "", "observe"], [23, 4, 1, "", "space"]], "highway_env.envs.common.observation.KinematicObservation": [[23, 4, 1, "", "normalize_obs"], [23, 4, 1, "", "observe"], [23, 4, 1, "", "space"]], "highway_env.envs.common.observation.KinematicsGoalObservation": [[23, 4, 1, "", "observe"], [23, 4, 1, "", "space"]], "highway_env.envs.common.observation.OccupancyGridObservation": [[23, 4, 1, "", "fill_road_layer_by_cell"], [23, 4, 1, "", "fill_road_layer_by_lanes"], [23, 4, 1, "", "normalize"], [23, 4, 1, "", "observe"], [23, 4, 1, "", "pos_to_index"], [23, 4, 1, "", "space"]], "highway_env.envs.highway_env": [[10, 2, 1, "", "HighwayEnv"]], "highway_env.envs.highway_env.HighwayEnv": [[10, 4, 1, "", "default_config"]], "highway_env.envs.intersection_env": [[12, 2, 1, "", "IntersectionEnv"]], "highway_env.envs.intersection_env.IntersectionEnv": [[12, 4, 1, "", "default_config"], [12, 4, 1, "", "step"]], "highway_env.envs.merge_env": [[13, 2, 1, "", "MergeEnv"]], "highway_env.envs.merge_env.MergeEnv": [[13, 4, 1, "", "default_config"]], "highway_env.envs.parking_env": [[14, 2, 1, "", "ParkingEnv"]], "highway_env.envs.parking_env.ParkingEnv": [[14, 4, 1, "", "compute_reward"], [14, 4, 1, "", "default_config"], [14, 4, 1, "", "define_spaces"]], "highway_env.envs.racetrack_env": [[15, 2, 1, "", "RacetrackEnv"]], "highway_env.envs.racetrack_env.RacetrackEnv": [[15, 4, 1, "", "default_config"]], "highway_env.envs.roundabout_env": [[16, 2, 1, "", "RoundaboutEnv"]], "highway_env.envs.roundabout_env.RoundaboutEnv": [[16, 4, 1, "", "default_config"]], "highway_env.road": [[18, 0, 0, "-", "graphics"], [4, 0, 0, "-", "lane"], [5, 0, 0, "-", "regulation"], [6, 0, 0, "-", "road"]], "highway_env.road.graphics": [[18, 2, 1, "", "LaneGraphics"], [18, 2, 1, "", "RoadGraphics"], [18, 2, 1, "", "RoadObjectGraphics"], [18, 2, 1, "", "WorldSurface"]], "highway_env.road.graphics.LaneGraphics": [[18, 3, 1, "", "STRIPE_LENGTH"], [18, 3, 1, "", "STRIPE_SPACING"], [18, 3, 1, "", "STRIPE_WIDTH"], [18, 4, 1, "", "continuous_curve"], [18, 4, 1, "", "continuous_line"], [18, 4, 1, "", "display"], [18, 4, 1, "", "draw_stripes"], [18, 4, 1, "", "striped_line"]], "highway_env.road.graphics.RoadGraphics": [[18, 4, 1, "", "display"], [18, 4, 1, "", "display_road_objects"], [18, 4, 1, "", "display_traffic"]], "highway_env.road.graphics.RoadObjectGraphics": [[18, 4, 1, "", "blit_rotate"], [18, 4, 1, "", "display"]], "highway_env.road.graphics.WorldSurface": [[18, 4, 1, "", "handle_event"], [18, 4, 1, "", "is_visible"], [18, 4, 1, "", "move_display_window_to"], [18, 4, 1, "", "pix"], [18, 4, 1, "", "pos2pix"], [18, 4, 1, "", "vec2pix"]], "highway_env.road.lane": [[4, 2, 1, "", "AbstractLane"], [4, 2, 1, "", "CircularLane"], [4, 2, 1, "", "LineType"], [4, 2, 1, "", "PolyLane"], [4, 2, 1, "", "PolyLaneFixedWidth"], [4, 2, 1, "", "SineLane"], [4, 2, 1, "", "StraightLane"]], "highway_env.road.lane.AbstractLane": [[4, 4, 1, "", "distance"], [4, 4, 1, "", "distance_with_heading"], [4, 4, 1, "", "from_config"], [4, 4, 1, "", "heading_at"], [4, 4, 1, "", "is_reachable_from"], [4, 4, 1, "", "local_angle"], [4, 4, 1, "", "local_coordinates"], [4, 3, 1, "", "metaclass__"], [4, 4, 1, "", "on_lane"], [4, 4, 1, "", "position"], [4, 4, 1, "", "to_config"], [4, 4, 1, "", "width_at"]], "highway_env.road.lane.CircularLane": [[4, 4, 1, "", "from_config"], [4, 4, 1, "", "heading_at"], [4, 4, 1, "", "local_coordinates"], [4, 4, 1, "", "position"], [4, 4, 1, "", "to_config"], [4, 4, 1, "", "width_at"]], "highway_env.road.lane.PolyLane": [[4, 4, 1, "", "to_config"], [4, 4, 1, "", "width_at"]], "highway_env.road.lane.PolyLaneFixedWidth": [[4, 4, 1, "", "from_config"], [4, 4, 1, "", "heading_at"], [4, 4, 1, "", "local_coordinates"], [4, 4, 1, "", "position"], [4, 4, 1, "", "to_config"], [4, 4, 1, "", "width_at"]], "highway_env.road.lane.SineLane": [[4, 4, 1, "", "from_config"], [4, 4, 1, "", "heading_at"], [4, 4, 1, "", "local_coordinates"], [4, 4, 1, "", "position"], [4, 4, 1, "", "to_config"]], "highway_env.road.lane.StraightLane": [[4, 4, 1, "", "from_config"], [4, 4, 1, "", "heading_at"], [4, 4, 1, "", "local_coordinates"], [4, 4, 1, "", "position"], [4, 4, 1, "", "to_config"], [4, 4, 1, "", "width_at"]], "highway_env.road.regulation": [[5, 2, 1, "", "RegulatedRoad"]], "highway_env.road.regulation.RegulatedRoad": [[5, 4, 1, "", "enforce_road_rules"], [5, 4, 1, "", "respect_priorities"], [5, 4, 1, "", "step"]], "highway_env.road.road": [[6, 2, 1, "", "Road"]], "highway_env.road.road.Road": [[6, 4, 1, "", "act"], [6, 4, 1, "", "neighbour_vehicles"], [6, 4, 1, "", "step"]], "highway_env.vehicle": [[7, 0, 0, "-", "behavior"], [8, 0, 0, "-", "controller"], [18, 0, 0, "-", "graphics"], [9, 0, 0, "-", "kinematics"]], "highway_env.vehicle.behavior": [[7, 2, 1, "", "AggressiveVehicle"], [7, 2, 1, "", "DefensiveVehicle"], [7, 2, 1, "", "IDMVehicle"], [7, 2, 1, "", "LinearVehicle"]], "highway_env.vehicle.behavior.AggressiveVehicle": [[7, 3, 1, "", "target_speed"]], "highway_env.vehicle.behavior.DefensiveVehicle": [[7, 3, 1, "", "target_speed"]], "highway_env.vehicle.behavior.IDMVehicle": [[7, 3, 1, "", "ACC_MAX"], [7, 3, 1, "", "COMFORT_ACC_MAX"], [7, 3, 1, "", "COMFORT_ACC_MIN"], [7, 3, 1, "", "DELTA"], [7, 3, 1, "", "DELTA_RANGE"], [7, 3, 1, "", "DISTANCE_WANTED"], [7, 3, 1, "", "TIME_WANTED"], [7, 4, 1, "", "acceleration"], [7, 4, 1, "", "act"], [7, 4, 1, "", "change_lane_policy"], [7, 4, 1, "", "create_from"], [7, 4, 1, "", "desired_gap"], [7, 4, 1, "", "mobil"], [7, 4, 1, "", "recover_from_stop"], [7, 4, 1, "", "step"], [7, 3, 1, "", "target_speed"]], "highway_env.vehicle.behavior.LinearVehicle": [[7, 3, 1, "", "TIME_WANTED"], [7, 4, 1, "", "acceleration"], [7, 4, 1, "", "act"], [7, 4, 1, "", "collect_data"], [7, 4, 1, "", "steering_control"], [7, 4, 1, "", "steering_features"], [7, 3, 1, "", "target_speed"]], "highway_env.vehicle.controller": [[8, 2, 1, "", "ControlledVehicle"], [8, 2, 1, "", "MDPVehicle"]], "highway_env.vehicle.controller.ControlledVehicle": [[8, 4, 1, "", "act"], [8, 4, 1, "", "create_from"], [8, 4, 1, "", "follow_road"], [8, 4, 1, "", "get_routes_at_intersection"], [8, 4, 1, "", "plan_route_to"], [8, 4, 1, "", "predict_trajectory_constant_speed"], [8, 4, 1, "", "set_route_at_intersection"], [8, 4, 1, "", "speed_control"], [8, 4, 1, "", "steering_control"], [8, 3, 1, "", "target_speed"]], "highway_env.vehicle.controller.MDPVehicle": [[8, 4, 1, "", "act"], [8, 4, 1, "", "index_to_speed"], [8, 4, 1, "", "predict_trajectory"], [8, 4, 1, "", "speed_to_index"], [8, 4, 1, "", "speed_to_index_default"], [8, 3, 1, "", "target_speed"]], "highway_env.vehicle.kinematics": [[9, 2, 1, "", "Vehicle"]], "highway_env.vehicle.kinematics.Vehicle": [[9, 3, 1, "", "DEFAULT_INITIAL_SPEEDS"], [9, 3, 1, "", "HISTORY_SIZE"], [9, 3, 1, "", "LENGTH"], [9, 3, 1, "", "MAX_SPEED"], [9, 3, 1, "", "MIN_SPEED"], [9, 3, 1, "", "WIDTH"], [9, 4, 1, "", "act"], [9, 4, 1, "", "create_from"], [9, 4, 1, "", "create_random"], [9, 4, 1, "", "predict_trajectory"], [9, 4, 1, "", "step"]]}, "objtypes": {"0": "py:module", "1": "py:function", "2": "py:class", "3": "py:attribute", "4": "py:method", "5": "py:property"}, "objnames": {"0": ["py", "module", "Python module"], "1": ["py", "function", "Python function"], "2": ["py", "class", "Python class"], "3": ["py", "attribute", "Python attribute"], "4": ["py", "method", "Python method"], "5": ["py", "property", "Python property"]}, "titleterms": {"404": 0, "page": 0, "Not": 0, "found": 0, "action": [1, 22], "continu": 1, "discret": 1, "meta": 1, "manual": 1, "control": [1, 8, 22], "api": [1, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16, 18, 21, 23], "bibliographi": 2, "dynam": 3, "road": [3, 5, 6], "vehicl": [3, 21, 22, 23], "lane": 4, "regul": 5, "behavior": 7, "longitudin": [7, 8], "later": [7, 8], "posit": 8, "head": 8, "kinemat": [9, 17, 23], "highwai": [10, 17, 19], "usag": [10, 12, 13, 14, 15, 16], "default": [10, 12, 13, 14, 15, 16], "configur": [10, 12, 13, 14, 15, 16, 21, 23, 24], "faster": 10, "variant": 10, "The": [11, 22], "environ": [11, 17, 21, 24, 25], "intersect": 12, "merg": 13, "park": 14, "racetrack": 15, "roundabout": 16, "frequent": 17, "ask": 17, "question": 17, "when": 17, "i": [17, 23], "try": 17, "make": [17, 21, 24], "an": [17, 24], "get": [17, 24], "error": 17, "gymnasium": 17, "namenotfound": 17, "doesn": 17, "t": 17, "exist": 17, "train": [17, 24], "agent": [17, 22, 24], "us": 17, "observ": [17, 22, 23], "mlp": 17, "model": 17, "result": 17, "polici": 17, "optim": 17, "why": 17, "my": 17, "video": 17, "ar": 17, "too": 17, "fast": 17, "have": 17, "low": 17, "framer": 17, "graphic": 18, "world": 18, "surfac": 18, "scene": [18, 21], "welcom": 19, "env": 19, "": 19, "document": 19, "how": 19, "cite": 19, "thi": 19, "work": 19, "instal": 20, "prerequisit": 20, "ubuntu": 20, "window": 20, "10": 20, "stabl": 20, "releas": 20, "develop": 20, "version": 20, "your": 21, "own": 21, "set": [21, 22], "up": [21, 22], "file": 21, "creat": 21, "regist": 21, "profit": 21, "multi": 22, "increas": 22, "number": 22, "chang": 22, "space": 22, "wrap": 22, "exampl": [23, 24], "grayscal": 23, "imag": 23, "illustr": 23, "stack": 23, "mechan": 23, "occup": 23, "grid": 23, "presenc": 23, "featur": 23, "one": 23, "close": 23, "north": 23, "farther": 23, "east": 23, "v_x": 23, "drive": 23, "same": 23, "speed": 23, "ego": 23, "bit": 23, "slower": 23, "time": 23, "collis": 23, "lidar": 23, "start": 24, "all": 24, "googl": 24, "colab": 24, "reward": 25, "most": 25, "goal": 25, "user": 26, "guid": 26}, "envversion": {"sphinx.domains.c": 3, "sphinx.domains.changeset": 1, "sphinx.domains.citation": 1, "sphinx.domains.cpp": 9, "sphinx.domains.index": 1, "sphinx.domains.javascript": 3, "sphinx.domains.math": 2, "sphinx.domains.python": 4, "sphinx.domains.rst": 2, "sphinx.domains.std": 2, "sphinx.ext.viewcode": 1, "sphinxcontrib.bibtex": 9, "sphinx": 60}, "alltitles": {"404": [[0, "id1"]], "Page Not Found": [[0, "page-not-found"]], "Actions": [[1, "actions"]], "Continuous Actions": [[1, "continuous-actions"]], "Discrete Actions": [[1, "discrete-actions"]], "Discrete Meta-Actions": [[1, "discrete-meta-actions"]], "Manual control": [[1, "manual-control"]], "API": [[1, "module-highway_env.envs.common.action"], [4, "module-highway_env.road.lane"], [5, "module-highway_env.road.regulation"], [6, "module-highway_env.road.road"], [7, "module-highway_env.vehicle.behavior"], [8, "module-highway_env.vehicle.controller"], [9, "module-highway_env.vehicle.kinematics"], [10, "api"], [12, "api"], [13, "api"], [14, "api"], [15, "api"], [16, "api"], [18, "module-highway_env.envs.common.graphics"], [21, "module-highway_env.__init__"], [23, "module-highway_env.envs.common.observation"]], "Bibliography": [[2, "bibliography"]], "Dynamics": [[3, "dynamics"]], "Roads": [[3, "roads"]], "Vehicles": [[3, "vehicles"]], "Lane": [[4, "lane"]], "Road regulation": [[5, "road-regulation"]], "Road": [[6, "road"]], "Behavior": [[7, "behavior"]], "Longitudinal Behavior": [[7, "longitudinal-behavior"]], "Lateral Behavior": [[7, "lateral-behavior"]], "Control": [[8, "control"]], "Longitudinal controller": [[8, "longitudinal-controller"]], "Lateral controller": [[8, "lateral-controller"]], "Position control": [[8, "position-control"]], "Heading control": [[8, "heading-control"]], "Kinematics": [[9, "kinematics"], [23, "kinematics"]], "Highway": [[10, "highway"]], "Usage": [[10, "usage"], [12, "usage"], [13, "usage"], [14, "usage"], [15, "usage"], [16, "usage"]], "Default configuration": [[10, "default-configuration"], [12, "default-configuration"], [13, "default-configuration"], [14, "default-configuration"], [15, "default-configuration"], [16, "default-configuration"]], "Faster variant": [[10, "faster-variant"]], "The environments": [[11, "the-environments"]], "Intersection": [[12, "intersection"]], "Merge": [[13, "merge"]], "Parking": [[14, "parking"]], "Racetrack": [[15, "racetrack"]], "Roundabout": [[16, "roundabout"]], "Frequently Asked Questions": [[17, "frequently-asked-questions"]], "When I try to make an environment, I get an error gymnasium.error.NameNotFound: Environment highway doesn't exist.": [[17, "when-i-try-to-make-an-environment-i-get-an-error-gymnasium-error-namenotfound-environment-highway-doesn-t-exist"]], "I try to train an agent using the Kinematics Observation and an MLP model, but the resulting policy is not optimal. Why?": [[17, "i-try-to-train-an-agent-using-the-kinematics-observation-and-an-mlp-model-but-the-resulting-policy-is-not-optimal-why"]], "My videos are too fast / have a low framerate.": [[17, "my-videos-are-too-fast-have-a-low-framerate"]], "Graphics": [[18, "id1"]], "World surface": [[18, "world-surface"]], "Scene graphics": [[18, "scene-graphics"]], "Welcome to highway-env\u2019s documentation!": [[19, "welcome-to-highway-env-s-documentation"]], "How to cite this work?": [[19, "how-to-cite-this-work"]], "Installation": [[20, "installation"]], "Prerequisites": [[20, "prerequisites"]], "Ubuntu": [[20, "ubuntu"]], "Windows 10": [[20, "windows-10"]], "Stable release": [[20, "stable-release"]], "Development version": [[20, "development-version"]], "Make your own environment": [[21, "make-your-own-environment"]], "Set up files": [[21, "set-up-files"]], "Create the scene": [[21, "create-the-scene"]], "Create the vehicles": [[21, "create-the-vehicles"]], "Make the environment configurable": [[21, "make-the-environment-configurable"]], "Register the environment": [[21, "register-the-environment"]], "Profit": [[21, "profit"]], "The Multi-Agent setting": [[22, "the-multi-agent-setting"]], "Increase the number of controlled vehicles": [[22, "increase-the-number-of-controlled-vehicles"]], "Change the action space": [[22, "change-the-action-space"]], "Change the observation space": [[22, "change-the-observation-space"]], "Wrapping it up": [[22, "wrapping-it-up"]], "Observations": [[23, "id1"]], "Example configuration": [[23, "example-configuration"], [23, "grayscale-example-configuration"], [23, "id4"], [23, "id5"], [23, "id6"]], "Grayscale Image": [[23, "grayscale-image"]], "Illustration of the stack mechanism": [[23, "illustration-of-the-stack-mechanism"]], "Occupancy grid": [[23, "occupancy-grid"]], "presence feature: one vehicle is close to the north, and one is farther to the east.": [[23, "id7"]], "v_x feature: the north vehicle drives at the same speed as the ego-vehicle, and the east vehicle a bit slower": [[23, "id8"]], "Time to collision": [[23, "time-to-collision"]], "Lidar": [[23, "lidar"]], "the Lidar observation": [[23, "id9"]], "Getting Started": [[24, "getting-started"]], "Making an environment": [[24, "making-an-environment"]], "All the environments": [[24, "all-the-environments"]], "Configuring an environment": [[24, "configuring-an-environment"]], "Training an agent": [[24, "training-an-agent"]], "Examples on Google Colab": [[24, "examples-on-google-colab"]], "Rewards": [[25, "rewards"]], "Most environments": [[25, "most-environments"]], "Goal environments": [[25, "goal-environments"]], "User Guide": [[26, "user-guide"]]}, "indexentries": {"acceleration_range (highway_env.envs.common.action.continuousaction attribute)": [[1, "highway_env.envs.common.action.ContinuousAction.ACCELERATION_RANGE"]], "actions_all (highway_env.envs.common.action.discretemetaaction attribute)": [[1, "highway_env.envs.common.action.DiscreteMetaAction.ACTIONS_ALL"]], "actions_lat (highway_env.envs.common.action.discretemetaaction attribute)": [[1, "highway_env.envs.common.action.DiscreteMetaAction.ACTIONS_LAT"]], "actions_longi (highway_env.envs.common.action.discretemetaaction attribute)": [[1, "highway_env.envs.common.action.DiscreteMetaAction.ACTIONS_LONGI"]], "actiontype (class in highway_env.envs.common.action)": [[1, "highway_env.envs.common.action.ActionType"]], "continuousaction (class in highway_env.envs.common.action)": [[1, "highway_env.envs.common.action.ContinuousAction"]], "discreteaction (class in highway_env.envs.common.action)": [[1, "highway_env.envs.common.action.DiscreteAction"]], "discretemetaaction (class in highway_env.envs.common.action)": [[1, "highway_env.envs.common.action.DiscreteMetaAction"]], "multiagentaction (class in highway_env.envs.common.action)": [[1, "highway_env.envs.common.action.MultiAgentAction"]], "steering_range (highway_env.envs.common.action.continuousaction attribute)": [[1, "highway_env.envs.common.action.ContinuousAction.STEERING_RANGE"]], "act() (highway_env.envs.common.action.actiontype method)": [[1, "highway_env.envs.common.action.ActionType.act"]], "act() (highway_env.envs.common.action.continuousaction method)": [[1, "highway_env.envs.common.action.ContinuousAction.act"]], "act() (highway_env.envs.common.action.discreteaction method)": [[1, "highway_env.envs.common.action.DiscreteAction.act"]], "act() (highway_env.envs.common.action.discretemetaaction method)": [[1, "highway_env.envs.common.action.DiscreteMetaAction.act"]], "act() (highway_env.envs.common.action.multiagentaction method)": [[1, "highway_env.envs.common.action.MultiAgentAction.act"]], "controlled_vehicle (highway_env.envs.common.action.actiontype property)": [[1, "highway_env.envs.common.action.ActionType.controlled_vehicle"]], "get_available_actions() (highway_env.envs.common.action.actiontype method)": [[1, "highway_env.envs.common.action.ActionType.get_available_actions"]], "get_available_actions() (highway_env.envs.common.action.discretemetaaction method)": [[1, "highway_env.envs.common.action.DiscreteMetaAction.get_available_actions"]], "get_available_actions() (highway_env.envs.common.action.multiagentaction method)": [[1, "highway_env.envs.common.action.MultiAgentAction.get_available_actions"]], "highway_env.envs.common.action": [[1, "module-highway_env.envs.common.action"]], "module": [[1, "module-highway_env.envs.common.action"], [4, "module-highway_env.road.lane"], [5, "module-highway_env.road.regulation"], [6, "module-highway_env.road.road"], [7, "module-highway_env.vehicle.behavior"], [8, "module-highway_env.vehicle.controller"], [9, "module-highway_env.vehicle.kinematics"], [18, "module-highway_env.envs.common.graphics"], [18, "module-highway_env.road.graphics"], [18, "module-highway_env.vehicle.graphics"], [21, "module-highway_env.__init__"], [21, "module-highway_env.envs.common.abstract"], [23, "module-highway_env.envs.common.observation"]], "space() (highway_env.envs.common.action.actiontype method)": [[1, "highway_env.envs.common.action.ActionType.space"]], "space() (highway_env.envs.common.action.continuousaction method)": [[1, "highway_env.envs.common.action.ContinuousAction.space"]], "space() (highway_env.envs.common.action.discreteaction method)": [[1, "highway_env.envs.common.action.DiscreteAction.space"]], "space() (highway_env.envs.common.action.discretemetaaction method)": [[1, "highway_env.envs.common.action.DiscreteMetaAction.space"]], "space() (highway_env.envs.common.action.multiagentaction method)": [[1, "highway_env.envs.common.action.MultiAgentAction.space"]], "vehicle_class (highway_env.envs.common.action.actiontype property)": [[1, "highway_env.envs.common.action.ActionType.vehicle_class"]], "vehicle_class (highway_env.envs.common.action.continuousaction property)": [[1, "highway_env.envs.common.action.ContinuousAction.vehicle_class"]], "vehicle_class (highway_env.envs.common.action.discretemetaaction property)": [[1, "highway_env.envs.common.action.DiscreteMetaAction.vehicle_class"]], "vehicle_class (highway_env.envs.common.action.multiagentaction property)": [[1, "highway_env.envs.common.action.MultiAgentAction.vehicle_class"]], "abstractlane (class in highway_env.road.lane)": [[4, "highway_env.road.lane.AbstractLane"]], "circularlane (class in highway_env.road.lane)": [[4, "highway_env.road.lane.CircularLane"]], "linetype (class in highway_env.road.lane)": [[4, "highway_env.road.lane.LineType"]], "polylane (class in highway_env.road.lane)": [[4, "highway_env.road.lane.PolyLane"]], "polylanefixedwidth (class in highway_env.road.lane)": [[4, "highway_env.road.lane.PolyLaneFixedWidth"]], "sinelane (class in highway_env.road.lane)": [[4, "highway_env.road.lane.SineLane"]], "straightlane (class in highway_env.road.lane)": [[4, "highway_env.road.lane.StraightLane"]], "distance() (highway_env.road.lane.abstractlane method)": [[4, "highway_env.road.lane.AbstractLane.distance"]], "distance_with_heading() (highway_env.road.lane.abstractlane method)": [[4, "highway_env.road.lane.AbstractLane.distance_with_heading"]], "from_config() (highway_env.road.lane.abstractlane class method)": [[4, "highway_env.road.lane.AbstractLane.from_config"]], "from_config() (highway_env.road.lane.circularlane class method)": [[4, "highway_env.road.lane.CircularLane.from_config"]], "from_config() (highway_env.road.lane.polylanefixedwidth class method)": [[4, "highway_env.road.lane.PolyLaneFixedWidth.from_config"]], "from_config() (highway_env.road.lane.sinelane class method)": [[4, "highway_env.road.lane.SineLane.from_config"]], "from_config() (highway_env.road.lane.straightlane class method)": [[4, "highway_env.road.lane.StraightLane.from_config"]], "heading_at() (highway_env.road.lane.abstractlane method)": [[4, "highway_env.road.lane.AbstractLane.heading_at"]], "heading_at() (highway_env.road.lane.circularlane method)": [[4, "highway_env.road.lane.CircularLane.heading_at"]], "heading_at() (highway_env.road.lane.polylanefixedwidth method)": [[4, "highway_env.road.lane.PolyLaneFixedWidth.heading_at"]], "heading_at() (highway_env.road.lane.sinelane method)": [[4, "highway_env.road.lane.SineLane.heading_at"]], "heading_at() (highway_env.road.lane.straightlane method)": [[4, "highway_env.road.lane.StraightLane.heading_at"]], "highway_env.road.lane": [[4, "module-highway_env.road.lane"]], "is_reachable_from() (highway_env.road.lane.abstractlane method)": [[4, "highway_env.road.lane.AbstractLane.is_reachable_from"]], "local_angle() (highway_env.road.lane.abstractlane method)": [[4, "highway_env.road.lane.AbstractLane.local_angle"]], "local_coordinates() (highway_env.road.lane.abstractlane method)": [[4, "highway_env.road.lane.AbstractLane.local_coordinates"]], "local_coordinates() (highway_env.road.lane.circularlane method)": [[4, "highway_env.road.lane.CircularLane.local_coordinates"]], "local_coordinates() (highway_env.road.lane.polylanefixedwidth method)": [[4, "highway_env.road.lane.PolyLaneFixedWidth.local_coordinates"]], "local_coordinates() (highway_env.road.lane.sinelane method)": [[4, "highway_env.road.lane.SineLane.local_coordinates"]], "local_coordinates() (highway_env.road.lane.straightlane method)": [[4, "highway_env.road.lane.StraightLane.local_coordinates"]], "metaclass__ (highway_env.road.lane.abstractlane attribute)": [[4, "highway_env.road.lane.AbstractLane.metaclass__"]], "on_lane() (highway_env.road.lane.abstractlane method)": [[4, "highway_env.road.lane.AbstractLane.on_lane"]], "position() (highway_env.road.lane.abstractlane method)": [[4, "highway_env.road.lane.AbstractLane.position"]], "position() (highway_env.road.lane.circularlane method)": [[4, "highway_env.road.lane.CircularLane.position"]], "position() (highway_env.road.lane.polylanefixedwidth method)": [[4, "highway_env.road.lane.PolyLaneFixedWidth.position"]], "position() (highway_env.road.lane.sinelane method)": [[4, "highway_env.road.lane.SineLane.position"]], "position() (highway_env.road.lane.straightlane method)": [[4, "highway_env.road.lane.StraightLane.position"]], "to_config() (highway_env.road.lane.abstractlane method)": [[4, "highway_env.road.lane.AbstractLane.to_config"]], "to_config() (highway_env.road.lane.circularlane method)": [[4, "highway_env.road.lane.CircularLane.to_config"]], "to_config() (highway_env.road.lane.polylane method)": [[4, "highway_env.road.lane.PolyLane.to_config"]], "to_config() (highway_env.road.lane.polylanefixedwidth method)": [[4, "highway_env.road.lane.PolyLaneFixedWidth.to_config"]], "to_config() (highway_env.road.lane.sinelane method)": [[4, "highway_env.road.lane.SineLane.to_config"]], "to_config() (highway_env.road.lane.straightlane method)": [[4, "highway_env.road.lane.StraightLane.to_config"]], "width_at() (highway_env.road.lane.abstractlane method)": [[4, "highway_env.road.lane.AbstractLane.width_at"]], "width_at() (highway_env.road.lane.circularlane method)": [[4, "highway_env.road.lane.CircularLane.width_at"]], "width_at() (highway_env.road.lane.polylane method)": [[4, "highway_env.road.lane.PolyLane.width_at"]], "width_at() (highway_env.road.lane.polylanefixedwidth method)": [[4, "highway_env.road.lane.PolyLaneFixedWidth.width_at"]], "width_at() (highway_env.road.lane.straightlane method)": [[4, "highway_env.road.lane.StraightLane.width_at"]], "regulatedroad (class in highway_env.road.regulation)": [[5, "highway_env.road.regulation.RegulatedRoad"]], "enforce_road_rules() (highway_env.road.regulation.regulatedroad method)": [[5, "highway_env.road.regulation.RegulatedRoad.enforce_road_rules"]], "highway_env.road.regulation": [[5, "module-highway_env.road.regulation"]], "respect_priorities() (highway_env.road.regulation.regulatedroad static method)": [[5, "highway_env.road.regulation.RegulatedRoad.respect_priorities"]], "step() (highway_env.road.regulation.regulatedroad method)": [[5, "highway_env.road.regulation.RegulatedRoad.step"]], "road (class in highway_env.road.road)": [[6, "highway_env.road.road.Road"]], "act() (highway_env.road.road.road method)": [[6, "highway_env.road.road.Road.act"]], "highway_env.road.road": [[6, "module-highway_env.road.road"]], "neighbour_vehicles() (highway_env.road.road.road method)": [[6, "highway_env.road.road.Road.neighbour_vehicles"]], "step() (highway_env.road.road.road method)": [[6, "highway_env.road.road.Road.step"]], "acc_max (highway_env.vehicle.behavior.idmvehicle attribute)": [[7, "highway_env.vehicle.behavior.IDMVehicle.ACC_MAX"]], "aggressivevehicle (class in highway_env.vehicle.behavior)": [[7, "highway_env.vehicle.behavior.AggressiveVehicle"]], "comfort_acc_max (highway_env.vehicle.behavior.idmvehicle attribute)": [[7, "highway_env.vehicle.behavior.IDMVehicle.COMFORT_ACC_MAX"]], "comfort_acc_min (highway_env.vehicle.behavior.idmvehicle attribute)": [[7, "highway_env.vehicle.behavior.IDMVehicle.COMFORT_ACC_MIN"]], "delta (highway_env.vehicle.behavior.idmvehicle attribute)": [[7, "highway_env.vehicle.behavior.IDMVehicle.DELTA"]], "delta_range (highway_env.vehicle.behavior.idmvehicle attribute)": [[7, "highway_env.vehicle.behavior.IDMVehicle.DELTA_RANGE"]], "distance_wanted (highway_env.vehicle.behavior.idmvehicle attribute)": [[7, "highway_env.vehicle.behavior.IDMVehicle.DISTANCE_WANTED"]], "defensivevehicle (class in highway_env.vehicle.behavior)": [[7, "highway_env.vehicle.behavior.DefensiveVehicle"]], "idmvehicle (class in highway_env.vehicle.behavior)": [[7, "highway_env.vehicle.behavior.IDMVehicle"]], "linearvehicle (class in highway_env.vehicle.behavior)": [[7, "highway_env.vehicle.behavior.LinearVehicle"]], "time_wanted (highway_env.vehicle.behavior.idmvehicle attribute)": [[7, "highway_env.vehicle.behavior.IDMVehicle.TIME_WANTED"]], "time_wanted (highway_env.vehicle.behavior.linearvehicle attribute)": [[7, "highway_env.vehicle.behavior.LinearVehicle.TIME_WANTED"]], "acceleration() (highway_env.vehicle.behavior.idmvehicle method)": [[7, "highway_env.vehicle.behavior.IDMVehicle.acceleration"]], "acceleration() (highway_env.vehicle.behavior.linearvehicle method)": [[7, "highway_env.vehicle.behavior.LinearVehicle.acceleration"]], "act() (highway_env.vehicle.behavior.idmvehicle method)": [[7, "highway_env.vehicle.behavior.IDMVehicle.act"]], "act() (highway_env.vehicle.behavior.linearvehicle method)": [[7, "highway_env.vehicle.behavior.LinearVehicle.act"]], "change_lane_policy() (highway_env.vehicle.behavior.idmvehicle method)": [[7, "highway_env.vehicle.behavior.IDMVehicle.change_lane_policy"]], "collect_data() (highway_env.vehicle.behavior.linearvehicle method)": [[7, "highway_env.vehicle.behavior.LinearVehicle.collect_data"]], "create_from() (highway_env.vehicle.behavior.idmvehicle class method)": [[7, "highway_env.vehicle.behavior.IDMVehicle.create_from"]], "desired_gap() (highway_env.vehicle.behavior.idmvehicle method)": [[7, "highway_env.vehicle.behavior.IDMVehicle.desired_gap"]], "highway_env.vehicle.behavior": [[7, "module-highway_env.vehicle.behavior"]], "mobil() (highway_env.vehicle.behavior.idmvehicle method)": [[7, "highway_env.vehicle.behavior.IDMVehicle.mobil"]], "recover_from_stop() (highway_env.vehicle.behavior.idmvehicle method)": [[7, "highway_env.vehicle.behavior.IDMVehicle.recover_from_stop"]], "steering_control() (highway_env.vehicle.behavior.linearvehicle method)": [[7, "highway_env.vehicle.behavior.LinearVehicle.steering_control"]], "steering_features() (highway_env.vehicle.behavior.linearvehicle method)": [[7, "highway_env.vehicle.behavior.LinearVehicle.steering_features"]], "step() (highway_env.vehicle.behavior.idmvehicle method)": [[7, "highway_env.vehicle.behavior.IDMVehicle.step"]], "target_speed (highway_env.vehicle.behavior.aggressivevehicle attribute)": [[7, "highway_env.vehicle.behavior.AggressiveVehicle.target_speed"]], "target_speed (highway_env.vehicle.behavior.defensivevehicle attribute)": [[7, "highway_env.vehicle.behavior.DefensiveVehicle.target_speed"]], "target_speed (highway_env.vehicle.behavior.idmvehicle attribute)": [[7, "highway_env.vehicle.behavior.IDMVehicle.target_speed"]], "target_speed (highway_env.vehicle.behavior.linearvehicle attribute)": [[7, "highway_env.vehicle.behavior.LinearVehicle.target_speed"]], "controlledvehicle (class in highway_env.vehicle.controller)": [[8, "highway_env.vehicle.controller.ControlledVehicle"]], "mdpvehicle (class in highway_env.vehicle.controller)": [[8, "highway_env.vehicle.controller.MDPVehicle"]], "act() (highway_env.vehicle.controller.controlledvehicle method)": [[8, "highway_env.vehicle.controller.ControlledVehicle.act"]], "act() (highway_env.vehicle.controller.mdpvehicle method)": [[8, "highway_env.vehicle.controller.MDPVehicle.act"]], "create_from() (highway_env.vehicle.controller.controlledvehicle class method)": [[8, "highway_env.vehicle.controller.ControlledVehicle.create_from"]], "follow_road() (highway_env.vehicle.controller.controlledvehicle method)": [[8, "highway_env.vehicle.controller.ControlledVehicle.follow_road"]], "get_routes_at_intersection() (highway_env.vehicle.controller.controlledvehicle method)": [[8, "highway_env.vehicle.controller.ControlledVehicle.get_routes_at_intersection"]], "highway_env.vehicle.controller": [[8, "module-highway_env.vehicle.controller"]], "index_to_speed() (highway_env.vehicle.controller.mdpvehicle method)": [[8, "highway_env.vehicle.controller.MDPVehicle.index_to_speed"]], "plan_route_to() (highway_env.vehicle.controller.controlledvehicle method)": [[8, "highway_env.vehicle.controller.ControlledVehicle.plan_route_to"]], "predict_trajectory() (highway_env.vehicle.controller.mdpvehicle method)": [[8, "highway_env.vehicle.controller.MDPVehicle.predict_trajectory"]], "predict_trajectory_constant_speed() (highway_env.vehicle.controller.controlledvehicle method)": [[8, "highway_env.vehicle.controller.ControlledVehicle.predict_trajectory_constant_speed"]], "set_route_at_intersection() (highway_env.vehicle.controller.controlledvehicle method)": [[8, "highway_env.vehicle.controller.ControlledVehicle.set_route_at_intersection"]], "speed_control() (highway_env.vehicle.controller.controlledvehicle method)": [[8, "highway_env.vehicle.controller.ControlledVehicle.speed_control"]], "speed_to_index() (highway_env.vehicle.controller.mdpvehicle method)": [[8, "highway_env.vehicle.controller.MDPVehicle.speed_to_index"]], "speed_to_index_default() (highway_env.vehicle.controller.mdpvehicle class method)": [[8, "highway_env.vehicle.controller.MDPVehicle.speed_to_index_default"]], "steering_control() (highway_env.vehicle.controller.controlledvehicle method)": [[8, "highway_env.vehicle.controller.ControlledVehicle.steering_control"]], "target_speed (highway_env.vehicle.controller.controlledvehicle attribute)": [[8, "highway_env.vehicle.controller.ControlledVehicle.target_speed"]], "target_speed (highway_env.vehicle.controller.mdpvehicle attribute)": [[8, "highway_env.vehicle.controller.MDPVehicle.target_speed"]], "default_initial_speeds (highway_env.vehicle.kinematics.vehicle attribute)": [[9, "highway_env.vehicle.kinematics.Vehicle.DEFAULT_INITIAL_SPEEDS"]], "history_size (highway_env.vehicle.kinematics.vehicle attribute)": [[9, "highway_env.vehicle.kinematics.Vehicle.HISTORY_SIZE"]], "length (highway_env.vehicle.kinematics.vehicle attribute)": [[9, "highway_env.vehicle.kinematics.Vehicle.LENGTH"]], "max_speed (highway_env.vehicle.kinematics.vehicle attribute)": [[9, "highway_env.vehicle.kinematics.Vehicle.MAX_SPEED"]], "min_speed (highway_env.vehicle.kinematics.vehicle attribute)": [[9, "highway_env.vehicle.kinematics.Vehicle.MIN_SPEED"]], "vehicle (class in highway_env.vehicle.kinematics)": [[9, "highway_env.vehicle.kinematics.Vehicle"]], "width (highway_env.vehicle.kinematics.vehicle attribute)": [[9, "highway_env.vehicle.kinematics.Vehicle.WIDTH"]], "act() (highway_env.vehicle.kinematics.vehicle method)": [[9, "highway_env.vehicle.kinematics.Vehicle.act"]], "create_from() (highway_env.vehicle.kinematics.vehicle class method)": [[9, "highway_env.vehicle.kinematics.Vehicle.create_from"]], "create_random() (highway_env.vehicle.kinematics.vehicle class method)": [[9, "highway_env.vehicle.kinematics.Vehicle.create_random"]], "highway_env.vehicle.kinematics": [[9, "module-highway_env.vehicle.kinematics"]], "predict_trajectory() (highway_env.vehicle.kinematics.vehicle method)": [[9, "highway_env.vehicle.kinematics.Vehicle.predict_trajectory"]], "step() (highway_env.vehicle.kinematics.vehicle method)": [[9, "highway_env.vehicle.kinematics.Vehicle.step"]], "highwayenv (class in highway_env.envs.highway_env)": [[10, "highway_env.envs.highway_env.HighwayEnv"]], "default_config() (highway_env.envs.highway_env.highwayenv class method)": [[10, "highway_env.envs.highway_env.HighwayEnv.default_config"]], "intersectionenv (class in highway_env.envs.intersection_env)": [[12, "highway_env.envs.intersection_env.IntersectionEnv"]], "default_config() (highway_env.envs.intersection_env.intersectionenv class method)": [[12, "highway_env.envs.intersection_env.IntersectionEnv.default_config"]], "step() (highway_env.envs.intersection_env.intersectionenv method)": [[12, "highway_env.envs.intersection_env.IntersectionEnv.step"]], "mergeenv (class in highway_env.envs.merge_env)": [[13, "highway_env.envs.merge_env.MergeEnv"]], "default_config() (highway_env.envs.merge_env.mergeenv class method)": [[13, "highway_env.envs.merge_env.MergeEnv.default_config"]], "parkingenv (class in highway_env.envs.parking_env)": [[14, "highway_env.envs.parking_env.ParkingEnv"]], "compute_reward() (highway_env.envs.parking_env.parkingenv method)": [[14, "highway_env.envs.parking_env.ParkingEnv.compute_reward"]], "default_config() (highway_env.envs.parking_env.parkingenv class method)": [[14, "highway_env.envs.parking_env.ParkingEnv.default_config"]], "define_spaces() (highway_env.envs.parking_env.parkingenv method)": [[14, "highway_env.envs.parking_env.ParkingEnv.define_spaces"]], "racetrackenv (class in highway_env.envs.racetrack_env)": [[15, "highway_env.envs.racetrack_env.RacetrackEnv"]], "default_config() (highway_env.envs.racetrack_env.racetrackenv class method)": [[15, "highway_env.envs.racetrack_env.RacetrackEnv.default_config"]], "roundaboutenv (class in highway_env.envs.roundabout_env)": [[16, "highway_env.envs.roundabout_env.RoundaboutEnv"]], "default_config() (highway_env.envs.roundabout_env.roundaboutenv class method)": [[16, "highway_env.envs.roundabout_env.RoundaboutEnv.default_config"]], "envviewer (class in highway_env.envs.common.graphics)": [[18, "highway_env.envs.common.graphics.EnvViewer"]], "lanegraphics (class in highway_env.road.graphics)": [[18, "highway_env.road.graphics.LaneGraphics"]], "roadgraphics (class in highway_env.road.graphics)": [[18, "highway_env.road.graphics.RoadGraphics"]], "roadobjectgraphics (class in highway_env.road.graphics)": [[18, "highway_env.road.graphics.RoadObjectGraphics"]], "stripe_length (highway_env.road.graphics.lanegraphics attribute)": [[18, "highway_env.road.graphics.LaneGraphics.STRIPE_LENGTH"]], "stripe_spacing (highway_env.road.graphics.lanegraphics attribute)": [[18, "highway_env.road.graphics.LaneGraphics.STRIPE_SPACING"]], "stripe_width (highway_env.road.graphics.lanegraphics attribute)": [[18, "highway_env.road.graphics.LaneGraphics.STRIPE_WIDTH"]], "worldsurface (class in highway_env.road.graphics)": [[18, "highway_env.road.graphics.WorldSurface"]], "blit_rotate() (highway_env.road.graphics.roadobjectgraphics static method)": [[18, "highway_env.road.graphics.RoadObjectGraphics.blit_rotate"]], "close() (highway_env.envs.common.graphics.envviewer method)": [[18, "highway_env.envs.common.graphics.EnvViewer.close"]], "continuous_curve() (highway_env.road.graphics.lanegraphics class method)": [[18, "highway_env.road.graphics.LaneGraphics.continuous_curve"]], "continuous_line() (highway_env.road.graphics.lanegraphics class method)": [[18, "highway_env.road.graphics.LaneGraphics.continuous_line"]], "display() (highway_env.envs.common.graphics.envviewer method)": [[18, "highway_env.envs.common.graphics.EnvViewer.display"]], "display() (highway_env.road.graphics.lanegraphics class method)": [[18, "highway_env.road.graphics.LaneGraphics.display"]], "display() (highway_env.road.graphics.roadgraphics static method)": [[18, "highway_env.road.graphics.RoadGraphics.display"]], "display() (highway_env.road.graphics.roadobjectgraphics class method)": [[18, "highway_env.road.graphics.RoadObjectGraphics.display"]], "display_road_objects() (highway_env.road.graphics.roadgraphics static method)": [[18, "highway_env.road.graphics.RoadGraphics.display_road_objects"]], "display_traffic() (highway_env.road.graphics.roadgraphics static method)": [[18, "highway_env.road.graphics.RoadGraphics.display_traffic"]], "draw_stripes() (highway_env.road.graphics.lanegraphics class method)": [[18, "highway_env.road.graphics.LaneGraphics.draw_stripes"]], "get_image() (highway_env.envs.common.graphics.envviewer method)": [[18, "highway_env.envs.common.graphics.EnvViewer.get_image"]], "handle_event() (highway_env.road.graphics.worldsurface method)": [[18, "highway_env.road.graphics.WorldSurface.handle_event"]], "handle_events() (highway_env.envs.common.graphics.envviewer method)": [[18, "highway_env.envs.common.graphics.EnvViewer.handle_events"]], "highway_env.envs.common.graphics": [[18, "module-highway_env.envs.common.graphics"]], "highway_env.road.graphics": [[18, "module-highway_env.road.graphics"]], "highway_env.vehicle.graphics": [[18, "module-highway_env.vehicle.graphics"]], "is_visible() (highway_env.road.graphics.worldsurface method)": [[18, "highway_env.road.graphics.WorldSurface.is_visible"]], "move_display_window_to() (highway_env.road.graphics.worldsurface method)": [[18, "highway_env.road.graphics.WorldSurface.move_display_window_to"]], "pix() (highway_env.road.graphics.worldsurface method)": [[18, "highway_env.road.graphics.WorldSurface.pix"]], "pos2pix() (highway_env.road.graphics.worldsurface method)": [[18, "highway_env.road.graphics.WorldSurface.pos2pix"]], "set_agent_action_sequence() (highway_env.envs.common.graphics.envviewer method)": [[18, "highway_env.envs.common.graphics.EnvViewer.set_agent_action_sequence"]], "set_agent_display() (highway_env.envs.common.graphics.envviewer method)": [[18, "highway_env.envs.common.graphics.EnvViewer.set_agent_display"]], "striped_line() (highway_env.road.graphics.lanegraphics class method)": [[18, "highway_env.road.graphics.LaneGraphics.striped_line"]], "vec2pix() (highway_env.road.graphics.worldsurface method)": [[18, "highway_env.road.graphics.WorldSurface.vec2pix"]], "window_position() (highway_env.envs.common.graphics.envviewer method)": [[18, "highway_env.envs.common.graphics.EnvViewer.window_position"]], "abstractenv (class in highway_env.envs.common.abstract)": [[21, "highway_env.envs.common.abstract.AbstractEnv"]], "multiagentwrapper (class in highway_env.envs.common.abstract)": [[21, "highway_env.envs.common.abstract.MultiAgentWrapper"]], "perception_distance (highway_env.envs.common.abstract.abstractenv attribute)": [[21, "highway_env.envs.common.abstract.AbstractEnv.PERCEPTION_DISTANCE"]], "_automatic_rendering() (highway_env.envs.common.abstract.abstractenv method)": [[21, "highway_env.envs.common.abstract.AbstractEnv._automatic_rendering"]], "_info() (highway_env.envs.common.abstract.abstractenv method)": [[21, "highway_env.envs.common.abstract.AbstractEnv._info"]], "_is_terminated() (highway_env.envs.common.abstract.abstractenv method)": [[21, "highway_env.envs.common.abstract.AbstractEnv._is_terminated"]], "_is_truncated() (highway_env.envs.common.abstract.abstractenv method)": [[21, "highway_env.envs.common.abstract.AbstractEnv._is_truncated"]], "_reset() (highway_env.envs.common.abstract.abstractenv method)": [[21, "highway_env.envs.common.abstract.AbstractEnv._reset"]], "_reward() (highway_env.envs.common.abstract.abstractenv method)": [[21, "highway_env.envs.common.abstract.AbstractEnv._reward"]], "_rewards() (highway_env.envs.common.abstract.abstractenv method)": [[21, "highway_env.envs.common.abstract.AbstractEnv._rewards"]], "_simulate() (highway_env.envs.common.abstract.abstractenv method)": [[21, "highway_env.envs.common.abstract.AbstractEnv._simulate"]], "change_vehicles() (highway_env.envs.common.abstract.abstractenv method)": [[21, "highway_env.envs.common.abstract.AbstractEnv.change_vehicles"]], "close() (highway_env.envs.common.abstract.abstractenv method)": [[21, "highway_env.envs.common.abstract.AbstractEnv.close"]], "default_config() (highway_env.envs.common.abstract.abstractenv class method)": [[21, "highway_env.envs.common.abstract.AbstractEnv.default_config"]], "define_spaces() (highway_env.envs.common.abstract.abstractenv method)": [[21, "highway_env.envs.common.abstract.AbstractEnv.define_spaces"]], "highway_env.__init__": [[21, "module-highway_env.__init__"]], "highway_env.envs.common.abstract": [[21, "module-highway_env.envs.common.abstract"]], "register_highway_envs() (in module highway_env.__init__)": [[21, "highway_env.__init__.register_highway_envs"]], "render() (highway_env.envs.common.abstract.abstractenv method)": [[21, "highway_env.envs.common.abstract.AbstractEnv.render"]], "reset() (highway_env.envs.common.abstract.abstractenv method)": [[21, "highway_env.envs.common.abstract.AbstractEnv.reset"]], "simplify() (highway_env.envs.common.abstract.abstractenv method)": [[21, "highway_env.envs.common.abstract.AbstractEnv.simplify"]], "step() (highway_env.envs.common.abstract.abstractenv method)": [[21, "highway_env.envs.common.abstract.AbstractEnv.step"]], "step() (highway_env.envs.common.abstract.multiagentwrapper method)": [[21, "highway_env.envs.common.abstract.MultiAgentWrapper.step"]], "vehicle (highway_env.envs.common.abstract.abstractenv property)": [[21, "highway_env.envs.common.abstract.AbstractEnv.vehicle"]], "exitobservation (class in highway_env.envs.common.observation)": [[23, "highway_env.envs.common.observation.ExitObservation"]], "grayscaleobservation (class in highway_env.envs.common.observation)": [[23, "highway_env.envs.common.observation.GrayscaleObservation"]], "kinematicobservation (class in highway_env.envs.common.observation)": [[23, "highway_env.envs.common.observation.KinematicObservation"]], "kinematicsgoalobservation (class in highway_env.envs.common.observation)": [[23, "highway_env.envs.common.observation.KinematicsGoalObservation"]], "occupancygridobservation (class in highway_env.envs.common.observation)": [[23, "highway_env.envs.common.observation.OccupancyGridObservation"]], "fill_road_layer_by_cell() (highway_env.envs.common.observation.occupancygridobservation method)": [[23, "highway_env.envs.common.observation.OccupancyGridObservation.fill_road_layer_by_cell"]], "fill_road_layer_by_lanes() (highway_env.envs.common.observation.occupancygridobservation method)": [[23, "highway_env.envs.common.observation.OccupancyGridObservation.fill_road_layer_by_lanes"]], "highway_env.envs.common.observation": [[23, "module-highway_env.envs.common.observation"]], "normalize() (highway_env.envs.common.observation.occupancygridobservation method)": [[23, "highway_env.envs.common.observation.OccupancyGridObservation.normalize"]], "normalize_obs() (highway_env.envs.common.observation.kinematicobservation method)": [[23, "highway_env.envs.common.observation.KinematicObservation.normalize_obs"]], "observe() (highway_env.envs.common.observation.exitobservation method)": [[23, "highway_env.envs.common.observation.ExitObservation.observe"]], "observe() (highway_env.envs.common.observation.grayscaleobservation method)": [[23, "highway_env.envs.common.observation.GrayscaleObservation.observe"]], "observe() (highway_env.envs.common.observation.kinematicobservation method)": [[23, "highway_env.envs.common.observation.KinematicObservation.observe"]], "observe() (highway_env.envs.common.observation.kinematicsgoalobservation method)": [[23, "highway_env.envs.common.observation.KinematicsGoalObservation.observe"]], "observe() (highway_env.envs.common.observation.occupancygridobservation method)": [[23, "highway_env.envs.common.observation.OccupancyGridObservation.observe"]], "pos_to_index() (highway_env.envs.common.observation.occupancygridobservation method)": [[23, "highway_env.envs.common.observation.OccupancyGridObservation.pos_to_index"]], "space() (highway_env.envs.common.observation.grayscaleobservation method)": [[23, "highway_env.envs.common.observation.GrayscaleObservation.space"]], "space() (highway_env.envs.common.observation.kinematicobservation method)": [[23, "highway_env.envs.common.observation.KinematicObservation.space"]], "space() (highway_env.envs.common.observation.kinematicsgoalobservation method)": [[23, "highway_env.envs.common.observation.KinematicsGoalObservation.space"]], "space() (highway_env.envs.common.observation.occupancygridobservation method)": [[23, "highway_env.envs.common.observation.OccupancyGridObservation.space"]]}})
\ No newline at end of file