1 package org.opentrafficsim.road.gtu.lane.perception.categories;
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.djunits.value.vdouble.scalar.Time;
7 import org.opentrafficsim.base.parameters.ParameterException;
8 import org.opentrafficsim.road.gtu.lane.LaneBasedGTU;
9 import org.opentrafficsim.road.gtu.lane.perception.categories.Anticipation.NeighborTriplet;
10 import org.opentrafficsim.road.gtu.lane.perception.mental.AdaptationSituationalAwareness;
11
12
13
14
15
16
17
18
19
20
21
22
23 public interface Estimation
24 {
25
26 public static final Estimation NONE = new Estimation()
27 {
28 @Override
29 public NeighborTriplet estimate(final LaneBasedGTU perceivingGtu, final LaneBasedGTU perceivedGtu,
30 final Length distance, final boolean downstream, final Time when) throws ParameterException
31 {
32 return new NeighborTriplet(distance, perceivedGtu.getSpeed(), perceivedGtu.getAcceleration());
33 }
34 };
35
36
37 public static final Estimation UNDERESTIMATION = new Estimation()
38 {
39 @Override
40 public NeighborTriplet estimate(final LaneBasedGTU perceivingGtu, final LaneBasedGTU perceivedGtu,
41 final Length distance, final boolean downstream, final Time when) throws ParameterException
42 {
43 double factor = 1.0 - (perceivingGtu.getParameters().getParameter(AdaptationSituationalAwareness.SA_MAX)
44 - perceivingGtu.getParameters().getParameter(AdaptationSituationalAwareness.SA));
45 double delta = (perceivedGtu.getOdometer().si - perceivedGtu.getOdometer(when).si)
46 - (perceivingGtu.getOdometer().si - perceivingGtu.getOdometer(when).si);
47 if (!downstream)
48 {
49 delta = -delta;
50 }
51 Length headway = Length.createSI((distance.si + delta) * factor);
52 double egoSpeed = perceivingGtu.getSpeed(when).si;
53 Speed speed = Speed.createSI(egoSpeed + factor * (perceivedGtu.getSpeed(when).si - egoSpeed));
54 Acceleration acceleration = perceivedGtu.getAcceleration(when);
55 return new NeighborTriplet(headway, speed, acceleration);
56 }
57 };
58
59
60
61
62
63
64
65
66
67
68
69 NeighborTriplet estimate(LaneBasedGTU perceivingGtu, LaneBasedGTU perceivedGtu, Length distance, boolean downstream,
70 Time when) throws ParameterException;
71 }