Class LaneOperationalPlanBuilder

java.lang.Object
org.opentrafficsim.road.gtu.lane.plan.operational.LaneOperationalPlanBuilder

public final class LaneOperationalPlanBuilder extends Object
Builder for several often used operational plans. E.g., decelerate to come to a full stop at the end of a shape; accelerate to reach a certain speed at the end of a curve; drive constant on a curve; decelerate or accelerate to reach a given end speed at the end of a curve, etc.
TODO driving with negative speeds (backward driving) is not yet supported.

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

Author:
Alexander Verbraeck, Peter Knoppers
  • Constructor Details

    • LaneOperationalPlanBuilder

      LaneOperationalPlanBuilder()
      Constructor.
  • Method Details

    • buildAccelerationPlan

      public static LaneBasedOperationalPlan buildAccelerationPlan(LaneBasedGtu gtu, org.djunits.value.vdouble.scalar.Time startTime, org.djunits.value.vdouble.scalar.Speed startSpeed, org.djunits.value.vdouble.scalar.Acceleration acceleration, org.djunits.value.vdouble.scalar.Duration timeStep, boolean deviative) throws OperationalPlanException
      Build a plan with a path and a given start speed to try to reach a provided end speed. Acceleration or deceleration is as provided, until the end speed is reached. After this, constant end speed is used to reach the end point of the path. There is no guarantee that the end speed is actually reached by this plan. If the end speed is zero, and it is reached before completing the path, a truncated path that ends where the GTU stops is used instead.
      Parameters:
      gtu - the GTU for debugging purposes
      startTime - the current time or a time in the future when the plan should start
      startSpeed - the speed at the start of the path
      acceleration - the acceleration to use
      timeStep - time step for the plan
      deviative - whether the plan is deviative
      Returns:
      the operational plan to accomplish the given end speed
      Throws:
      OperationalPlanException - when the construction of the operational path fails
    • createPathAlongCenterLine

      public static org.opentrafficsim.base.geometry.OtsLine2d createPathAlongCenterLine(LaneBasedGtu gtu, org.djunits.value.vdouble.scalar.Length distance)
      Creates a path along lane center lines.
      Parameters:
      gtu - gtu
      distance - minimum distance
      Returns:
      path along lane center lines
    • buildAccelerationLaneChangePlan

      public static LaneBasedOperationalPlan buildAccelerationLaneChangePlan(LaneBasedGtu gtu, LateralDirectionality laneChangeDirectionality, org.djutils.draw.point.OrientedPoint2d startPosition, org.djunits.value.vdouble.scalar.Time startTime, org.djunits.value.vdouble.scalar.Speed startSpeed, org.djunits.value.vdouble.scalar.Acceleration acceleration, org.djunits.value.vdouble.scalar.Duration timeStep, LaneChange laneChange) throws OperationalPlanException
      Build a plan with a path and a given start speed to try to reach a provided end speed. Acceleration or deceleration is as provided, until the end speed is reached. After this, constant end speed is used to reach the end point of the path. There is no guarantee that the end speed is actually reached by this plan. If the end speed is zero, and it is reached before completing the path, a truncated path that ends where the GTU stops is used instead.
      Parameters:
      gtu - the GTU for debugging purposes
      laneChangeDirectionality - direction of lane change (on initiation only, after that not important)
      startPosition - current position
      startTime - the current time or a time in the future when the plan should start
      startSpeed - the speed at the start of the path
      acceleration - the acceleration to use
      timeStep - time step for the plan
      laneChange - lane change status
      Returns:
      the operational plan to accomplish the given end speed
      Throws:
      OperationalPlanException - when the construction of the operational path fails
    • buildPlanFromSimplePlan

      public static LaneBasedOperationalPlan buildPlanFromSimplePlan(LaneBasedGtu gtu, org.djunits.value.vdouble.scalar.Time startTime, SimpleOperationalPlan simplePlan, LaneChange laneChange) throws org.opentrafficsim.base.parameters.ParameterException, GtuException, NetworkException
      Build an operational plan based on a simple operational plan and status info.
      Parameters:
      gtu - gtu
      startTime - start time for plan
      simplePlan - simple operational plan
      laneChange - lane change status
      Returns:
      operational plan
      Throws:
      org.opentrafficsim.base.parameters.ParameterException - if parameter is not defined
      GtuException - gtu exception
      NetworkException - network exception
    • scheduleLaneChangeFinalization

      public static void scheduleLaneChangeFinalization(LaneBasedGtu gtu, org.djunits.value.vdouble.scalar.Length distance, LateralDirectionality laneChangeDirection) throws nl.tudelft.simulation.dsol.SimRuntimeException
      Schedules a lane change finalization after the given distance is covered. This distance is known as the plan is created, but at that point no time can be derived as the plan is required for that. Hence, this method can be scheduled at the same time (sequentially after creation of the plan) to then schedule the actual finalization by deriving time from distance with the plan.
      Parameters:
      gtu - gtu
      distance - distance
      laneChangeDirection - lane change direction
      Throws:
      nl.tudelft.simulation.dsol.SimRuntimeException - on bad time