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, OtsGeometryException
      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 - LaneBasedGtu; the GTU for debugging purposes
      startTime - Time; the current time or a time in the future when the plan should start
      startSpeed - Speed; the speed at the start of the path
      acceleration - Acceleration; the acceleration to use
      timeStep - Duration; time step for the plan
      deviative - boolean; 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
      OtsGeometryException - in case the lanes are not connected or firstLanePositiion is larger than the length of the first lane
    • createPathAlongCenterLine

      public static OtsLine2d createPathAlongCenterLine(LaneBasedGtu gtu, org.djunits.value.vdouble.scalar.Length distance) throws OtsGeometryException
      Creates a path along lane center lines.
      Parameters:
      gtu - LaneBasedGtu; gtu
      distance - Length; minimum distance
      Returns:
      OtsLine2d; path along lane center lines
      Throws:
      OtsGeometryException - when any of the OtsLine2d operations fails
    • 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, OtsGeometryException
      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 - LaneBasedGtu; the GTU for debugging purposes
      laneChangeDirectionality - LateralDirectionality; direction of lane change (on initiation only, after that not important)
      startPosition - OrientedPoint2d; current position
      startTime - Time; the current time or a time in the future when the plan should start
      startSpeed - Speed; the speed at the start of the path
      acceleration - Acceleration; the acceleration to use
      timeStep - Duration; time step for the plan
      laneChange - LaneChange; lane change status
      Returns:
      the operational plan to accomplish the given end speed
      Throws:
      OperationalPlanException - when the construction of the operational path fails
      OtsGeometryException - in case the lanes are not connected or firstLanePositiion is larger than the length of the first lane
    • 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, OperationalPlanException
      Build an operational plan based on a simple operational plan and status info.
      Parameters:
      gtu - LaneBasedGtu; gtu
      startTime - Time; start time for plan
      simplePlan - SimpleOperationalPlan; simple operational plan
      laneChange - LaneChange; lane change status
      Returns:
      operational plan
      Throws:
      org.opentrafficsim.base.parameters.ParameterException - if parameter is not defined
      GtuException - gtu exception
      NetworkException - network exception
      OperationalPlanException - operational plan exeption
    • 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 - LaneBasedGtu; gtu
      distance - Length; distance
      laneChangeDirection - LateralDirectionality; lane change direction
      Throws:
      nl.tudelft.simulation.dsol.SimRuntimeException - on bad time