Class OperationalPlan
java.lang.Object
org.opentrafficsim.core.gtu.plan.operational.OperationalPlan
An Operational plan describes a path through the world with a speed profile that a GTU intends to follow. The OperationalPlan
can be updated or replaced at any time (including before it has been totally executed), for which a tactical planner is
responsible. The operational plan is implemented using segments of the movement (time, location, speed, acceleration) that
the GTU will use to plan its location and movement. Within an OperationalPlan the GTU cannot reverse direction along the path
of movement. This ensures that the timeAtDistance method will never have to select among several valid solutions.
Copyright (c) 2013-2026 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
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final org.djunits.value.vdouble.scalar.AccelerationThe drifting speed.static final org.djunits.value.vdouble.scalar.SpeedThe drifting speed.static final org.djunits.value.vdouble.scalar.LengthMinimum distance of an operational plan path; anything shorter will be truncated to 0. -
Constructor Summary
ConstructorsConstructorDescriptionOperationalPlan(Gtu gtu, OtsLine2d path, org.djunits.value.vdouble.scalar.Duration startTime, Segments segments) Construct an operational plan. -
Method Summary
Modifier and TypeMethodDescriptionbooleanfinal org.djunits.value.vdouble.scalar.AccelerationgetAcceleration(org.djunits.value.vdouble.scalar.Duration time) Calculate the acceleration of the GTU at the given time.final org.djunits.value.vdouble.scalar.AccelerationgetAccelerationFromStart(org.djunits.value.vdouble.scalar.Duration duration) Calculate the acceleration of the GTU after the given duration since the start of the plan.org.djunits.value.vdouble.scalar.DurationgetDurationAtDistance(org.djunits.value.vdouble.scalar.Length traveledDistance) Calculates the duration at which the given distance is traveled.Provide the end location of this operational plan as a DirectedPoint.org.djunits.value.vdouble.scalar.DurationReturn the time at which the entire operational plan is completed.final DirectedPoint2dgetLocation(org.djunits.value.vdouble.scalar.Duration time) Calculate the location at the given time.final DirectedPoint2dgetLocation(org.djunits.value.vdouble.scalar.Duration time, RelativePosition pos) Calculate the location after the given duration since the start of the plan.final DirectedPoint2dgetLocationFromStart(org.djunits.value.vdouble.scalar.Duration duration) Calculate the location after the given duration since the start of the plan.Return the segments (parts with constant speed, acceleration or deceleration) of the operational plan.getPath()Return the path that will be traveled.final org.djunits.value.vdouble.scalar.SpeedgetSpeed(org.djunits.value.vdouble.scalar.Duration time) Calculate the speed of the GTU at the given time.final org.djunits.value.vdouble.scalar.SpeedgetSpeedFromStart(org.djunits.value.vdouble.scalar.Duration duration) Calculate the speed of the GTU after the given duration since the start of the plan.org.djunits.value.vdouble.scalar.SpeedReturn the end speed of the operational plan.org.djunits.value.vdouble.scalar.DurationReturn the start time of the operational plan.org.djunits.value.vdouble.scalar.DurationgetTimeAtDistance(org.djunits.value.vdouble.scalar.Length traveledDistance) Calculates the time at which the given distance is traveled.org.djunits.value.vdouble.scalar.DurationReturn the duration it will take to complete the entire operational plan.org.djunits.value.vdouble.scalar.LengthReturn the distance the entire operational plan will cover.org.djunits.value.vdouble.scalar.LengthgetTraveledDistance(org.djunits.value.vdouble.scalar.Duration time) Calculate the distance traveled as part of this plan at the given absolute time.final org.djunits.value.vdouble.scalar.LengthgetTraveledDistanceFromStart(org.djunits.value.vdouble.scalar.Duration duration) Calculate the distance traveled as part of this plan after the given duration since the start of the plan.inthashCode()static OperationalPlanstandStill(Gtu gtu, DirectedPoint2d point, org.djunits.value.vdouble.scalar.Duration startTime, org.djunits.value.vdouble.scalar.Duration duration) Creates a stand-still plan at a point.final org.djunits.value.vdouble.scalar.DurationtimeAtDistance(org.djunits.value.vdouble.scalar.Length distance) Return the time when the GTU will reach the given distance.final org.djunits.value.vdouble.scalar.DurationtimeAtPoint(DirectedPoint2d point, boolean upstream) Calculates when the GTU will be at the given point.toString()
-
Field Details
-
DRIFTING_SPEED
public static final org.djunits.value.vdouble.scalar.Speed DRIFTING_SPEEDThe drifting speed. Speeds under this value will be cropped to zero. -
DRIFTING_ACCELERATION
public static final org.djunits.value.vdouble.scalar.Acceleration DRIFTING_ACCELERATIONThe drifting speed. Accelerations under this value will be cropped to zero. -
MINIMUM_CREDIBLE_PATH_LENGTH
public static final org.djunits.value.vdouble.scalar.Length MINIMUM_CREDIBLE_PATH_LENGTHMinimum distance of an operational plan path; anything shorter will be truncated to 0.
-
-
Constructor Details
-
OperationalPlan
public OperationalPlan(Gtu gtu, OtsLine2d path, org.djunits.value.vdouble.scalar.Duration startTime, Segments segments) Construct an operational plan. The plan will be as long as the minimum of the path or segments allow.- Parameters:
gtu- the GTU for debugging purposespath- the path to follow from a certain time till a certain time. The path should have <i>at least</i> the lengthstartTime- start timesegments- the segments that make up the longitudinal dynamics
-
-
Method Details
-
standStill
public static OperationalPlan standStill(Gtu gtu, DirectedPoint2d point, org.djunits.value.vdouble.scalar.Duration startTime, org.djunits.value.vdouble.scalar.Duration duration) Creates a stand-still plan at a point. A 1m path in the direction of the point is created.- Parameters:
gtu- GTU.point- point.startTime- start time.duration- duration.- Returns:
- stand-still plan.
-
getPath
Return the path that will be traveled. If the plan is a wait plan, the start point of the path is good; the end point of the path is bogus (should only be used to determine the orientation of the GTU).- Returns:
- the path
-
getStartTime
public org.djunits.value.vdouble.scalar.Duration getStartTime()Return the start time of the operational plan.- Returns:
- the start time of the operational plan
-
getStartSpeed
public org.djunits.value.vdouble.scalar.Speed getStartSpeed()Return the end speed of the operational plan.- Returns:
- the end speed of the operational plan
-
getOperationalPlanSegmentList
Return the segments (parts with constant speed, acceleration or deceleration) of the operational plan.- Returns:
- ImmutableList<OperationalPlan.Segment>; segmentList
-
getTotalDuration
public org.djunits.value.vdouble.scalar.Duration getTotalDuration()Return the duration it will take to complete the entire operational plan.- Returns:
- the duration it will take to complete the entire operational plan
-
getTotalLength
public org.djunits.value.vdouble.scalar.Length getTotalLength()Return the distance the entire operational plan will cover.- Returns:
- the distance of the entire operational plan
-
getEndTime
public org.djunits.value.vdouble.scalar.Duration getEndTime()Return the time at which the entire operational plan is completed.- Returns:
- the time at which the entire operational plan is completed
-
getEndLocation
Provide the end location of this operational plan as a DirectedPoint.- Returns:
- the end location
-
timeAtDistance
public final org.djunits.value.vdouble.scalar.Duration timeAtDistance(org.djunits.value.vdouble.scalar.Length distance) Return the time when the GTU will reach the given distance.- Parameters:
distance- the distance to calculate the time for- Returns:
- the simulation time at which the distance will be traveled within the current plan
-
getLocationFromStart
public final DirectedPoint2d getLocationFromStart(org.djunits.value.vdouble.scalar.Duration duration) throws OperationalPlanException Calculate the location after the given duration since the start of the plan.- Parameters:
duration- duration relative to start of the plan- Returns:
- the location after the given duration since the start of the plan.
- Throws:
OperationalPlanException- when the duration is after the validity of the operational plan
-
getLocation
public final DirectedPoint2d getLocation(org.djunits.value.vdouble.scalar.Duration time) throws OperationalPlanException Calculate the location at the given time.- Parameters:
time- simulation time- Returns:
- the location at the given time.
- Throws:
OperationalPlanException- when the time is after the validity of the operational plan
-
getLocation
public final DirectedPoint2d getLocation(org.djunits.value.vdouble.scalar.Duration time, RelativePosition pos) throws OperationalPlanException Calculate the location after the given duration since the start of the plan.- Parameters:
time- simulation timepos- relative position- Returns:
- the location after the given duration since the start of the plan.
- Throws:
OperationalPlanException- when the time is after the validity of the operational plan
-
getSpeedFromStart
public final org.djunits.value.vdouble.scalar.Speed getSpeedFromStart(org.djunits.value.vdouble.scalar.Duration duration) throws OperationalPlanException Calculate the speed of the GTU after the given duration since the start of the plan.- Parameters:
duration- duration relative to start of the plan- Returns:
- the location after the given duration since the start of the plan.
- Throws:
OperationalPlanException- when the duration is after the validity of the operational plan
-
getSpeed
public final org.djunits.value.vdouble.scalar.Speed getSpeed(org.djunits.value.vdouble.scalar.Duration time) throws OperationalPlanException Calculate the speed of the GTU at the given time.- Parameters:
time- simulation time- Returns:
- the location at the given time.
- Throws:
OperationalPlanException- when the time is after the validity of the operational plan
-
getAccelerationFromStart
public final org.djunits.value.vdouble.scalar.Acceleration getAccelerationFromStart(org.djunits.value.vdouble.scalar.Duration duration) throws OperationalPlanException Calculate the acceleration of the GTU after the given duration since the start of the plan.- Parameters:
duration- duration relative to start of the plan- Returns:
- the location after the given duration since the start of the plan.
- Throws:
OperationalPlanException- when the time is after the validity of the operational plan
-
getAcceleration
public final org.djunits.value.vdouble.scalar.Acceleration getAcceleration(org.djunits.value.vdouble.scalar.Duration time) throws OperationalPlanException Calculate the acceleration of the GTU at the given time.- Parameters:
time- simulation time- Returns:
- the location at the given time.
- Throws:
OperationalPlanException- when the time is after the validity of the operational plan
-
getTraveledDistanceFromStart
public final org.djunits.value.vdouble.scalar.Length getTraveledDistanceFromStart(org.djunits.value.vdouble.scalar.Duration duration) throws OperationalPlanException Calculate the distance traveled as part of this plan after the given duration since the start of the plan.- Parameters:
duration- duration relative to start of the plan- Returns:
- the distance traveled as part of this plan after the given duration since the start of the plan.
- Throws:
OperationalPlanException- when the duration is after the validity of the operational plan
-
getTraveledDistance
public org.djunits.value.vdouble.scalar.Length getTraveledDistance(org.djunits.value.vdouble.scalar.Duration time) throws OperationalPlanException Calculate the distance traveled as part of this plan at the given absolute time.- Parameters:
time- simulation time- Returns:
- the distance traveled as part of this plan at the given time
- Throws:
OperationalPlanException- when the time is after the validity of the operational plan
-
getDurationAtDistance
public org.djunits.value.vdouble.scalar.Duration getDurationAtDistance(org.djunits.value.vdouble.scalar.Length traveledDistance) throws OperationalPlanException Calculates the duration at which the given distance is traveled.- Parameters:
traveledDistance- traveled distance- Returns:
- duration since start of the plan at which the given distance is traveled
- Throws:
OperationalPlanException- if the traveled distance is beyond the plan length
-
getTimeAtDistance
public org.djunits.value.vdouble.scalar.Duration getTimeAtDistance(org.djunits.value.vdouble.scalar.Length traveledDistance) throws OperationalPlanException Calculates the time at which the given distance is traveled.- Parameters:
traveledDistance- traveled distance- Returns:
- simulation time at which the given distance is traveled
- Throws:
OperationalPlanException- if the traveled distance is beyond the plan length
-
timeAtPoint
public final org.djunits.value.vdouble.scalar.Duration timeAtPoint(DirectedPoint2d point, boolean upstream) Calculates when the GTU will be at the given point. The point does not need to be at the traveled path, as the point is projected to the path at 90 degrees. The point may for instance be the end of a lane, which is crossed by a GTU possibly during a lane change.- Parameters:
point- point with angle, which will be projected to the path at 90 degreesupstream- true if the point is upstream of the path- Returns:
- simulation time at point
-
hashCode
public int hashCode() -
equals
-
toString
-