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
22 * <a href= "http://simulation.tudelft.nl:8085/browse/OTS-113">http://simulation.tudelft.nl:8085/browse/OTS-113</a>.
23 * <p>
24 * Copyright (c) 2013-2020 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 AbstractHeadwayCopy
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 String; 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, final Acceleration acceleration)
46 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 String; 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 String; 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 String; 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)
87 throws GTUException
88 {
89 super(ObjectType.OBJECT, id, overlapFront, overlap, overlapRear);
90 }
91
92 /**
93 * Construct a new Headway information object, for a moving object ahead of us or behind us.
94 * @param id String; the id of the object for comparison purposes, can not be null.
95 * @param distance the distance to the other object; if this constructor is used, distance cannot be null.
96 * @param length Length; the length of the other object, can be null of unknown.
97 * @param speed the (perceived) speed of the other object; can be null if unknown.
98 * @param acceleration the (perceived) acceleration of the other object; can be null if unknown.
99 * @throws GTUException when id is null, objectType is null, or parameters are inconsistent
100 */
101 public HeadwayObject(final String id, final Length distance, final Length length, final Speed speed,
102 final Acceleration acceleration) throws GTUException
103 {
104 super(ObjectType.OBJECT, id, distance, length, speed, acceleration);
105 }
106
107 /**
108 * Construct a new Headway information object, for a non-moving object ahead of us or behind us.
109 * @param id String; the id of the object for comparison purposes, can not be null.
110 * @param distance the distance to the other object; if this constructor is used, distance cannot be null.
111 * @param length Length; the length of the other object, can be null of unknown.
112 * @throws GTUException when id is null, or parameters are inconsistent
113 */
114 public HeadwayObject(final String id, final Length distance, final Length length) throws GTUException
115 {
116 super(ObjectType.OBJECT, id, distance, length);
117 }
118
119 /**
120 * Construct a new Headway information object, for a moving object parallel with us.
121 * @param id String; the id of the object for comparison purposes, can not be null.
122 * @param overlapFront the front-front distance to the other object; if this constructor is used, this value cannot be null.
123 * @param overlap the 'center' overlap with the other object; if this constructor is used, this value cannot be null.
124 * @param overlapRear the rear-rear distance to the other object; if this constructor is used, this value cannot be null.
125 * @param length Length; the length of the other object, can be null of unknown.
126 * @param speed the (perceived) speed of the other object; can be null if unknown.
127 * @param acceleration the (perceived) acceleration of the other object; can be null if unknown.
128 * @throws GTUException when id is null, or parameters are inconsistent
129 */
130 public HeadwayObject(final String id, final Length overlapFront, final Length overlap, final Length overlapRear,
131 final Length length, final Speed speed, final Acceleration acceleration) throws GTUException
132 {
133 super(ObjectType.OBJECT, id, overlapFront, overlap, overlapRear, length, speed, acceleration);
134 }
135
136 /**
137 * Construct a new Headway information object, for a non-moving object parallel with us.
138 * @param id String; the id of the object for comparison purposes, can not be null.
139 * @param overlapFront the front-front distance to the other object; if this constructor is used, this value cannot be null.
140 * @param overlap the 'center' overlap with the other object; if this constructor is used, this value cannot be null.
141 * @param overlapRear the rear-rear distance to the other object; if this constructor is used, this value cannot be null.
142 * @param length Length; the length of the other object, can be null of unknown.
143 * @throws GTUException when id is null, or parameters are inconsistent
144 */
145 public HeadwayObject(final String id, final Length overlapFront, final Length overlap, final Length overlapRear,
146 final Length length) throws GTUException
147 {
148 super(ObjectType.OBJECT, id, overlapFront, overlap, overlapRear, length);
149 }
150
151 /** {@inheritDoc} */
152 @Override
153 public final String toString()
154 {
155 return "HeadwayObject []";
156 }
157
158 }