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   * Linear CACC implementation based on derivatives by Jeroen Ploeg.
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 PloegCACC extends LinearCACC
24  {
25  
26      /**
27       * Constructor using default sensors with no delay.
28       * @param delayedActuation DelayedActuation; delayed actuation
29       */
30      public PloegCACC(final DelayedActuation delayedActuation)
31      {
32          super(delayedActuation);
33      }
34  
35      /** Gap error derivative gain parameter. */
36      public static final ParameterTypeDouble KD =
37              new ParameterTypeDouble("kd", "Gap error derivative gain", 0.7, NumericConstraint.POSITIVE);
38  
39      /** {@inheritDoc} */
40      @Override
41      public Acceleration getFollowingAcceleration(final LaneBasedGTU gtu,
42              final PerceptionCollectable<HeadwayGTU, LaneBasedGTU> leaders) throws ParameterException
43      {
44          Parameters params = gtu.getParameters();
45          HeadwayGTU leader = leaders.first();
46          double es;
47          double esd;
48          double kaui;
49          if (leader.getAcceleration() == null)
50          {
51              // ACC mode
52              es = leader.getDistance().si - gtu.getSpeed().si * params.getParameter(TDACC).si - params.getParameter(X0).si;
53              esd = leader.getSpeed().si - gtu.getSpeed().si - gtu.getAcceleration().si * params.getParameter(TDACC).si;
54              kaui = 0.0;
55          }
56          else
57          {
58              // CACC mode
59              es = leader.getDistance().si - gtu.getSpeed().si * params.getParameter(TDCACC).si - params.getParameter(X0).si;
60              esd = leader.getSpeed().si - gtu.getSpeed().si - gtu.getAcceleration().si * params.getParameter(TDCACC).si;
61              kaui = params.getParameter(KA) * leader.getAcceleration().si;
62          }
63          return Acceleration.createSI(params.getParameter(KS) * es + params.getParameter(KD) * esd + kaui);
64      }
65  
66  }