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-2020 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 LinearACC
24  {
25  
26      /** Acceleration error gain parameter. */
27      public static final ParameterTypeDouble KA =
28              new ParameterTypeDouble("ka", "Acceleration error gain", 1.0, NumericConstraint.POSITIVE);
29  
30      /**
31       * Constructor using default sensors with no delay.
32       * @param delayedActuation DelayedActuation; delayed actuation
33       */
34      public LinearCACC(final DelayedActuation delayedActuation)
35      {
36          super(delayedActuation);
37      }
38  
39      /** {@inheritDoc} */
40      @Override
41      public Acceleration getFollowingAcceleration(final LaneBasedGTU gtu,
42              final PerceptionCollectable<HeadwayGTU, LaneBasedGTU> leaders, final Parameters settings) throws ParameterException
43      {
44          HeadwayGTU leader = leaders.first();
45          if (leader.getAcceleration() == null)
46          {
47              // ACC mode
48              return super.getFollowingAcceleration(gtu, leaders, settings);
49          }
50          double es =
51                  leader.getDistance().si - gtu.getSpeed().si * settings.getParameter(TDCACC).si - settings.getParameter(X0).si;
52          double ev = leader.getSpeed().si - gtu.getSpeed().si;
53          double kaui = settings.getParameter(KA) * leader.getAcceleration().si;
54          return Acceleration.instantiateSI(settings.getParameter(KS) * es + settings.getParameter(KV) * ev + kaui);
55      }
56  
57  }