Class LaneOperationalPlanBuilder
java.lang.Object
org.opentrafficsim.road.gtu.lane.plan.operational.LaneOperationalPlanBuilder
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.
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic 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) Build a plan with a path and a given start speed to try to reach a provided end speed.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) Build a plan with a path and a given start speed to try to reach a provided end speed.static LaneBasedOperationalPlan
buildPlanFromSimplePlan
(LaneBasedGtu gtu, org.djunits.value.vdouble.scalar.Time startTime, SimpleOperationalPlan simplePlan, LaneChange laneChange) Build an operational plan based on a simple operational plan and status info.static OtsLine2d
createPathAlongCenterLine
(LaneBasedGtu gtu, org.djunits.value.vdouble.scalar.Length distance) Creates a path along lane center lines.static void
scheduleLaneChangeFinalization
(LaneBasedGtu gtu, org.djunits.value.vdouble.scalar.Length distance, LateralDirectionality laneChangeDirection) Schedules a lane change finalization after the given distance is covered.
-
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 purposesstartTime
- Time; the current time or a time in the future when the plan should startstartSpeed
- Speed; the speed at the start of the pathacceleration
- Acceleration; the acceleration to usetimeStep
- Duration; time step for the plandeviative
- 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 failsOtsGeometryException
- 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; gtudistance
- 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 purposeslaneChangeDirectionality
- LateralDirectionality; direction of lane change (on initiation only, after that not important)startPosition
- OrientedPoint2d; current positionstartTime
- Time; the current time or a time in the future when the plan should startstartSpeed
- Speed; the speed at the start of the pathacceleration
- Acceleration; the acceleration to usetimeStep
- Duration; time step for the planlaneChange
- LaneChange; lane change status- Returns:
- the operational plan to accomplish the given end speed
- Throws:
OperationalPlanException
- when the construction of the operational path failsOtsGeometryException
- 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; gtustartTime
- Time; start time for plansimplePlan
- SimpleOperationalPlan; simple operational planlaneChange
- LaneChange; lane change status- Returns:
- operational plan
- Throws:
org.opentrafficsim.base.parameters.ParameterException
- if parameter is not definedGtuException
- gtu exceptionNetworkException
- network exceptionOperationalPlanException
- 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; gtudistance
- Length; distancelaneChangeDirection
- LateralDirectionality; lane change direction- Throws:
nl.tudelft.simulation.dsol.SimRuntimeException
- on bad time
-