Class OperationalPlanBuilder
- java.lang.Object
-
- org.opentrafficsim.core.gtu.plan.operational.OperationalPlanBuilder
-
public final class OperationalPlanBuilder 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.
TODO plan with a constant speed.Copyright (c) 2013-2022 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 OperationalPlan
buildConstantSpeedPlan(GTU gtu, OTSLine3D path, Time startTime, Speed speed)
Build a plan with a path and a given speed.static OperationalPlan
buildGradualAccelerationPlan(GTU gtu, OTSLine3D path, 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 OperationalPlan
buildGradualAccelerationPlan(GTU gtu, OTSLine3D path, Time startTime, Speed startSpeed, Speed endSpeed, Acceleration maximumAcceleration, Acceleration maximumDeceleration)
Build a plan with a path and a given start speed to try to reach a provided end speed, exactly at the providedendTime
.static OperationalPlan
buildMaximumAccelerationPlan(GTU gtu, OTSLine3D path, Time startTime, Speed startSpeed, Speed endSpeed, Acceleration maximumAcceleration, Acceleration maximumDeceleration)
Build a plan with a path and a given start speed to try to reach a provided end speed.static OperationalPlan
buildStopPlan(GTU gtu, OTSLine3D path, 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.
-
-
-
Method Detail
-
buildConstantSpeedPlan
public static OperationalPlan buildConstantSpeedPlan(GTU gtu, OTSLine3D path, Time startTime, Speed speed) throws OperationalPlanException
Build a plan with a path and a given speed.- Parameters:
gtu
- GTU; the GTU for debugging purposespath
- OTSLine3D; the path to drive (provides the length)startTime
- Time; the current time or a time in the future when the plan should startspeed
- Speed; the speed at the start of the path- 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 threshold
-
buildGradualAccelerationPlan
public static OperationalPlan buildGradualAccelerationPlan(GTU gtu, OTSLine3D path, Time startTime, Speed startSpeed, Speed endSpeed, Acceleration maximumAcceleration, Acceleration maximumDeceleration) throws OperationalPlanException
Build a plan with a path and a given start speed to try to reach a provided end speed, exactly at the providedendTime
. 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.TODO: rename this method buildConstantAccelerationPlan.
- Parameters:
gtu
- GTU; the GTU for debugging purposespath
- OTSLine3D; the path to drive (provides the length)startTime
- 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 speedmaximumAcceleration
- Acceleration; the maximum acceleration that can be applied, provided as a POSITIVE numbermaximumDeceleration
- 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 length of the path and the calculated driven distance implied by the constructed segment list differ more than a given threshold
-
buildGradualAccelerationPlan
public static OperationalPlan buildGradualAccelerationPlan(GTU gtu, OTSLine3D path, Time startTime, Speed startSpeed, Speed endSpeed) throws OperationalPlanException
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
- GTU; the GTU for debugging purposespath
- OTSLine3D; the path to drive (provides the length)startTime
- 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 threshold
-
buildMaximumAccelerationPlan
public static OperationalPlan buildMaximumAccelerationPlan(GTU gtu, OTSLine3D path, Time startTime, Speed startSpeed, Speed endSpeed, Acceleration maximumAcceleration, Acceleration maximumDeceleration) throws OperationalPlanException
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. The maximum acceleration and deceleration is limited by the provided values. If these prevent theendSpeed
from being reached, the generated plan is a constant acceleration plan using the limiting value.- Parameters:
gtu
- GTU; the GTU for debugging purposespath
- OTSLine3D; the path to drive (provides the length)startTime
- 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 speedmaximumAcceleration
- Acceleration; the acceleration to use if endSpeed > startSpeed, provided as a POSITIVE numbermaximumDeceleration
- 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 length of the path and the calculated driven distance implied by the constructed segment list differ more than a given threshold
-
buildStopPlan
public static OperationalPlan buildStopPlan(GTU gtu, OTSLine3D path, Time startTime, Speed startSpeed, Acceleration deceleration) throws OperationalPlanException
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
- GTU; the GTU for debugging purposespath
- OTSLine3D; the path to drive (provides the length)startTime
- 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 the length of the path and the calculated driven distance implied by the constructed segment list differ more than a given threshold
-
-