Class CarFollowingUtil

java.lang.Object
org.opentrafficsim.road.gtu.tactical.util.CarFollowingUtil

public final class CarFollowingUtil extends Object
Static methods regarding car-following for composition in tactical planners.

Copyright (c) 2013-2026 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.

Author:
Alexander Verbraeck, Wouter Schakel
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.djunits.value.vdouble.scalar.Acceleration
    approachTargetSpeed(TacticalContext context, org.djunits.value.vdouble.scalar.Length distance, org.djunits.value.vdouble.scalar.Speed targetSpeed)
    Returns an acceleration based on the car-following model in order to adjust the speed to a given value at some location ahead.
    static org.djunits.value.vdouble.scalar.Acceleration
    constantAccelerationStop(TacticalContext context, org.djunits.value.vdouble.scalar.Length distance)
    Return constant acceleration in order to stop in specified distance.
    static org.djunits.value.vdouble.scalar.Acceleration
    followSingleLeader(CarFollowingModel carFollowingModel, Parameters parameters, org.djunits.value.vdouble.scalar.Speed speed, SpeedLimits speedLimits, org.djunits.value.vdouble.scalar.Speed maxVehicleSpeed, org.djunits.value.vdouble.scalar.Length distance, org.djunits.value.vdouble.scalar.Speed leaderSpeed)
    Follow some object.
    static org.djunits.value.vdouble.scalar.Acceleration
    followSingleLeader(CarFollowingModel carFollowingModel, Parameters parameters, org.djunits.value.vdouble.scalar.Speed speed, SpeedLimits speedLimits, org.djunits.value.vdouble.scalar.Speed maxVehicleSpeed, PerceivedObject leader)
    Follow some object.
    static org.djunits.value.vdouble.scalar.Acceleration
    followSingleLeader(TacticalContext context, org.djunits.value.vdouble.scalar.Length distance, org.djunits.value.vdouble.scalar.Speed leaderSpeed)
    Follow some object.
    static org.djunits.value.vdouble.scalar.Acceleration
    Follow some object.
    static org.djunits.value.vdouble.scalar.Acceleration
    freeAcceleration(TacticalContext context, org.djunits.value.vdouble.scalar.Speed speed)
    Calculate free acceleration.
    static org.djunits.value.vdouble.scalar.Acceleration
    stop(TacticalContext context, org.djunits.value.vdouble.scalar.Length distance)
    Stop within given distance.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • followSingleLeader

      public static org.djunits.value.vdouble.scalar.Acceleration followSingleLeader(TacticalContext context, org.djunits.value.vdouble.scalar.Length distance, org.djunits.value.vdouble.scalar.Speed leaderSpeed) throws ParameterException
      Follow some object.
      Parameters:
      context - tactical information such as parameters and car-following model
      distance - distance
      leaderSpeed - speed of the leader
      Returns:
      acceleration for following the object
      Throws:
      NullPointerException - if any input is null
      ParameterException - if a parameter is not given or out of bounds
    • followSingleLeader

      public static org.djunits.value.vdouble.scalar.Acceleration followSingleLeader(TacticalContext context, PerceivedObject leader) throws ParameterException
      Follow some object.
      Parameters:
      context - tactical information such as parameters and car-following model
      leader - leader
      Returns:
      acceleration for following the object
      Throws:
      NullPointerException - if any input is null
      ParameterException - if a parameter is not given or out of bounds
    • followSingleLeader

      public static org.djunits.value.vdouble.scalar.Acceleration followSingleLeader(CarFollowingModel carFollowingModel, Parameters parameters, org.djunits.value.vdouble.scalar.Speed speed, SpeedLimits speedLimits, org.djunits.value.vdouble.scalar.Speed maxVehicleSpeed, org.djunits.value.vdouble.scalar.Length distance, org.djunits.value.vdouble.scalar.Speed leaderSpeed) throws ParameterException
      Follow some object.
      Parameters:
      carFollowingModel - car-following model
      parameters - parameters
      speed - current speed
      speedLimits - speed limits
      maxVehicleSpeed - maximum vehicle speed
      distance - distance
      leaderSpeed - speed of the leader
      Returns:
      acceleration for following the object
      Throws:
      NullPointerException - if any input is null
      ParameterException - if a parameter is not given or out of bounds
    • followSingleLeader

      public static org.djunits.value.vdouble.scalar.Acceleration followSingleLeader(CarFollowingModel carFollowingModel, Parameters parameters, org.djunits.value.vdouble.scalar.Speed speed, SpeedLimits speedLimits, org.djunits.value.vdouble.scalar.Speed maxVehicleSpeed, PerceivedObject leader) throws ParameterException
      Follow some object.
      Parameters:
      carFollowingModel - car-following model
      parameters - parameters
      speed - current speed
      speedLimits - speed limits
      maxVehicleSpeed - maximum vehicle speed
      leader - leader
      Returns:
      acceleration for following the object
      Throws:
      NullPointerException - if any input is null
      ParameterException - if a parameter is not given or out of bounds
    • stop

      public static org.djunits.value.vdouble.scalar.Acceleration stop(TacticalContext context, org.djunits.value.vdouble.scalar.Length distance) throws ParameterException
      Stop within given distance.
      Parameters:
      context - tactical information such as parameters and car-following model
      distance - distance to stop over
      Returns:
      acceleration to stop over distance
      Throws:
      NullPointerException - if any input is null
      ParameterException - if a parameter is not given or out of bounds
    • constantAccelerationStop

      public static org.djunits.value.vdouble.scalar.Acceleration constantAccelerationStop(TacticalContext context, org.djunits.value.vdouble.scalar.Length distance) throws ParameterException
      Return constant acceleration in order to stop in specified distance. The car-following model is used to determine the stopping distance (i.e. distance remaining at stand still, e.g. 1-3m).
      Parameters:
      context - tactical information such as parameters and car-following model
      distance - distance to stop over
      Returns:
      constant acceleration in order to stop in specified distance
      Throws:
      NullPointerException - if any input is null
      ParameterException - on missing parameter
    • freeAcceleration

      public static org.djunits.value.vdouble.scalar.Acceleration freeAcceleration(TacticalContext context, org.djunits.value.vdouble.scalar.Speed speed) throws ParameterException
      Calculate free acceleration.
      Parameters:
      context - tactical information such as parameters and car-following model
      speed - speed to accelerate from, which may be different from the current speed to anticipate ego movement
      Returns:
      acceleration free acceleration
      Throws:
      NullPointerException - if any input is null
      ParameterException - if a parameter is not given or out of bounds
    • approachTargetSpeed

      public static org.djunits.value.vdouble.scalar.Acceleration approachTargetSpeed(TacticalContext context, org.djunits.value.vdouble.scalar.Length distance, org.djunits.value.vdouble.scalar.Speed targetSpeed) throws ParameterException
      Returns an acceleration based on the car-following model in order to adjust the speed to a given value at some location ahead. This is done by placing a virtual vehicle somewhere near the location. Both the location and speed of this virtual vehicle are dynamically adjusted to resemble a car-following situation. To explain, first consider the situation where a virtual vehicle is placed at the target speed and such that the equilibrium headway is in line with the location:
      
        ___    location of target speed --)|        ___
       |___|(--------------s--------------) (--h--)|___| ))) vTar
       
      Here, s is the distance to the target speed, and h is the desired headway if the vehicle would drive at the target speed vTar.

      In this way car-following models will first underestimate the required deceleration, as the virtual vehicle is actually stationary and does not move with vTar at all. Because of this underestimation, strong deceleration is required later. This behavior is not in line with the sensitivity parameters of the car-following model.

      To correct for the fact that the virtual vehicle is actually not moving, the speed difference should be larger, i.e. the speed of the virtual vehicle vTar' should be lower. We require:
      • if v = vTar then vTar' = vTar, otherwise there is an incentive to accelerate or decelerate for no good reason
      • if vTar ~ 0 then vTar' ~ 0, as car-following models are suitable for stopping and need no additional incentive to decelerate in such cases
      • if 0 < vTar < v then vTar' < vTar, introducing additional deceleration to compensate for the fact that the virtual vehicle does not actually move by vTar
      These requirements are met by vTar' = vTar * (vTar/v) = vTar^2/v.

      Furthermore, if v < vTar we get vTar' > vTar leading to additional acceleration. Acceleration is then appropriate, and possibly limited by a free term in the car-following model.

      The virtual vehicle is thus placed with speed vTar' at a distance s + h' where h' is the desired headway if the vehicle would drive at speed vTar'. Both vTar' and h' depend on the current speed of the vehicle, so the virtual vehicle in this case actually moves, but not with vTar.

      This approach has been tested with the IDM+ to deliver decelerations in line with the parameters. On a plane with initial speed ranging from 0 to 33.33m/s and a target speed in 300m also ranging from 0 to 33.33m/s, strongest deceleration is equal to the car-following model stopping from 33.33m/s to a stand-still vehicle in 300m (+ stopping distance of 3m). Throughout the plane the maximum deceleration of each scenario is close to this value, unless the initial speed is so low, and the target speed is so high, that such levels of deceleration are never required.

      Parameters:
      context - tactical information such as parameters and car-following model
      distance - distance to the location of the target speed
      targetSpeed - target speed
      Returns:
      acceleration acceleration based on the car-following model in order to adjust the speed
      Throws:
      ParameterException - if parameter exception occurs
      NullPointerException - if any input is null
      IllegalArgumentException - if the distance or target speed is not at least 0