Class OperationalPlan
- java.lang.Object
-
- org.opentrafficsim.core.gtu.plan.operational.OperationalPlan
-
- All Implemented Interfaces:
Serializable
public class OperationalPlan extends Object implements Serializable
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-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 14, 2015
BSD-style license. See OpenTrafficSim License.- Author:
- Alexander Verbraeck, Peter Knoppers
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
OperationalPlan.AccelerationSegment
The segment of an operational plan in which the acceleration is constant.static class
OperationalPlan.Segment
The segment of an operational plan contains a part of the speed profile of a movement in which some of the variables determining movement (speed, acceleration) are constant.static class
OperationalPlan.SpeedSegment
The segment of an operational plan in which the speed is constant.
-
Field Summary
Fields Modifier and Type Field Description static double
DRIFTING_SPEED_SI
The drifting speed.(package private) static double
MAX_DELTA_SI
The maximum difference in the length of the path and the calculated driven distance implied by the segment list.
-
Constructor Summary
Constructors Constructor Description OperationalPlan(GTU gtu, DirectedPoint waitPoint, Time startTime, Duration duration)
Build a plan where the GTU will wait for a certain time.OperationalPlan(GTU gtu, OTSLine3D path, Time startTime, Speed startSpeed, List<OperationalPlan.Segment> operationalPlanSegmentList)
Construct an operational plan.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
Acceleration
getAcceleration(Duration time)
Calculate the acceleration of the GTU after the given duration since the start of the plan.Acceleration
getAcceleration(Time time)
Calculate the acceleration of the GTU at the given time.DirectedPoint
getEndLocation()
Provide the end location of this operational plan as a DirectedPoint.Speed
getEndSpeed()
Time
getEndTime()
Return the time it will take to complete the entire operational plan.DirectedPoint
getLocation(Duration time)
Calculate the location after the given duration since the start of the plan.DirectedPoint
getLocation(Time time)
Calculate the location at the given time.DirectedPoint
getLocation(Time time, RelativePosition pos)
Calculate the location after the given duration since the start of the plan.List<OperationalPlan.Segment>
getOperationalPlanSegmentList()
Return the segments (parts with constant speed, acceleration or deceleration) of the operational plan.OTSLine3D
getPath()
Return the path that will be traveled.Speed
getSpeed(Duration time)
Calculate the speed of the GTU after the given duration since the start of the plan.Speed
getSpeed(Time time)
Calculate the speed of the GTU at the given time.Speed
getStartSpeed()
Return the start speed of the entire plan.Time
getStartTime()
Return the (absolute) start time of the operational plan.Duration
getTotalDuration()
Return the time it will take to complete the entire operational plan.Length
getTotalLength()
Return the distance the entire operational plan will cover.Length
getTraveledDistance(Duration duration)
Calculate the distance traveled as part of this plan after the given duration since the start of the plan.Length
getTraveledDistance(Time time)
Calculate the distance traveled as part of this plan at the given absolute time.double
getTraveledDistanceSI(Duration duration)
Calculate the distance traveled as part of this plan after the given duration since the start of the plan.double
getTraveledDistanceSI(Time time)
Calculate the distance traveled as part of this plan at the given absolute time.int
hashCode()
Time
timeAtDistance(Length distance)
Return the time when the GTU will reach the given distance.Time
timeAtPoint(DirectedPoint point, boolean upstream)
Calculates when the GTU will be at the given point.String
toString()
-
-
-
Field Detail
-
MAX_DELTA_SI
static final double MAX_DELTA_SI
The maximum difference in the length of the path and the calculated driven distance implied by the segment list. The same constant is also used as a maximum between speeds of segments that should align in terms of speed.- See Also:
- Constant Field Values
-
DRIFTING_SPEED_SI
public static final double DRIFTING_SPEED_SI
The drifting speed. Speeds under this value will be cropped to zero.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
OperationalPlan
public OperationalPlan(GTU gtu, OTSLine3D path, Time startTime, Speed startSpeed, List<OperationalPlan.Segment> operationalPlanSegmentList) throws OperationalPlanException
Construct an operational plan.- Parameters:
gtu
- GTU; the GTU for debugging purposespath
- OTSLine3D; the path to follow from a certain time till a certain time. The path should have <i>at least</i> the lengthstartTime
- Time; the absolute start time when we start executing the pathstartSpeed
- Speed; the GTU speed when we start executing the pathoperationalPlanSegmentList
- List<Segment>; the segments that make up the path with an acceleration, constant speed or deceleration profile- Throws:
OperationalPlanException
- when the path is too short for the operation
-
OperationalPlan
public OperationalPlan(GTU gtu, DirectedPoint waitPoint, Time startTime, Duration duration) throws OperationalPlanException
Build a plan where the GTU will wait for a certain time.- Parameters:
gtu
- GTU; the GTU for debugging purposeswaitPoint
- DirectedPoint; the point at which the GTU will waitstartTime
- Time; the current time or a time in the future when the plan should startduration
- Duration; the waiting time- Throws:
OperationalPlanException
- when construction of a waiting path fails
-
-
Method Detail
-
getPath
public final OTSLine3D 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 final Time getStartTime()
Return the (absolute) start time of the operational plan.- Returns:
- startTime
-
getStartSpeed
public final Speed getStartSpeed()
Return the start speed of the entire plan.- Returns:
- startSpeed
-
getEndSpeed
public final Speed getEndSpeed()
- Returns:
- the end speed when completing the entire plan.
-
getOperationalPlanSegmentList
public final List<OperationalPlan.Segment> getOperationalPlanSegmentList()
Return the segments (parts with constant speed, acceleration or deceleration) of the operational plan.
The caller MUST NOT MODIFY the returned object.- Returns:
- operationalPlanSegmentList
-
getTotalDuration
public final Duration getTotalDuration()
Return the time it will take to complete the entire operational plan.- Returns:
- the time it will take to complete the entire operational plan
-
getTotalLength
public final Length getTotalLength()
Return the distance the entire operational plan will cover.- Returns:
- the distance of the entire operational plan
-
getEndTime
public final Time getEndTime()
Return the time it will take to complete the entire operational plan.- Returns:
- the time it will take to complete the entire operational plan
-
getEndLocation
public final DirectedPoint getEndLocation()
Provide the end location of this operational plan as a DirectedPoint.- Returns:
- the end location
-
timeAtDistance
public final Time timeAtDistance(Length distance)
Return the time when the GTU will reach the given distance.- Parameters:
distance
- Length; the distance to calculate the time for- Returns:
- the time it will take to have traveled the given distance
-
getLocation
public final DirectedPoint getLocation(Time time) throws OperationalPlanException
Calculate the location at the given time.- Parameters:
time
- Time; the absolute time to look for a location- Returns:
- the location at the given time.
- Throws:
OperationalPlanException
- when the time is after the validity of the operational plan
-
getSpeed
public final Speed getSpeed(Duration time) throws OperationalPlanException
Calculate the speed of the GTU after the given duration since the start of the plan.- Parameters:
time
- Duration; the relative time to look for a location- 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
-
getSpeed
public final Speed getSpeed(Time time) throws OperationalPlanException
Calculate the speed of the GTU at the given time.- Parameters:
time
- Time; the absolute time to look for a location- Returns:
- the location at the given time.
- Throws:
OperationalPlanException
- when the time is after the validity of the operational plan
-
getAcceleration
public final Acceleration getAcceleration(Duration time) throws OperationalPlanException
Calculate the acceleration of the GTU after the given duration since the start of the plan.- Parameters:
time
- Duration; the relative time to look for a location- 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 Acceleration getAcceleration(Time time) throws OperationalPlanException
Calculate the acceleration of the GTU at the given time.- Parameters:
time
- Time; the absolute time to look for a location- Returns:
- the location at the given time.
- Throws:
OperationalPlanException
- when the time is after the validity of the operational plan
-
getLocation
public final DirectedPoint getLocation(Duration time) throws OperationalPlanException
Calculate the location after the given duration since the start of the plan.- Parameters:
time
- Duration; the relative time to look for a location- 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
-
getLocation
public final DirectedPoint getLocation(Time time, RelativePosition pos) throws OperationalPlanException
Calculate the location after the given duration since the start of the plan.- Parameters:
time
- Time; the relative time to look for a locationpos
- RelativePosition; 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
-
getTraveledDistanceSI
public final double getTraveledDistanceSI(Duration duration) throws OperationalPlanException
Calculate the distance traveled as part of this plan after the given duration since the start of the plan. This method returns the traveled distance as a double in SI units.- Parameters:
duration
- Duration; the relative time to calculate the traveled distance- Returns:
- the distance traveled as part of this plan after the given duration since the start of the plan.
- Throws:
OperationalPlanException
- when the time is after the validity of the operational plan
-
getTraveledDistance
public final Length getTraveledDistance(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; the relative time to calculate the traveled distance- Returns:
- the distance traveled as part of this plan after the given duration since the start of the plan.
- Throws:
OperationalPlanException
- when the time is after the validity of the operational plan
-
getTraveledDistanceSI
public final double getTraveledDistanceSI(Time time) throws OperationalPlanException
Calculate the distance traveled as part of this plan at the given absolute time. This method returns the traveled distance as a double in SI units.- Parameters:
time
- Time; the absolute time to calculate the traveled distance for as part of this plan- 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
-
timeAtPoint
public final Time timeAtPoint(DirectedPoint 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
- DirectedPoint; point with angle, which will be projected to the path at 90 degreesupstream
- boolean; true if the point is upstream of the path- Returns:
- Time; time at point
-
getTraveledDistance
public final Length getTraveledDistance(Time time) throws OperationalPlanException
Calculate the distance traveled as part of this plan at the given absolute time.- Parameters:
time
- Time; the absolute time to calculate the traveled distance for as part of this plan- 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
-
-