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-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
16   * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
17   * </p>
18   * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
19   * @author <a href="https://tudelft.nl/staff/p.knoppers-1">Peter Knoppers</a>
20   * @author <a href="https://github.com/wjschakel">Wouter Schakel</a>
21   */
22  public class LinearCacc extends LinearAcc
23  {
24  
25      /** Acceleration error gain parameter. */
26      public static final ParameterTypeDouble KA =
27              new ParameterTypeDouble("ka", "Acceleration error gain", 1.0, NumericConstraint.POSITIVE);
28  
29      /**
30       * Constructor using default sensors with no delay.
31       * @param delayedActuation DelayedActuation; delayed actuation
32       */
33      public LinearCacc(final DelayedActuation delayedActuation)
34      {
35          super(delayedActuation);
36      }
37  
38      /** {@inheritDoc} */
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              // ACC mode
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  }