View Javadoc
1   package org.opentrafficsim.road.gtu.lane;
2   
3   import java.util.Set;
4   
5   import nl.tudelft.simulation.dsol.SimRuntimeException;
6   
7   import org.djunits.value.vdouble.scalar.Length;
8   import org.djunits.value.vdouble.scalar.Speed;
9   import org.opentrafficsim.core.dsol.OTSDEVSSimulatorInterface;
10  import org.opentrafficsim.core.geometry.OTSGeometryException;
11  import org.opentrafficsim.core.gtu.GTUException;
12  import org.opentrafficsim.core.gtu.GTUType;
13  import org.opentrafficsim.core.network.NetworkException;
14  import org.opentrafficsim.core.network.OTSNetwork;
15  import org.opentrafficsim.road.gtu.lane.perception.LanePerceptionFull;
16  import org.opentrafficsim.road.gtu.strategical.LaneBasedStrategicalPlanner;
17  import org.opentrafficsim.road.network.lane.DirectedLanePosition;
18  
19  /**
20   * Specific type of LaneBasedGTU. This class adds length, width, maximum velocity and a reference to the simulator to the
21   * AbstractLaneBasedGTU.
22   * <p>
23   * Copyright (c) 2013-2015 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
24   * BSD-style license. See <a href="http://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
25   * <p>
26   * @version $Revision: 1401 $, $LastChangedDate: 2015-09-14 01:33:02 +0200 (Mon, 14 Sep 2015) $, by $Author: averbraeck $,
27   *          initial version Jan 1, 2015 <br>
28   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
29   * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
30   */
31  public abstract class AbstractLaneBasedIndividualGTU extends AbstractLaneBasedGTU
32  {
33      /** */
34      private static final long serialVersionUID = 20140822L;
35  
36      /** The maximum length of the GTU (parallel with driving direction). */
37      private final Length.Rel length;
38  
39      /** The maximum width of the GTU (perpendicular to driving direction). */
40      private final Length.Rel width;
41  
42      /** The maximum speed of the GTU (in the driving direction). */
43      private final Speed maximumVelocity;
44  
45      /**
46       * Construct a new AbstractLaneBasedIndividualGTU.
47       * @param id the id of the GTU
48       * @param gtuType the type of GTU, e.g. TruckType, CarType, BusType
49       * @param initialLongitudinalPositions the initial positions of the car on one or more lanes
50       * @param initialSpeed the initial speed of the car on the lane
51       * @param length the maximum length of the GTU (parallel with driving direction)
52       * @param width the maximum width of the GTU (perpendicular to driving direction)
53       * @param maximumVelocity the maximum speed of the GTU (in the driving direction)
54       * @param simulator the simulator
55       * @param strategicalPlanner the strategical planner (e.g., route determination) to use
56       * @param perception the lane-based perception model of the GTU
57       * @param network the network that the GTU is initially registered in
58       * @throws NetworkException when the GTU cannot be placed on the given lane
59       * @throws SimRuntimeException when the move method cannot be scheduled
60       * @throws GTUException when a parameter is invalid
61       * @throws OTSGeometryException when the initial path is wrong
62       */
63      @SuppressWarnings("checkstyle:parameternumber")
64      public AbstractLaneBasedIndividualGTU(final String id, final GTUType gtuType,
65          final Set<DirectedLanePosition> initialLongitudinalPositions, final Speed initialSpeed,
66          final Length.Rel length, final Length.Rel width, final Speed maximumVelocity,
67          final OTSDEVSSimulatorInterface simulator, final LaneBasedStrategicalPlanner strategicalPlanner,
68          final LanePerceptionFull perception, final OTSNetwork network) throws NetworkException, SimRuntimeException,
69          GTUException, OTSGeometryException
70      {
71          super(id, gtuType, initialLongitudinalPositions, initialSpeed, simulator, strategicalPlanner, perception,
72              network);
73          this.length = length;
74          this.width = width;
75          if (null == maximumVelocity)
76          {
77              throw new GTUException("maximumVelocity may not be null");
78          }
79          this.maximumVelocity = maximumVelocity;
80      }
81  
82      /** {@inheritDoc} */
83      @Override
84      public final Length.Rel getLength()
85      {
86          return this.length;
87      }
88  
89      /** {@inheritDoc} */
90      @Override
91      public final Length.Rel getWidth()
92      {
93          return this.width;
94      }
95  
96      /** {@inheritDoc} */
97      @Override
98      public final Speed getMaximumVelocity()
99      {
100         return this.maximumVelocity;
101     }
102 
103 }