Class LaneOperationalPlanBuilder
- java.lang.Object
-
- org.opentrafficsim.road.gtu.lane.plan.operational.LaneOperationalPlanBuilder
-
public final class LaneOperationalPlanBuilder extends Object
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.Copyright (c) 2013-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
$LastChangedDate: 2015-07-24 02:58:59 +0200 (Fri, 24 Jul 2015) $, @version $Revision: 1147 $, by $Author: averbraeck $, initial version Nov 15, 2015
BSD-style license. See OpenTrafficSim License.- Author:
- Alexander Verbraeck, Peter Knoppers
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Duration
brakingTime(Acceleration acceleration, Speed startSpeed, Duration time)
Returns the effective braking time, which stops if stand-still is reached.static LaneBasedOperationalPlan
buildAccelerationLaneChangePlan(LaneBasedGTU gtu, LateralDirectionality laneChangeDirectionality, DirectedPoint startPosition, Time startTime, Speed startSpeed, Acceleration acceleration, 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, Time startTime, Speed startSpeed, Acceleration acceleration, 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
buildGradualAccelerationPlan(LaneBasedGTU gtu, Length distance, Time startTime, Speed startSpeed, Speed endSpeed)
Build a plan with a path and a given start speed to reach a provided end speed, exactly at the end of the curve.static LaneBasedOperationalPlan
buildGradualAccelerationPlan(LaneBasedGTU gtu, Length distance, Time startTime, Speed startSpeed, Speed endSpeed, Acceleration maxAcceleration, Acceleration maxDeceleration)
Build a plan with a path and a given start speed to try to reach a provided end speed, exactly at the end of the curve.static LaneBasedOperationalPlan
buildMaximumAccelerationPlan(LaneBasedGTU gtu, Length distance, Time startTime, Speed startSpeed, Speed endSpeed, Acceleration acceleration, Acceleration deceleration)
Build a plan with a path and a given start speed to try to reach a provided end speed.static LaneBasedOperationalPlan
buildPlanFromSimplePlan(LaneBasedGTU gtu, Time startTime, SimpleOperationalPlan simplePlan, LaneChange laneChange)
Build an operational plan based on a simple operational plan and status info.static LaneBasedOperationalPlan
buildStopPlan(LaneBasedGTU gtu, Length distance, Time startTime, Speed startSpeed, Acceleration deceleration)
Build a plan with a path and a given start speed to try to come to a stop with a given deceleration.static OTSLine3D
createPathAlongCenterLine(LaneBasedGTU gtu, Length distance)
Creates a path along lane center lines.static void
scheduleLaneChangeFinalization(LaneBasedGTU gtu, Length distance, LateralDirectionality laneChangeDirection)
Schedules a lane change finalization after the given distance is covered.
-
-
-
Method Detail
-
buildGradualAccelerationPlan
public static LaneBasedOperationalPlan buildGradualAccelerationPlan(LaneBasedGTU gtu, Length distance, Time startTime, Speed startSpeed, Speed endSpeed, Acceleration maxAcceleration, Acceleration maxDeceleration) throws OperationalPlanException, OTSGeometryException
Build a plan with a path and a given start speed to try to reach a provided end speed, exactly at the end of the curve. The acceleration (and deceleration) are capped by maxAcceleration and maxDeceleration. Therefore, there is no guarantee that the end speed is actually reached by this plan.- Parameters:
gtu
- LaneBasedGTU; the GTU for debugging purposesdistance
- Length; distance to drive for reaching the end speedstartTime
- Time; the current time or a time in the future when the plan should startstartSpeed
- Speed; the speed at the start of the pathendSpeed
- Speed; the required end speedmaxAcceleration
- Acceleration; the maximum acceleration that can be applied, provided as a POSITIVE numbermaxDeceleration
- Acceleration; the maximum deceleration that can be applied, provided as a NEGATIVE number- Returns:
- the operational plan to accomplish the given end speed
- Throws:
OperationalPlanException
- when the plan cannot be generated, e.g. because of a path that is too shortOperationalPlanException
- when the length of the path and the calculated driven distance implied by the constructed segment list differ more than a given thresholdOTSGeometryException
- in case the lanes are not connected or firstLanePosition is larger than the length of the first lane
-
buildGradualAccelerationPlan
public static LaneBasedOperationalPlan buildGradualAccelerationPlan(LaneBasedGTU gtu, Length distance, Time startTime, Speed startSpeed, Speed endSpeed) throws OperationalPlanException, OTSGeometryException
Build a plan with a path and a given start speed to reach a provided end speed, exactly at the end of the curve. Acceleration and deceleration are virtually unbounded (1E12 m/s2) to reach the end speed (e.g., to come to a complete stop).- Parameters:
gtu
- LaneBasedGTU; the GTU for debugging purposesdistance
- Length; distance to drive for reaching the end speedstartTime
- Time; the current time or a time in the future when the plan should startstartSpeed
- Speed; the speed at the start of the pathendSpeed
- Speed; the required end speed- Returns:
- the operational plan to accomplish the given end speed
- Throws:
OperationalPlanException
- when the length of the path and the calculated driven distance implied by the constructed segment list differ more than a given thresholdOTSGeometryException
- in case the lanes are not connected or firstLanePositiion is larger than the length of the first lane
-
buildMaximumAccelerationPlan
public static LaneBasedOperationalPlan buildMaximumAccelerationPlan(LaneBasedGTU gtu, Length distance, Time startTime, Speed startSpeed, Speed endSpeed, Acceleration acceleration, Acceleration deceleration) 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 purposesdistance
- Length; distance to drive for reaching the end speedstartTime
- Time; the current time or a time in the future when the plan should startstartSpeed
- Speed; the speed at the start of the pathendSpeed
- Speed; the required end speedacceleration
- Acceleration; the acceleration to use if endSpeed > startSpeed, provided as a POSITIVE numberdeceleration
- Acceleration; the deceleration to use if endSpeed < startSpeed, provided as a NEGATIVE number- 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
-
buildAccelerationPlan
public static LaneBasedOperationalPlan buildAccelerationPlan(LaneBasedGTU gtu, Time startTime, Speed startSpeed, Acceleration acceleration, 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 OTSLine3D createPathAlongCenterLine(LaneBasedGTU gtu, Length distance) throws OTSGeometryException
Creates a path along lane center lines.- Parameters:
gtu
- LaneBasedGTU; gtudistance
- Length; minimum distance- Returns:
- OTSLine3D; path along lane center lines
- Throws:
OTSGeometryException
- when any of the OTSLine3D operations fails
-
buildAccelerationLaneChangePlan
public static LaneBasedOperationalPlan buildAccelerationLaneChangePlan(LaneBasedGTU gtu, LateralDirectionality laneChangeDirectionality, DirectedPoint startPosition, Time startTime, Speed startSpeed, Acceleration acceleration, 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
- DirectedPoint; 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
-
brakingTime
public static Duration brakingTime(Acceleration acceleration, Speed startSpeed, Duration time)
Returns the effective braking time, which stops if stand-still is reached.- Parameters:
acceleration
- Acceleration; accelerationstartSpeed
- Speed; start speedtime
- Duration; intended time step- Returns:
- Duration; effective braking time
-
buildPlanFromSimplePlan
public static LaneBasedOperationalPlan buildPlanFromSimplePlan(LaneBasedGTU gtu, Time startTime, SimpleOperationalPlan simplePlan, LaneChange laneChange) throws 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:
ParameterException
- if parameter is not definedGTUException
- gtu exceptionNetworkException
- network exceptionOperationalPlanException
- operational plan exeption
-
scheduleLaneChangeFinalization
public static void scheduleLaneChangeFinalization(LaneBasedGTU gtu, Length distance, LateralDirectionality laneChangeDirection) throws 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:
SimRuntimeException
- on bad time
-
buildStopPlan
public static LaneBasedOperationalPlan buildStopPlan(LaneBasedGTU gtu, Length distance, Time startTime, Speed startSpeed, Acceleration deceleration) throws OperationalPlanException, OTSGeometryException
Build a plan with a path and a given start speed to try to come to a stop with a given deceleration. If the GTU can stop before completing the given path, a truncated path that ends where the GTU stops is used instead. There is no guarantee that the OperationalPlan will lead to a complete stop.- Parameters:
gtu
- LaneBasedGTU; the GTU for debugging purposesdistance
- Length; distance to drive for reaching the end speedstartTime
- Time; the current time or a time in the future when the plan should startstartSpeed
- Speed; the speed at the start of the pathdeceleration
- Acceleration; the deceleration to use if endSpeed < startSpeed, provided as a NEGATIVE number- Returns:
- the operational plan to accomplish the given end speed
- Throws:
OperationalPlanException
- when construction of the operational path failsOTSGeometryException
- in case the lanes are not connected or firstLanePositiion is larger than the length of the first lane
-
-