java.lang.Object
org.opentrafficsim.road.gtu.lane.plan.operational.LaneChange
All Implemented Interfaces:
Serializable

public class LaneChange extends Object implements Serializable
Lane change status across operational plans. This class allows lane based tactical planners to perform lane changes without having to deal with many complexities concerning paths and lane registration. The main purpose of the tactical planner is to request a path using getPath() for each step of the tactical planner.

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, Wouter Schakel
See Also:
  • Field Details

    • MIN_LC_LENGTH_FACTOR

      public static double MIN_LC_LENGTH_FACTOR
      Minimum distance required to perform a lane change as factor on vehicle length.
  • Constructor Details

    • LaneChange

      public LaneChange(LaneBasedGtu gtu)
      Constructor.
      Parameters:
      gtu - LaneBasedGtu; gtu
    • LaneChange

      public LaneChange(org.djunits.value.vdouble.scalar.Length minimumLaneChangeDistance, org.djunits.value.vdouble.scalar.Duration desiredLaneChangeDuration)
      Constructor.
      Parameters:
      minimumLaneChangeDistance - Length; minimum lane change distance
      desiredLaneChangeDuration - Duration; deaired lane change duration
  • Method Details

    • getMinimumLaneChangeDistance

      public org.djunits.value.vdouble.scalar.Length getMinimumLaneChangeDistance()
      Returns the minimum lane change distance.
      Returns:
      Length; minimum lane change distance
    • setDesiredLaneChangeDuration

      public void setDesiredLaneChangeDuration(org.djunits.value.vdouble.scalar.Duration duration)
      Sets the desired lane change duration. Should be set by a tactical planner.
      Parameters:
      duration - Duration; desired lane change duration
    • setBoundary

      public void setBoundary(org.djunits.value.vdouble.scalar.Length boundary)
      Sets the distance within which a lane change should be finished. Should be set by a tactical planner. In case of a single lane change required before some point, this is not required as the found center line length is intrinsically limited. For multiple lane changes being required, space after a lane change is required.
      Parameters:
      boundary - Length; boundary
    • getFraction

      public double getFraction()
      Returns the fraction of the lane change performed.
      Returns:
      double; fraction of lane change performed
    • setLaneChangePath

      public void setLaneChangePath(LaneChange.LaneChangePath laneChangePath)
      Sets a lane change path.
      Parameters:
      laneChangePath - LaneChangePath; lane change path
    • isChangingLane

      public final boolean isChangingLane()
      Return whether the GTU is changing lane.
      Returns:
      whether the GTU is changing lane
    • isChangingLeft

      public final boolean isChangingLeft()
      Return whether the GTU is changing left.
      Returns:
      whether the GTU is changing left
    • isChangingRight

      public final boolean isChangingRight()
      Return whether the GTU is changing right.
      Returns:
      whether the GTU is changing right
    • getDirection

      public final LateralDirectionality getDirection()
      Return lateral lane change direction.
      Returns:
      LateralDirectionality; lateral lane change direction
    • getSecondLane

      public final RelativeLane getSecondLane(LaneBasedGtu gtu) throws OperationalPlanException
      Second lane of lane change relative to the reference lane. Note that the reference lane may either be the source or the target lane. Thus, the second lane during a lane change may either be the left or right lane, regardless of the lane change direction.
      Parameters:
      gtu - LaneBasedGtu; the GTU
      Returns:
      target lane of lane change
      Throws:
      OperationalPlanException - If no lane change is being performed.
    • getPath

      public final OtsLine2d getPath(org.djunits.value.vdouble.scalar.Duration timeStep, LaneBasedGtu gtu, LanePosition from, org.djutils.draw.point.OrientedPoint2d startPosition, org.djunits.value.vdouble.scalar.Length planDistance, LateralDirectionality laneChangeDirection) throws OtsGeometryException
      Returns the path for a lane change. Lane change initialization and finalization events are automatically performed.
      Parameters:
      timeStep - Duration; plan time step
      gtu - LaneBasedGtu; gtu
      from - LanePosition; current position on the from lane (i.e. not necessarily the reference position)
      startPosition - OrientedPoint2d; current position in 2D
      planDistance - Length; absolute distance that will be covered during the time step
      laneChangeDirection - LateralDirectionality; lane change direction
      Returns:
      OtsLine2d; path
      Throws:
      OtsGeometryException - on path or shape error
    • checkRoom

      public boolean checkRoom(LaneBasedGtu gtu, Headway headway)
      Checks whether the given GTU has sufficient space relative to a Headway.
      Parameters:
      gtu - LaneBasedGtu; gtu
      headway - Headway; headway
      Returns:
      boolean; whether the given GTU has sufficient space relative to a Headway
    • toString

      public String toString()
      Overrides:
      toString in class Object