Class 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-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
    BSD-style license. See OpenTrafficSim License.

    Version:
    $Revision$, $LastChangedDate$, by $Author$, initial version Jul 26, 2016
    Author:
    Alexander Verbraeck, Peter Knoppers, Wouter Schakel
    See Also:
    Serialized Form
    • Field Detail

      • 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 Detail

      • LaneChange

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

        public LaneChange​(Length minimumLaneChangeDistance,
                          Duration desiredLaneChangeDuration)
        Constructor.
        Parameters:
        minimumLaneChangeDistance - Length; minimum lane change distance
        desiredLaneChangeDuration - Duration; deaired lane change duration
    • Method Detail

      • getMinimumLaneChangeDistance

        public Length getMinimumLaneChangeDistance()
        Returns the minimum lane change distance.
        Returns:
        Length; minimum lane change distance
      • setDesiredLaneChangeDuration

        public void setDesiredLaneChangeDuration​(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​(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 OTSLine3D getPath​(Duration timeStep,
                                       LaneBasedGTU gtu,
                                       DirectedLanePosition from,
                                       DirectedPoint startPosition,
                                       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 - DirectedLanePosition; current position on the from lane (i.e. not necessarily the reference position)
        startPosition - DirectedPoint; current position in 2D
        planDistance - Length; absolute distance that will be covered during the time step
        laneChangeDirection - LateralDirectionality; lane change direction
        Returns:
        OTSLine3D; 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