1 package org.opentrafficsim.road.gtu.lane.control;
2
3 import org.djunits.value.vdouble.scalar.Acceleration;
4 import org.djunits.value.vdouble.scalar.Duration;
5 import org.djunits.value.vdouble.scalar.Length;
6 import org.opentrafficsim.base.parameters.ParameterException;
7 import org.opentrafficsim.base.parameters.ParameterTypeDuration;
8 import org.opentrafficsim.base.parameters.ParameterTypeLength;
9 import org.opentrafficsim.base.parameters.Parameters;
10 import org.opentrafficsim.base.parameters.constraint.NumericConstraint;
11 import org.opentrafficsim.core.gtu.plan.operational.OperationalPlanException;
12 import org.opentrafficsim.road.gtu.lane.LaneBasedGtu;
13 import org.opentrafficsim.road.gtu.lane.perception.PerceptionCollectable;
14 import org.opentrafficsim.road.gtu.lane.perception.categories.neighbors.LongitudinalControllerPerception;
15 import org.opentrafficsim.road.gtu.lane.perception.headway.HeadwayGtu;
16
17
18
19
20
21
22
23
24
25
26
27 public abstract class AbstractActuatedControl implements LongitudinalControl
28 {
29
30
31 public static final ParameterTypeDuration TDACC = new ParameterTypeDuration("td ACC",
32 "User defined time headway in ACC mode", Duration.instantiateSI(1.2), NumericConstraint.POSITIVE);
33
34
35 public static final ParameterTypeDuration TDCACC = new ParameterTypeDuration("td CACC",
36 "User defined time headway in CACC mode", Duration.instantiateSI(0.5), NumericConstraint.POSITIVE);
37
38
39 public static final ParameterTypeLength X0 = new ParameterTypeLength("x0 (C)ACC", "Stopping distance (C)ACC",
40 Length.instantiateSI(3.0), NumericConstraint.POSITIVE);
41
42
43 private final DelayedActuation delayedActuation;
44
45
46
47
48
49 public AbstractActuatedControl(final DelayedActuation delayedActuation)
50 {
51 this.delayedActuation = delayedActuation;
52 }
53
54
55
56
57
58
59
60 public Acceleration delayActuation(final Acceleration desiredAcceleration, final LaneBasedGtu gtu)
61 {
62 return this.delayedActuation.delayActuation(desiredAcceleration, gtu);
63 }
64
65 @Override
66 public Acceleration getAcceleration(final LaneBasedGtu gtu, final Parameters settings)
67 {
68 try
69 {
70 PerceptionCollectable<HeadwayGtu, LaneBasedGtu> leaders = gtu.getTacticalPlanner().getPerception()
71 .getPerceptionCategory(LongitudinalControllerPerception.class).getLeaders();
72 return delayActuation(getDesiredAcceleration(gtu, leaders, settings), gtu);
73 }
74 catch (OperationalPlanException exception)
75 {
76 throw new RuntimeException("Missing perception category LongitudinalControllerPerception", exception);
77 }
78 catch (ParameterException exception)
79 {
80 throw new RuntimeException("Missing parameter", exception);
81 }
82 }
83
84
85
86
87
88
89
90
91
92 public abstract Acceleration getDesiredAcceleration(LaneBasedGtu gtu,
93 PerceptionCollectable<HeadwayGtu, LaneBasedGtu> leaders, Parameters settings) throws ParameterException;
94
95 }