Class LaneChange
- 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 usinggetPath()
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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
LaneChange.LaneChangePath
Provides a (partial) path during lane changes.
-
Field Summary
Fields Modifier and Type Field Description static double
MIN_LC_LENGTH_FACTOR
Minimum distance required to perform a lane change as factor on vehicle length.
-
Constructor Summary
Constructors Constructor Description LaneChange(Length minimumLaneChangeDistance, Duration desiredLaneChangeDuration)
Constructor.LaneChange(LaneBasedGTU gtu)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
checkRoom(LaneBasedGTU gtu, Headway headway)
Checks whether the given GTU has sufficient space relative to aHeadway
.LateralDirectionality
getDirection()
Return lateral lane change direction.double
getFraction()
Returns the fraction of the lane change performed.Length
getMinimumLaneChangeDistance()
Returns the minimum lane change distance.OTSLine3D
getPath(Duration timeStep, LaneBasedGTU gtu, DirectedLanePosition from, DirectedPoint startPosition, Length planDistance, LateralDirectionality laneChangeDirection)
Returns the path for a lane change.RelativeLane
getSecondLane(LaneBasedGTU gtu)
Second lane of lane change relative to the reference lane.boolean
isChangingLane()
Return whether the GTU is changing lane.boolean
isChangingLeft()
Return whether the GTU is changing left.boolean
isChangingRight()
Return whether the GTU is changing right.void
setBoundary(Length boundary)
Sets the distance within which a lane change should be finished.void
setDesiredLaneChangeDuration(Duration duration)
Sets the desired lane change duration.void
setLaneChangePath(LaneChange.LaneChangePath laneChangePath)
Sets a lane change path.String
toString()
-
-
-
Constructor Detail
-
LaneChange
public LaneChange(LaneBasedGTU gtu)
Constructor.- Parameters:
gtu
- LaneBasedGTU; gtu
-
-
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 stepgtu
- LaneBasedGTU; gtufrom
- DirectedLanePosition; current position on the from lane (i.e. not necessarily the reference position)startPosition
- DirectedPoint; current position in 2DplanDistance
- Length; absolute distance that will be covered during the time steplaneChangeDirection
- 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 aHeadway
.- Parameters:
gtu
- LaneBasedGTU; gtuheadway
- Headway; headway- Returns:
- boolean; whether the given GTU has sufficient space relative to a
Headway
-
-