1 package org.opentrafficsim.road.gtu.lane.control;
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.base.parameters.ParameterException;
7 import org.opentrafficsim.base.parameters.ParameterTypeDouble;
8 import org.opentrafficsim.base.parameters.Parameters;
9 import org.opentrafficsim.base.parameters.constraint.NumericConstraint;
10 import org.opentrafficsim.core.gtu.plan.operational.OperationalPlanException;
11 import org.opentrafficsim.road.gtu.lane.LaneBasedGtu;
12 import org.opentrafficsim.road.gtu.lane.perception.PerceptionCollectable;
13 import org.opentrafficsim.road.gtu.lane.perception.RelativeLane;
14 import org.opentrafficsim.road.gtu.lane.perception.categories.InfrastructurePerception;
15 import org.opentrafficsim.road.gtu.lane.perception.headway.HeadwayGtu;
16 import org.opentrafficsim.road.network.speed.SpeedLimitInfo;
17
18
19
20
21
22
23
24
25
26
27
28
29 public abstract class AbstractLinearFreeControl extends AbstractActuatedControl
30 {
31
32
33 public static final ParameterTypeDouble KF =
34 new ParameterTypeDouble("kf", "Desired speed error gain", 0.075, NumericConstraint.POSITIVE);
35
36
37
38
39
40 public AbstractLinearFreeControl(final DelayedActuation delayedActuation)
41 {
42 super(delayedActuation);
43 }
44
45
46 @Override
47 public final Acceleration getDesiredAcceleration(final LaneBasedGtu gtu,
48 final PerceptionCollectable<HeadwayGtu, LaneBasedGtu> leaders, final Parameters settings) throws ParameterException
49 {
50 SpeedLimitInfo speedInfo;
51 try
52 {
53 speedInfo = gtu.getTacticalPlanner().getPerception().getPerceptionCategory(InfrastructurePerception.class)
54 .getSpeedLimitProspect(RelativeLane.CURRENT).getSpeedLimitInfo(Length.ZERO);
55 }
56 catch (OperationalPlanException exception)
57 {
58 throw new RuntimeException("Infrastructure perception is not available.", exception);
59 }
60 Speed v0 = gtu.getTacticalPlanner().getCarFollowingModel().desiredSpeed(gtu.getParameters(), speedInfo);
61 Acceleration a = Acceleration.instantiateSI(settings.getParameter(KF) * (v0.si - gtu.getSpeed().si));
62 if (leaders.isEmpty())
63 {
64 return a;
65 }
66 return Acceleration.min(a, getFollowingAcceleration(gtu, leaders, settings));
67 }
68
69
70
71
72
73
74
75
76
77
78 public abstract Acceleration getFollowingAcceleration(LaneBasedGtu gtu,
79 PerceptionCollectable<HeadwayGtu, LaneBasedGtu> leaders, Parameters settings) throws ParameterException;
80
81 }