1 package org.opentrafficsim.road.gtu.lane.control;
2
3 import org.djunits.value.vdouble.scalar.Acceleration;
4 import org.opentrafficsim.base.parameters.ParameterException;
5 import org.opentrafficsim.base.parameters.ParameterTypeDouble;
6 import org.opentrafficsim.base.parameters.Parameters;
7 import org.opentrafficsim.base.parameters.constraint.NumericConstraint;
8 import org.opentrafficsim.road.gtu.lane.LaneBasedGtu;
9 import org.opentrafficsim.road.gtu.lane.perception.PerceptionCollectable;
10 import org.opentrafficsim.road.gtu.lane.perception.headway.HeadwayGtu;
11
12
13
14
15
16
17
18
19
20
21
22 public class LinearCacc extends LinearAcc
23 {
24
25
26 public static final ParameterTypeDouble KA =
27 new ParameterTypeDouble("ka", "Acceleration error gain", 1.0, NumericConstraint.POSITIVE);
28
29
30
31
32
33 public LinearCacc(final DelayedActuation delayedActuation)
34 {
35 super(delayedActuation);
36 }
37
38
39 @Override
40 public Acceleration getFollowingAcceleration(final LaneBasedGtu gtu,
41 final PerceptionCollectable<HeadwayGtu, LaneBasedGtu> leaders, final Parameters settings) throws ParameterException
42 {
43 HeadwayGtu leader = leaders.first();
44 if (leader.getAcceleration() == null)
45 {
46
47 return super.getFollowingAcceleration(gtu, leaders, settings);
48 }
49 double es =
50 leader.getDistance().si - gtu.getSpeed().si * settings.getParameter(TDCACC).si - settings.getParameter(X0).si;
51 double ev = leader.getSpeed().si - gtu.getSpeed().si;
52 double kaui = settings.getParameter(KA) * leader.getAcceleration().si;
53 return Acceleration.instantiateSI(settings.getParameter(KS) * es + settings.getParameter(KV) * ev + kaui);
54 }
55
56 }