View Javadoc
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   * Simple linear CACC implementation.
14   * <p>
15   * Copyright (c) 2013-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
16   * BSD-style license. See <a href="http://opentrafficsim.org/node/13">OpenTrafficSim License</a>.
17   * <p>
18   * @version $Revision$, $LastChangedDate$, by $Author$, initial version Mar 13, 2019 <br>
19   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
20   * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
21   * @author <a href="http://www.transport.citg.tudelft.nl">Wouter Schakel</a>
22   */
23  public class LinearCACC extends AbstractLinearFreeControl
24  {
25  
26      /**
27       * Constructor using default sensors with no delay.
28       * @param delayedActuation DelayedActuation; delayed actuation
29       */
30      public LinearCACC(final DelayedActuation delayedActuation)
31      {
32          super(delayedActuation);
33      }
34  
35      /** Gap error gain parameter. */
36      public static final ParameterTypeDouble KS =
37              new ParameterTypeDouble("ks", "Gap error gain", 0.2, NumericConstraint.POSITIVE);
38  
39      /** Speed error gain parameter. */
40      public static final ParameterTypeDouble KV =
41              new ParameterTypeDouble("kv", "Speed error gain", 0.4, NumericConstraint.POSITIVE);
42  
43      /** Acceleration error gain parameter. */
44      public static final ParameterTypeDouble KA =
45              new ParameterTypeDouble("ka", "Acceleration error gain", 1.0, NumericConstraint.POSITIVE);
46  
47      /** {@inheritDoc} */
48      @Override
49      public Acceleration getFollowingAcceleration(final LaneBasedGTU gtu,
50              final PerceptionCollectable<HeadwayGTU, LaneBasedGTU> leaders) throws ParameterException
51      {
52          Parameters params = gtu.getParameters();
53          HeadwayGTU leader = leaders.first();
54          double es;
55          double kaui;
56          if (leader.getAcceleration() == null)
57          {
58              // ACC mode
59              es = leader.getDistance().si - gtu.getSpeed().si * params.getParameter(TDACC).si - params.getParameter(X0).si;
60              kaui = 0.0;
61          }
62          else
63          {
64              // CACC mode
65              es = leader.getDistance().si - gtu.getSpeed().si * params.getParameter(TDCACC).si - params.getParameter(X0).si;
66              kaui = params.getParameter(KA) * leader.getAcceleration().si;
67          }
68          double ev = leader.getSpeed().si - gtu.getSpeed().si;
69          return Acceleration.createSI(params.getParameter(KS) * es + params.getParameter(KV) * ev + kaui);
70      }
71  
72  }