The vehicles kinematics are represented in the Vehicle class by the Kinematic Bicycle Model [PAltcheDAndreaN17].

\[\begin{split}\dot{x}&=v\cos(\psi+\beta) \\ \dot{y}&=v\sin(\psi+\beta) \\ \dot{v}&=a \\ \dot{\psi}&=\frac{v}{l}\sin\beta \\ \beta&=\tan^{-1}(1/2\tan\delta), \\\end{split}\]


  • \((x, y)\) is the vehicle position;

  • \(v\) its forward speed;

  • \(\psi\) its heading;

  • \(a\) is the acceleration command;

  • \(\beta\) is the slip angle at the center of gravity;

  • \(\delta\) is the front wheel angle used as a steering command.

These calculations appear in the step() method.


class highway_env.vehicle.kinematics.Vehicle(road: highway_env.road.road.Road, position: Union[numpy.ndarray, Sequence[float]], heading: float = 0, speed: float = 0, predition_type: str = 'constant_steering')[source]

A moving vehicle on a road, and its kinematics.

The vehicle is represented by a dynamical system: a modified bicycle model. It’s state is propagated depending on its steering and acceleration actions.

LENGTH: float = 5.0

Vehicle length [m]

WIDTH: float = 2.0

Vehicle width [m]


Range for random initial speeds [m/s]

MAX_SPEED = 40.0

Maximum reachable speed [m/s]

MIN_SPEED = -40.0

Minimum reachable speed [m/s]


Length of the vehicle state history, for trajectory display

classmethod create_random(road: highway_env.road.road.Road, speed: Optional[float] = None, lane_from: Optional[str] = None, lane_to: Optional[str] = None, lane_id: Optional[int] = None, spacing: float = 1) highway_env.vehicle.kinematics.Vehicle[source]

Create a random vehicle on the road.

The lane and /or speed are chosen randomly, while longitudinal position is chosen behind the last vehicle in the road with density based on the number of lanes.

  • road – the road where the vehicle is driving

  • speed – initial speed in [m/s]. If None, will be chosen randomly

  • lane_from – start node of the lane to spawn in

  • lane_to – end node of the lane to spawn in

  • lane_id – id of the lane to spawn in

  • spacing – ratio of spacing to the front vehicle, 1 being the default


A vehicle with random position and/or speed

classmethod create_from(vehicle: highway_env.vehicle.kinematics.Vehicle) highway_env.vehicle.kinematics.Vehicle[source]

Create a new vehicle from an existing one.

Only the vehicle dynamics are copied, other properties are default.


vehicle – a vehicle


a new vehicle at the same dynamical state

act(action: Optional[Union[dict, str]] = None) None[source]

Store an action to be repeated.


action – the input action

step(dt: float) None[source]

Propagate the vehicle state given its actions.

Integrate a modified bicycle model with a 1st-order response on the steering wheel dynamics. If the vehicle is crashed, the actions are overridden with erratic steering and braking until complete stop. The vehicle’s current lane is updated.


dt – timestep of integration of the model [s]