View Javadoc
1   package org.opentrafficsim.road.gtu.lane.perception.headway;
2   
3   import org.djunits.value.vdouble.scalar.Acceleration;
4   import org.djunits.value.vdouble.scalar.Length;
5   import org.djunits.value.vdouble.scalar.Speed;
6   import org.opentrafficsim.base.parameters.Parameters;
7   import org.opentrafficsim.core.gtu.GTUException;
8   import org.opentrafficsim.core.gtu.GTUType;
9   import org.opentrafficsim.core.network.route.Route;
10  import org.opentrafficsim.road.gtu.lane.tactical.following.CarFollowingModel;
11  import org.opentrafficsim.road.network.speed.SpeedLimitInfo;
12  
13  /**
14   * Container for a reference to information about a (lane based) GTU and a headway. The Headway can store information about GTUs
15   * or objects ahead of the reference GTU, behind the reference GTU, or (partially) parallel to the reference GTU. In addition to
16   * the (perceived) headway, several other pieces of information can be stored, such as (perceived) speed, (perceived)
17   * acceleration, (perceived) turn indicators, and (perceived) braking lights. <br>
18   * This particular version has only limited behavioral information about the observed GTU.<br>
19   * Special care must be taken in curves when perceiving headway of a GTU or object on an adjacent lane.The question is whether
20   * we perceive the parallel or ahead/behind based on a line perpendicular to the front/back of the GTU (rectangular), or
21   * perpendicular to the center line of the lane (wedge-shaped in case of a curve). The difficulty of a wedge-shaped situation is
22   * that reciprocity might be violated: in case of a clothoid, for instance, it is not sure that the point on the center line
23   * when projected from lane 1 to lane 2 is the same as the projection from lane 2 to lane 1. The same holds for shapes with
24   * sharp bends. Therefore, algorithms implementing headway should only project the <i>reference point</i> of the reference GTU
25   * on the center line of the adjacent lane, and then calculate the forward position and backward position on the adjacent lane
26   * based on the reference point. Still, our human perception of what is parallel and what not, is not reflected by fractional
27   * positions. See examples in
28   * <a href= "http://simulation.tudelft.nl:8085/browse/OTS-113">http://simulation.tudelft.nl:8085/browse/OTS-113</a>.
29   * <p>
30   * Copyright (c) 2013-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
31   * BSD-style license. See <a href="http://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
32   * </p>
33   * $LastChangedDate: 2015-07-24 02:58:59 +0200 (Fri, 24 Jul 2015) $, @version $Revision: 1147 $, by $Author: averbraeck $,
34   * initial version May 27, 2016 <br>
35   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
36   * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
37   * @author <a href="http://www.transport.citg.tudelft.nl">Wouter Schakel</a>
38   */
39  public class HeadwayGTUSimple extends AbstractHeadwayGTU
40  {
41      /** */
42      private static final long serialVersionUID = 20160527L;
43  
44      /**
45       * Construct a new Headway information object, for a moving GTU ahead of us or behind us.
46       * @param id String; the id of the GTU for comparison purposes, can not be null.
47       * @param gtuType GTUType; the perceived GTU Type, or null if unknown.
48       * @param distance the distance to the other object; if this constructor is used, distance cannot be null.
49       * @param length the length of the other object; if this constructor is used, length cannot be null.
50       * @param width the (perceived) width of the other object; can not be null.
51       * @param speed the (perceived) speed of the other object; can be null if unknown.
52       * @param acceleration the (perceived) acceleration of the other object; can be null if unknown.
53       * @param desiredSpeed Speed; desired speed
54       * @param gtuStatus GTUStatus...; the observable characteristics of the GTU.
55       * @throws GTUException when id is null, objectType is null, or parameters are inconsistent
56       */
57      public HeadwayGTUSimple(final String id, final GTUType gtuType, final Length distance, final Length length,
58              final Length width, final Speed speed, final Acceleration acceleration, final Speed desiredSpeed,
59              final GTUStatus... gtuStatus) throws GTUException
60      {
61          super(id, gtuType, distance, true, length, width, speed, acceleration, desiredSpeed, gtuStatus);
62      }
63  
64      /**
65       * Construct a new Headway information object, for a non-moving GTU ahead of us or behind us.
66       * @param id String; the id of the GTU for comparison purposes, can not be null.
67       * @param gtuType GTUType; the perceived GTU Type, or null if unknown.
68       * @param distance Length; the distance to the other GTU; if this constructor is used, distance cannot be null.
69       * @param length the length of the other object; if this constructor is used, length cannot be null.
70       * @param width the (perceived) width of the other object; can not be null.
71       * @param desiredSpeed Speed; desired speed
72       * @param gtuStatus GTUStatus...; the observable characteristics of the GTU.
73       * @throws GTUException when id is null, or parameters are inconsistent
74       */
75      public HeadwayGTUSimple(final String id, final GTUType gtuType, final Length distance, final Length length,
76              final Length width, final Speed desiredSpeed, final GTUStatus... gtuStatus) throws GTUException
77      {
78          super(id, gtuType, distance, true, length, width, desiredSpeed, gtuStatus);
79      }
80  
81      /**
82       * Construct a new Headway information object, for a moving GTU parallel with us.
83       * @param id String; the id of the GTU for comparison purposes, can not be null.
84       * @param gtuType GTUType; the perceived GTU Type, or null if unknown.
85       * @param overlapFront the front-front distance to the other GTU; if this constructor is used, this value cannot be null.
86       * @param overlap the 'center' overlap with the other GTU; if this constructor is used, this value cannot be null.
87       * @param overlapRear the rear-rear distance to the other GTU; if this constructor is used, this value cannot be null.
88       * @param length the length of the other object; if this constructor is used, length cannot be null.
89       * @param width the (perceived) width of the other object; can not be null.
90       * @param speed the (perceived) speed of the other GTU; can be null if unknown.
91       * @param acceleration the (perceived) acceleration of the other GTU; can be null if unknown.
92       * @param desiredSpeed Speed; desired speed
93       * @param gtuStatus GTUStatus...; the observable characteristics of the GTU.
94       * @throws GTUException when id is null, or parameters are inconsistent
95       */
96      @SuppressWarnings("checkstyle:parameternumber")
97      public HeadwayGTUSimple(final String id, final GTUType gtuType, final Length overlapFront, final Length overlap,
98              final Length overlapRear, final Length length, final Length width, final Speed speed,
99              final Acceleration acceleration, final Speed desiredSpeed, final GTUStatus... gtuStatus) throws GTUException
100     {
101         super(id, gtuType, overlapFront, overlap, overlapRear, true, length, width, speed, acceleration, desiredSpeed,
102                 gtuStatus);
103     }
104 
105     /**
106      * Construct a new Headway information object, for a non-moving GTU parallel with us.
107      * @param id String; the id of the GTU for comparison purposes, can not be null.
108      * @param gtuType GTUType; the perceived GTU Type, or null if unknown.
109      * @param overlapFront the front-front distance to the other GTU; if this constructor is used, this value cannot be null.
110      * @param overlap the 'center' overlap with the other GTU; if this constructor is used, this value cannot be null.
111      * @param overlapRear the rear-rear distance to the other GTU; if this constructor is used, this value cannot be null.
112      * @param length the length of the other object; if this constructor is used, length cannot be null.
113      * @param width the (perceived) width of the other object; can not be null.
114      * @param desiredSpeed Speed; desired speed
115      * @param gtuStatus GTUStatus...; the observable characteristics of the GTU.
116      * @throws GTUException when id is null, or parameters are inconsistent
117      */
118     public HeadwayGTUSimple(final String id, final GTUType gtuType, final Length overlapFront, final Length overlap,
119             final Length overlapRear, final Length length, final Length width, final Speed desiredSpeed,
120             final GTUStatus... gtuStatus) throws GTUException
121     {
122         super(id, gtuType, overlapFront, overlap, overlapRear, true, length, width, desiredSpeed, gtuStatus);
123     }
124 
125     /** {@inheritDoc} */
126     @Override
127     public final CarFollowingModel getCarFollowingModel()
128     {
129         throw new UnsupportedOperationException("HeadwayGTUSimple does not support the getCarFollowingModel() method.");
130     }
131 
132     /** {@inheritDoc} */
133     @Override
134     public final Parameters getParameters()
135     {
136         throw new UnsupportedOperationException("HeadwayGTUSimple does not support the getParameters() method.");
137     }
138 
139     /** {@inheritDoc} */
140     @Override
141     public final SpeedLimitInfo getSpeedLimitInfo()
142     {
143         throw new UnsupportedOperationException("HeadwayGTUSimple does not support the getSpeedLimitInfo() method.");
144     }
145 
146     /** {@inheritDoc} */
147     @Override
148     public final Route getRoute()
149     {
150         return null;
151     }
152 
153     /** {@inheritDoc} */
154     @Override
155     public final AbstractHeadwayGTU moved(final Length headway, final Speed speed, final Acceleration acceleration)
156     {
157         try
158         {
159             return new HeadwayGTUSimple(getId(), getGtuType(), headway, getLength(), getWidth(), speed, acceleration,
160                     getDesiredSpeed(), getGtuStatus());
161         }
162         catch (GTUException exception)
163         {
164             // input should be consistent
165             throw new RuntimeException("Exception while copying Headway GTU.", exception);
166         }
167     }
168 
169     /** {@inheritDoc} */
170     @Override
171     public final String toString()
172     {
173         return "HeadwayGTUSimple [length=" + super.getLength() + "]";
174     }
175 
176 }