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-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
15   * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
16   * </p>
17   * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
18   * @author <a href="https://tudelft.nl/staff/p.knoppers-1">Peter Knoppers</a>
19   * @author <a href="https://github.com/wjschakel">Wouter Schakel</a>
20   */
21  public class LinearAcc extends AbstractLinearFreeControl
22  {
23  
24      /** Gap error gain parameter. */
25      public static final ParameterTypeDouble KS =
26              new ParameterTypeDouble("ks", "Gap error gain", 0.2, NumericConstraint.POSITIVE);
27  
28      /** Speed error gain parameter. */
29      public static final ParameterTypeDouble KV =
30              new ParameterTypeDouble("kv", "Speed error gain", 0.4, NumericConstraint.POSITIVE);
31  
32      /**
33       * Constructor using default sensors with no delay.
34       * @param delayedActuation DelayedActuation; delayed actuation
35       */
36      public LinearAcc(final DelayedActuation delayedActuation)
37      {
38          super(delayedActuation);
39      }
40  
41      /** {@inheritDoc} */
42      @Override
43      public Acceleration getFollowingAcceleration(final LaneBasedGtu gtu,
44              final PerceptionCollectable<HeadwayGtu, LaneBasedGtu> leaders, final Parameters settings) throws ParameterException
45      {
46          HeadwayGtu leader = leaders.first();
47          double es =
48                  leader.getDistance().si - gtu.getSpeed().si * settings.getParameter(TDACC).si - settings.getParameter(X0).si;
49          double ev = leader.getSpeed().si - gtu.getSpeed().si;
50          return Acceleration.instantiateSI(settings.getParameter(KS) * es + settings.getParameter(KV) * ev);
51      }
52  
53  }