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 import org.opentrafficsim.core.gtu.behavioralcharacteristics.BehavioralCharacteristics;
8 import org.opentrafficsim.road.gtu.lane.LaneBasedGTU;
9 import org.opentrafficsim.road.gtu.lane.tactical.following.CarFollowingModel;
10 import org.opentrafficsim.road.network.speed.SpeedLimitInfo;
11
12 /**
13 * Container for a reference to information about a (lane based) GTU and a headway. The Headway can store information about GTUs
14 * or objects ahead of the reference GTU, behind the reference GTU, or (partially) parallel to the reference GTU. In addition to
15 * the (perceived) headway, several other pieces of information can be stored, such as (perceived) speed, (perceived)
16 * acceleration, (perceived) turn indicators, and (perceived) braking lights. <br>
17 * This particular version returns behavioral information about the observed GTU objects based on their real state.<br>
18 * Special care must be taken in curves when perceiving headway of a GTU or object on an adjacent lane.The question is whether
19 * we perceive the parallel or ahead/behind based on a line perpendicular to the front/back of the GTU (rectangular), or
20 * perpendicular to the center line of the lane (wedge-shaped in case of a curve). The difficulty of a wedge-shaped situation is
21 * that reciprocity might be violated: in case of a clothoid, for instance, it is not sure that the point on the center line
22 * 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
23 * sharp bends. Therefore, algorithms implementing headway should only project the <i>reference point</i> of the reference GTU
24 * on the center line of the adjacent lane, and then calculate the forward position and backward position on the adjacent lane
25 * based on the reference point. Still, our human perception of what is parallel and what not, is not reflected by fractional
26 * positions. See examples in <a href=
27 * "http://simulation.tudelft.nl:8085/browse/OTS-113">http://simulation.tudelft.nl:8085/browse/OTS-113</a>.
28 * <p>
29 * Copyright (c) 2013-2016 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
30 * BSD-style license. See <a href="http://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
31 * </p>
32 * $LastChangedDate: 2015-07-24 02:58:59 +0200 (Fri, 24 Jul 2015) $, @version $Revision: 1147 $, by $Author: averbraeck $,
33 * initial version May 27, 2016 <br>
34 * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
35 * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
36 * @author <a href="http://www.transport.citg.tudelft.nl">Wouter Schakel</a>
37 */
38 public class HeadwayGTUReal extends AbstractHeadwayGTU
39 {
40 /** */
41 private static final long serialVersionUID = 20160527L;
42
43 /** stored car following model of the observed GTU. */
44 private final CarFollowingModel carFollowingModel;
45
46 /** stored behavioral characteristics of the observed GTU. */
47 private final BehavioralCharacteristics behavioralCharacteristics;
48
49 /** stored speed limit info of the observed GTU. */
50 private final SpeedLimitInfo speedLimitInfo;
51
52 /**
53 * Construct a new Headway information object, for a GTU ahead of us or behind us.
54 * @param gtu the observed GTU, can not be null.
55 * @param distance the distance to the other object; if this constructor is used, distance cannot be null.
56 * @param gtuStatus the observable characteristics of the GTU.
57 * @throws GTUException when id is null, objectType is null, or parameters are inconsistent
58 */
59 public HeadwayGTUReal(final LaneBasedGTU gtu, final Length distance, final GTUStatus... gtuStatus) throws GTUException
60 {
61 super(gtu.getId(), gtu.getGTUType(), distance, gtu.getLength(), gtu.getSpeed(), gtu.getAcceleration(), gtuStatus);
62 this.carFollowingModel = gtu.getTacticalPlanner().getCarFollowingModel();
63 this.behavioralCharacteristics = gtu.getBehavioralCharacteristics();
64 this.speedLimitInfo = null; // TODO obtain speed limit info from GTU
65 }
66
67 /**
68 * Construct a new Headway information object, for a GTU parallel with us.
69 * @param gtu the observed GTU, can not be null.
70 * @param overlapFront the front-front distance to the other GTU; if this constructor is used, this value cannot be null.
71 * @param overlap the 'center' overlap with the other GTU; if this constructor is used, this value cannot be null.
72 * @param overlapRear the rear-rear distance to the other GTU; if this constructor is used, this value cannot be null.
73 * @throws GTUException when id is null, or parameters are inconsistent
74 */
75 public HeadwayGTUReal(final LaneBasedGTU gtu, final Length overlapFront, final Length overlap, final Length overlapRear)
76 throws GTUException
77 {
78 super(gtu.getId(), gtu.getGTUType(), overlapFront, overlap, overlapRear, gtu.getLength(), gtu.getSpeed(), gtu
79 .getAcceleration());
80 this.carFollowingModel = gtu.getTacticalPlanner().getCarFollowingModel();
81 this.behavioralCharacteristics = gtu.getBehavioralCharacteristics();
82 this.speedLimitInfo = null; // TODO obtain speed limit info from GTU
83 }
84
85 /** {@inheritDoc} */
86 @Override
87 public final CarFollowingModel getCarFollowingModel()
88 {
89 return this.carFollowingModel;
90 }
91
92 /** {@inheritDoc} */
93 @Override
94 public final BehavioralCharacteristics getBehavioralCharacteristics()
95 {
96 return this.behavioralCharacteristics;
97 }
98
99 /** {@inheritDoc} */
100 @Override
101 public final SpeedLimitInfo getSpeedLimitInfo()
102 {
103 return this.speedLimitInfo;
104 }
105
106 }