Class LaneChange
java.lang.Object
org.opentrafficsim.road.gtu.lane.plan.operational.LaneChange
- All Implemented Interfaces:
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:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Provides a (partial) path during lane changes. -
Field Summary
Modifier and TypeFieldDescriptionstatic double
Minimum distance required to perform a lane change as factor on vehicle length. -
Constructor Summary
ConstructorDescriptionLaneChange
(org.djunits.value.vdouble.scalar.Length minimumLaneChangeDistance, org.djunits.value.vdouble.scalar.Duration desiredLaneChangeDuration) Constructor.LaneChange
(LaneBasedGtu gtu) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionboolean
checkRoom
(LaneBasedGtu gtu, Headway headway) Checks whether the given GTU has sufficient space relative to aHeadway
.final LateralDirectionality
Return lateral lane change direction.double
Returns the fraction of the lane change performed.org.djunits.value.vdouble.scalar.Length
Returns the minimum lane change distance.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) Returns the path for a lane change.final RelativeLane
Second lane of lane change relative to the reference lane.final boolean
Return whether the GTU is changing lane.final boolean
Return whether the GTU is changing left.final boolean
Return whether the GTU is changing right.void
setBoundary
(org.djunits.value.vdouble.scalar.Length boundary) Sets the distance within which a lane change should be finished.void
setDesiredLaneChangeDuration
(org.djunits.value.vdouble.scalar.Duration duration) Sets the desired lane change duration.void
setLaneChangePath
(LaneChange.LaneChangePath laneChangePath) Sets a lane change path.toString()
-
Field Details
-
MIN_LC_LENGTH_FACTOR
public static double MIN_LC_LENGTH_FACTORMinimum distance required to perform a lane change as factor on vehicle length.
-
-
Constructor Details
-
LaneChange
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 distancedesiredLaneChangeDuration
- 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
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
Return lateral lane change direction.- Returns:
- LateralDirectionality; lateral lane change direction
-
getSecondLane
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 stepgtu
- LaneBasedGtu; gtufrom
- LanePosition; current position on the from lane (i.e. not necessarily the reference position)startPosition
- OrientedPoint2d; current position in 2DplanDistance
- Length; absolute distance that will be covered during the time steplaneChangeDirection
- LateralDirectionality; lane change direction- Returns:
- OtsLine2d; path
- Throws:
OtsGeometryException
- on path or shape error
-
checkRoom
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
-
toString
-