1 package org.opentrafficsim.road.gtu.control;
2
3 import org.djunits.value.vdouble.scalar.Acceleration;
4 import org.djunits.value.vdouble.scalar.Speed;
5 import org.opentrafficsim.base.parameters.ParameterException;
6 import org.opentrafficsim.base.parameters.ParameterTypeDouble;
7 import org.opentrafficsim.base.parameters.Parameters;
8 import org.opentrafficsim.base.parameters.constraint.NumericConstraint;
9 import org.opentrafficsim.road.gtu.LaneBasedGtu;
10 import org.opentrafficsim.road.gtu.perception.PerceptionCollectable;
11 import org.opentrafficsim.road.gtu.perception.object.PerceivedGtu;
12 import org.opentrafficsim.road.network.speed.SpeedLimits;
13
14
15
16
17
18
19
20
21
22
23
24
25 public abstract class AbstractLinearFreeControl extends AbstractActuatedControl
26 {
27
28
29 public static final ParameterTypeDouble KF =
30 new ParameterTypeDouble("kf", "Desired speed error gain", 0.075, NumericConstraint.POSITIVE);
31
32
33
34
35
36 public AbstractLinearFreeControl(final DelayedActuation delayedActuation)
37 {
38 super(delayedActuation);
39 }
40
41 @Override
42 public final Acceleration getDesiredAcceleration(final LaneBasedGtu gtu,
43 final PerceptionCollectable<PerceivedGtu, LaneBasedGtu> leaders, final Parameters settings)
44 throws ParameterException
45 {
46 SpeedLimits speedLimits = gtu.getLane().getSpeedLimits(gtu.getType());
47 Speed v0 = gtu.getTacticalPlanner().getCarFollowingModel().desiredSpeed(gtu.getParameters(), speedLimits,
48 gtu.getMaximumSpeed());
49 Acceleration a = Acceleration.ofSI(settings.getParameter(KF) * (v0.si - gtu.getSpeed().si));
50 if (leaders.isEmpty())
51 {
52 return a;
53 }
54 return Acceleration.min(a, getFollowingAcceleration(gtu, leaders, settings));
55 }
56
57
58
59
60
61
62
63
64
65
66 public abstract Acceleration getFollowingAcceleration(LaneBasedGtu gtu,
67 PerceptionCollectable<PerceivedGtu, LaneBasedGtu> leaders, Parameters settings) throws ParameterException;
68
69 }