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.core.gtu.GTUException;
7   
8   /**
9    * Container for a reference to information about a (lane based) object and a headway. The Headway can store information about
10   * objects ahead of the reference object, behind the reference object, or (partially) parallel to the reference object. In
11   * addition to the (perceived) headway, several other pieces of information can be stored, such as (perceived) speed,
12   * (perceived) acceleration, (perceived) turn indicators, and (perceived) braking lights. <br>
13   * Special care must be taken in curves when perceiving headway of an object on an adjacent lane.The question is whether we
14   * perceive the parallel or ahead/behind based on a line perpendicular to the front/back of the object (rectangular), or
15   * perpendicular to the center line of the lane (wedge-shaped in case of a curve). The difficulty of a wedge-shaped situation is
16   * that reciprocity might be violated: in case of a clothoid, for instance, it is not sure that the point on the center line
17   * 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
18   * sharp bends. Therefore, algorithms implementing headway should only project the <i>reference point</i> of the reference
19   * object on the center line of the adjacent lane, and then calculate the forward position and backward position on the adjacent
20   * lane based on the reference point. Still, our human perception of what is parallel and what not, is not reflected by
21   * fractional positions. See examples in <a href=
22   * "http://simulation.tudelft.nl:8085/browse/OTS-113">http://simulation.tudelft.nl:8085/browse/OTS-113</a>.
23   * <p>
24   * Copyright (c) 2013-2016 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
25   * BSD-style license. See <a href="http://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
26   * <p>
27   * @version $Revision: 1368 $, $LastChangedDate: 2015-09-02 00:20:20 +0200 (Wed, 02 Sep 2015) $, by $Author: averbraeck $,
28   *          initial version 11 feb. 2015 <br>
29   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
30   * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
31   */
32  public class HeadwayObject extends AbstractHeadway
33  {
34      /** */
35      private static final long serialVersionUID = 20160410L;
36  
37      /**
38       * Construct a new Headway information object, for a moving object ahead of us or behind us.
39       * @param id the id of the object for comparison purposes, can not be null.
40       * @param distance the distance to the other object; if this constructor is used, distance cannot be null.
41       * @param speed the (perceived) speed of the other object; can be null if unknown.
42       * @param acceleration the (perceived) acceleration of the other object; can be null if unknown.
43       * @throws GTUException when id is null, objectType is null, or parameters are inconsistent
44       */
45      public HeadwayObject(final String id, final Length distance, final Speed speed,
46          final Acceleration acceleration) throws GTUException
47      {
48          super(ObjectType.OBJECT, id, distance, speed, acceleration);
49      }
50  
51      /**
52       * Construct a new Headway information object, for a non-moving object ahead of us or behind us.
53       * @param id the id of the object for comparison purposes, can not be null.
54       * @param distance the distance to the other object; if this constructor is used, distance cannot be null.
55       * @throws GTUException when id is null, or parameters are inconsistent
56       */
57      public HeadwayObject(final String id, final Length distance) throws GTUException
58      {
59          super(ObjectType.OBJECT, id, distance);
60      }
61  
62      /**
63       * Construct a new Headway information object, for a moving object parallel with us.
64       * @param id the id of the object for comparison purposes, can not be null.
65       * @param overlapFront the front-front distance to the other object; if this constructor is used, this value cannot be null.
66       * @param overlap the 'center' overlap with the other object; if this constructor is used, this value cannot be null.
67       * @param overlapRear the rear-rear distance to the other object; if this constructor is used, this value cannot be null.
68       * @param speed the (perceived) speed of the other object; can be null if unknown.
69       * @param acceleration the (perceived) acceleration of the other object; can be null if unknown.
70       * @throws GTUException when id is null, or parameters are inconsistent
71       */
72      public HeadwayObject(final String id, final Length overlapFront, final Length overlap, final Length overlapRear,
73          final Speed speed, final Acceleration acceleration) throws GTUException
74      {
75          super(ObjectType.OBJECT, id, overlapFront, overlap, overlapRear, speed, acceleration);
76      }
77  
78      /**
79       * Construct a new Headway information object, for a non-moving object parallel with us.
80       * @param id the id of the object for comparison purposes, can not be null.
81       * @param overlapFront the front-front distance to the other object; if this constructor is used, this value cannot be null.
82       * @param overlap the 'center' overlap with the other object; if this constructor is used, this value cannot be null.
83       * @param overlapRear the rear-rear distance to the other object; if this constructor is used, this value cannot be null.
84       * @throws GTUException when id is null, or parameters are inconsistent
85       */
86      public HeadwayObject(final String id, final Length overlapFront, final Length overlap, final Length overlapRear) throws GTUException
87      {
88          super(ObjectType.OBJECT, id, overlapFront, overlap, overlapRear);
89      }
90      
91      /**
92       * Construct a new Headway information object, for a moving object ahead of us or behind us.
93       * @param id the id of the object for comparison purposes, can not be null.
94       * @param distance the distance to the other object; if this constructor is used, distance cannot be null.
95       * @param length the length of the other object, can be null of unknown.
96       * @param speed the (perceived) speed of the other object; can be null if unknown.
97       * @param acceleration the (perceived) acceleration of the other object; can be null if unknown.
98       * @throws GTUException when id is null, objectType is null, or parameters are inconsistent
99       */
100     public HeadwayObject(final String id, final Length distance, final Length length, final Speed speed,
101         final Acceleration acceleration) throws GTUException
102     {
103         super(ObjectType.OBJECT, id, distance, length, speed, acceleration);
104     }
105 
106     /**
107      * Construct a new Headway information object, for a non-moving object ahead of us or behind us.
108      * @param id the id of the object for comparison purposes, can not be null.
109      * @param distance the distance to the other object; if this constructor is used, distance cannot be null.
110      * @param length the length of the other object, can be null of unknown.
111      * @throws GTUException when id is null, or parameters are inconsistent
112      */
113     public HeadwayObject(final String id, final Length distance, final Length length) throws GTUException
114     {
115         super(ObjectType.OBJECT, id, distance, length);
116     }
117 
118     /**
119      * Construct a new Headway information object, for a moving object parallel with us.
120      * @param id the id of the object for comparison purposes, can not be null.
121      * @param overlapFront the front-front distance to the other object; if this constructor is used, this value cannot be null.
122      * @param overlap the 'center' overlap with the other object; if this constructor is used, this value cannot be null.
123      * @param overlapRear the rear-rear distance to the other object; if this constructor is used, this value cannot be null.
124      * @param length the length of the other object, can be null of unknown.
125      * @param speed the (perceived) speed of the other object; can be null if unknown.
126      * @param acceleration the (perceived) acceleration of the other object; can be null if unknown.
127      * @throws GTUException when id is null, or parameters are inconsistent
128      */
129     public HeadwayObject(final String id, final Length overlapFront, final Length overlap, final Length overlapRear,
130         final Length length, final Speed speed, final Acceleration acceleration) throws GTUException
131     {
132         super(ObjectType.OBJECT, id, overlapFront, overlap, overlapRear, length, speed, acceleration);
133     }
134 
135     /**
136      * Construct a new Headway information object, for a non-moving object parallel with us.
137      * @param id the id of the object for comparison purposes, can not be null.
138      * @param overlapFront the front-front distance to the other object; if this constructor is used, this value cannot be null.
139      * @param overlap the 'center' overlap with the other object; if this constructor is used, this value cannot be null.
140      * @param overlapRear the rear-rear distance to the other object; if this constructor is used, this value cannot be null.
141      * @param length the length of the other object, can be null of unknown.
142      * @throws GTUException when id is null, or parameters are inconsistent
143      */
144     public HeadwayObject(final String id, final Length overlapFront, final Length overlap, final Length overlapRear,
145         final Length length) throws GTUException
146     {
147         super(ObjectType.OBJECT, id, overlapFront, overlap, overlapRear, length);
148     }
149 
150     /** {@inheritDoc} */
151     @Override
152     public final String toString()
153     {
154         return "HeadwayObject []";
155     }
156 
157 }