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   * <p>
14   * Copyright (c) 2013-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
15   * BSD-style license. See <a href="http://opentrafficsim.org/node/13">OpenTrafficSim License</a>.
16   * <p>
17   * @version $Revision$, $LastChangedDate$, by $Author$, initial version Apr 11, 2019 <br>
18   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
19   * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
20   * @author <a href="http://www.transport.citg.tudelft.nl">Wouter Schakel</a>
21   */
22  public class LinearACC extends AbstractLinearFreeControl
23  {
24  
25      /** Gap error gain parameter. */
26      public static final ParameterTypeDouble KS =
27              new ParameterTypeDouble("ks", "Gap error gain", 0.2, NumericConstraint.POSITIVE);
28  
29      /** Speed error gain parameter. */
30      public static final ParameterTypeDouble KV =
31              new ParameterTypeDouble("kv", "Speed error gain", 0.4, NumericConstraint.POSITIVE);
32  
33      /**
34       * Constructor using default sensors with no delay.
35       * @param delayedActuation DelayedActuation; delayed actuation
36       */
37      public LinearACC(final DelayedActuation delayedActuation)
38      {
39          super(delayedActuation);
40      }
41  
42      /** {@inheritDoc} */
43      @Override
44      public Acceleration getFollowingAcceleration(final LaneBasedGTU gtu,
45              final PerceptionCollectable<HeadwayGTU, LaneBasedGTU> leaders, final Parameters settings) throws ParameterException
46      {
47          HeadwayGTU leader = leaders.first();
48          double es =
49                  leader.getDistance().si - gtu.getSpeed().si * settings.getParameter(TDACC).si - settings.getParameter(X0).si;
50          double ev = leader.getSpeed().si - gtu.getSpeed().si;
51          return Acceleration.instantiateSI(settings.getParameter(KS) * es + settings.getParameter(KV) * ev);
52      }
53  
54  }