Behaviors

These stands one level above the actions. They provide a higher level decision that the actions then implement in order to propagate the simulation forward.

A behavior model can be interpreted as a control law. Given the current scene, representing all the vehicles present in the environment, a behavior model returns an action to execute.

Interface

We provide an interface to interact with behavior model or implement your own. To implement your own driver model you can create a type that inherits from the abstract type DriverModel. Then you can implement the following methods:

AutomotiveDrivingModels.DriverModelType
DriverModel{DriveAction}

A DriverModel represents a specific driving behavior. It specifies the action taken by the agent at a given scene. The ation will be of type DriveAction. It can be interpreted as a distribution, the likelihood of taking a certain action in a given scene. The DriverModel type is an abstract type! Custom driver models should inherit from it.

source
Base.randMethod
rand(model::DriverModel)
rand(rng::AbstractRNG, model::DriverModel)

Samples an action from the model.

source

observe! and rand are usually the most important methods to implement. observe! sets the model state in a given situation and rand allows to sample an action from the model.

Available Behaviors

AutomotiveDrivingModels.IntelligentDriverModelType
IntelligentDriverModel <: LaneFollowingDriver

The Intelligent Driver Model. A rule based driving model that is governed by parameter settings. The output is an longitudinal acceleration.

Here, we have extended IDM to the errorable IDM. If a standard deviation parameter is specified, then the output is a longitudinal acceleration sampled from a normal distribution around the non-errorable IDM output.

Fields

  • a::Float64 = NaN the predicted acceleration i.e. the output of the model
  • σ::Float64 = NaN allows errorable IDM, optional stdev on top of the model, set to zero or NaN for deterministic behavior
  • k_spd::Float64 = 1.0 proportional constant for speed tracking when in freeflow [s⁻¹]
  • δ::Float64 = 4.0 acceleration exponent
  • T::Float64 = 1.5 desired time headway [s]
  • v_des::Float64 = 29.0 desired speed [m/s]
  • s_min::Float64 = 5.0 minimum acceptable gap [m]
  • a_max::Float64 = 3.0 maximum acceleration ability [m/s²]
  • d_cmf::Float64 = 2.0 comfortable deceleration m/s²
  • d_max::Float64 = 9.0 maximum deceleration m/s²
source
AutomotiveDrivingModels.Tim2DDriverType
Tim2DDriver

Driver that combines longitudinal driver and lateral driver into one model.

Constructors

Tim2DDriver(timestep::Float64;mlon::LaneFollowingDriver=IntelligentDriverModel(), mlat::LateralDriverModel=ProportionalLaneTracker(), mlane::LaneChangeModel=TimLaneChanger(timestep))

Fields

  • mlon::LaneFollowingDriver = IntelligentDriverModel() Longitudinal driving model
  • mlat::LateralDriverModel = ProportionalLaneTracker() Lateral driving model
  • mlane::LaneChangeModel =TimLaneChanger Lane change model
source
AutomotiveDrivingModels.PrincetonDriverType
PrincetonDriver <: LaneFollowingDriver

A lane following driver model that controls longitudinal speed by following a front car.

Fields

  • a::Float64
  • σ::Float64 = NaN optional stdev on top of the model, set to zero or NaN for deterministic behavior
  • k::Float64 = 1.0 proportional constant for speed tracking [s⁻¹]
  • v_des::Float64 = 29.0 desired speed [m/s]
source
AutomotiveDrivingModels.SidewalkPedestrianModelType
SidewalkPedestrianModel

Walks along the sidewalk until approaching the crosswalk. Waits for the cars to pass, then crosses.

Fields

  • timestep::Float64
  • phase::Int = APPROACHING
  • ttc_threshold::Float64 = clamp(rand(Normal(4.0, 2.5)), 1.0, Inf)
  • crosswalk::Lane = Lane()
  • sw_origin::Lane = Lane()
  • sw_dest::Lane = Lane()
  • a::PedestrianLatLonAccel = PedestrianLatLonAccel(0.0, 0.0, sw_origin) makes you turn, left/right
  • σ::Float64 = NaN optional stdev on top of the model, set to zero or NaN for deterministic
  • v_des_approach::Float64 = clamp(rand(Normal(1.28, 0.18)), 0.0, Inf) Based on Feliciani et al. results
  • v_des_appraise::Float64 = clamp(rand(Normal(0.94, 0.21)), 0.0, Inf)
  • v_des_cross::Float64 = clamp(rand(Normal(1.35, 0.18)), 0.0, Inf)
  • ped_accel::Float64 = 0.30
  • ped_decel::Float64 = -0.50
source
AutomotiveDrivingModels.StaticDriverType
StaticDriver{A,P<:ContinuousMultivariateDistribution} <: DriverModel{A}

A driver model where actions are always sampled by the same distribution specified by the field distribution.

Fields

  • distribution::P
source

Lane change helper functions

These are not standalone driver models but are used by the driver models to do lane changing and lateral control.

AutomotiveDrivingModels.MOBILType
MOBIL

See Treiber & Kesting, 'Modeling Lane-Changing Decisions with MOBIL'

Constructor

MOBIL(timestep::Float64;mlon::LaneFollowingDriver=IntelligentDriverModel(),safe_decel::Float64=2.0,       politeness::Float64=0.35,advantage_threshold::Float64=0.1)

Fields

  • dir::Int
  • mlon::LaneFollowingDriver=IntelligentDriverModel()
  • safe_decel::Float64=2.0
  • politeness::Float64=0.35
  • advantage_threshold::Float64=0.1
source
AutomotiveDrivingModels.TimLaneChangerType
TimLaneChanger

A simple lane change behavior that changes lanes whenever the lead car is going slower than our desired speed. Lane changes are made when there is an available lane, fore/rear gaps exceed our thresholds, we are faster than a rear vehicle in the target lane, and any lead vehicle in the target lane is faster than we can currently go.

Has not been published anywhere, so first use in a paper would have to describe this. See MOBIL if you want a lane changer you can cite.

Constructors

TimLaneChanger(timestep::Float64;v_des::Float64=29.0,rec::SceneRecord=SceneRecord(2,timestep),threshold_fore::Float64 = 50.0,threshold_lane_change_gap_fore::Float64 = 10.0, threshold_lane_change_gap_rear::Float64 = 10.0,dir::Int=DIR_MIDDLE)

Fields

  • dir::Int = DIR_MIDDLE the desired lane to go to eg: left,middle (i.e. stay in same lane) or right
  • rec::SceneRecord TODO
  • v_des::Float64 = 29.0 desired velocity
  • threshold_fore::Float64 = 50.0 Distance from lead vehicle
  • threshold_lane_change_gap_fore::Float64 = 10.0 Space in front
  • threshold_lane_change_gap_rear::Float64 = 10.0 Space rear
source
AutomotiveDrivingModels.ProportionalLaneTrackerType
ProportionalLaneTracker

A controller that executes the lane change decision made by the lane change models

Constructors

ProportionalLaneTracker(;σ::Float64 = NaN,kp::Float64 = 3.0,kd::Float64 = 2.0)

Fields

  • a::Float64 = NaN predicted acceleration
  • σ::Float64 = NaN optional stdev on top of the model, set to zero or NaN for deterministic behavior
  • kp::Float64 = 3.0 proportional constant for lane tracking
  • kd::Float64 = 2.0 derivative constant for lane tracking
source

Longitudinal helper functions

These are not standalone driver models but are used to do longitudinal control by the driver models.

AutomotiveDrivingModels.ProportionalSpeedTrackerType
ProportionalSpeedTracker <: LaneFollowingDriver

Longitudinal proportional speed control.

Fields

  • a::Float64 = NaN predicted acceleration
  • σ::Float64 = NaN optional stdev on top of the model, set to zero or NaN for deterministic behavior
  • k::Float64 = 1.0 proportional constant for speed tracking [s⁻¹]
  • v_des::Float64 = 29.0 desired speed [m/s]
source