View Javadoc
1   package org.opentrafficsim.road.gtu.lane.plan.operational;
2   
3   import java.util.List;
4   
5   import org.djunits.value.vdouble.scalar.Duration;
6   import org.djunits.value.vdouble.scalar.Speed;
7   import org.djunits.value.vdouble.scalar.Time;
8   import org.opentrafficsim.core.geometry.OTSLine3D;
9   import org.opentrafficsim.core.gtu.plan.operational.OperationalPlan;
10  import org.opentrafficsim.core.gtu.plan.operational.OperationalPlanException;
11  import org.opentrafficsim.road.gtu.lane.LaneBasedGTU;
12  
13  import nl.tudelft.simulation.language.d3.DirectedPoint;
14  
15  /**
16   * An operational plan with some extra information about the lanes and lane changes so this information does not have to be
17   * recalculated multiple times. Furthermore, it is quite expensive to check whether a lane change is part of the oprtational
18   * plan based on geographical data.
19   * <p>
20   * Copyright (c) 2013-2018 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
21   * BSD-style license. See <a href="http://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
22   * </p>
23   * $LastChangedDate: 2015-07-24 02:58:59 +0200 (Fri, 24 Jul 2015) $, @version $Revision: 1147 $, by $Author: averbraeck $,
24   * initial version Jan 20, 2016 <br>
25   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
26   * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
27   */
28  public class LaneBasedOperationalPlan extends OperationalPlan
29  {
30      /** */
31      private static final long serialVersionUID = 20160120L;
32  
33      /** Deviative; meaning not along lane center lines. */
34      private final boolean deviative;
35  
36      /**
37       * Construct an operational plan with or without a lane change.
38       * @param gtu the GTU for debugging purposes
39       * @param path the path to follow from a certain time till a certain time. The path should have <i>at least</i> the length
40       * @param startTime the absolute start time when we start executing the path
41       * @param startSpeed the GTU speed when we start executing the path
42       * @param operationalPlanSegmentList the segments that make up the path with an acceleration, constant speed or deceleration
43       *            profile
44       * @param deviative whether the path is not along lane center lines
45       * @throws OperationalPlanException when the path is too short for the operation
46       */
47      @SuppressWarnings("checkstyle:parameternumber")
48      public LaneBasedOperationalPlan(final LaneBasedGTU gtu, final OTSLine3D path, final Time startTime, final Speed startSpeed,
49              final List<Segment> operationalPlanSegmentList, final boolean deviative) throws OperationalPlanException
50      {
51          super(gtu, path, startTime, startSpeed, operationalPlanSegmentList);
52          this.deviative = deviative;
53      }
54  
55      /**
56       * Build a plan where the GTU will wait for a certain time. Of course no lane change takes place.
57       * @param gtu the GTU for debugging purposes
58       * @param waitPoint the point at which the GTU will wait
59       * @param startTime the current time or a time in the future when the plan should start
60       * @param duration the waiting time
61       * @param deviative whether the path is not along lane center lines
62       * @throws OperationalPlanException when construction of a waiting path fails
63       */
64      public LaneBasedOperationalPlan(final LaneBasedGTU gtu, final DirectedPoint waitPoint, final Time startTime,
65              final Duration duration, final boolean deviative) throws OperationalPlanException
66      {
67          super(gtu, waitPoint, startTime, duration);
68          this.deviative = deviative;
69      }
70  
71      /**
72       * Check if we deviate from the center line.
73       * @return whether this maneuver involves deviation from the center line.
74       */
75      public final boolean isDeviative()
76      {
77          return this.deviative;
78      }
79  
80      /** {@inheritDoc} */
81      @Override
82      public final String toString()
83      {
84          return "LaneBasedOperationalPlan [deviative=" + this.deviative + "]";
85      }
86  }