View Javadoc
1   package org.opentrafficsim.road.gtu.lane.tactical.lmrs;
2   
3   import org.opentrafficsim.base.parameters.ParameterException;
4   import org.opentrafficsim.base.parameters.ParameterSet;
5   import org.opentrafficsim.base.parameters.ParameterTypes;
6   import org.opentrafficsim.base.parameters.Parameters;
7   import org.opentrafficsim.core.gtu.perception.DirectEgoPerception;
8   import org.opentrafficsim.road.gtu.lane.LaneBasedGtu;
9   import org.opentrafficsim.road.gtu.lane.perception.CategoricalLanePerception;
10  import org.opentrafficsim.road.gtu.lane.perception.LanePerception;
11  import org.opentrafficsim.road.gtu.lane.perception.PerceptionFactory;
12  import org.opentrafficsim.road.gtu.lane.perception.categories.AnticipationTrafficPerception;
13  import org.opentrafficsim.road.gtu.lane.perception.categories.DirectInfrastructurePerception;
14  import org.opentrafficsim.road.gtu.lane.perception.categories.DirectIntersectionPerception;
15  import org.opentrafficsim.road.gtu.lane.perception.categories.neighbors.DirectNeighborsPerception;
16  import org.opentrafficsim.road.gtu.lane.perception.categories.neighbors.HeadwayGtuType;
17  
18  /**
19   * Perception factory with EgoPerception, InfrastructurePerception, NeighborsPerception and IntersectionPerception.
20   * <p>
21   * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
22   * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
23   * </p>
24   * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
25   * @author <a href="https://tudelft.nl/staff/p.knoppers-1">Peter Knoppers</a>
26   * @author <a href="https://github.com/wjschakel">Wouter Schakel</a>
27   */
28  public class DefaultLmrsPerceptionFactory implements PerceptionFactory
29  {
30  
31      /** {@inheritDoc} */
32      @Override
33      public LanePerception generatePerception(final LaneBasedGtu gtu)
34      {
35          LanePerception perception = new CategoricalLanePerception(gtu);
36          perception.addPerceptionCategory(new DirectEgoPerception<>(perception));
37          perception.addPerceptionCategory(new DirectInfrastructurePerception(perception));
38          perception.addPerceptionCategory(new DirectNeighborsPerception(perception, HeadwayGtuType.WRAP));
39          perception.addPerceptionCategory(new AnticipationTrafficPerception(perception));
40          perception.addPerceptionCategory(new DirectIntersectionPerception(perception, HeadwayGtuType.WRAP));
41          return perception;
42      }
43  
44      /** {@inheritDoc} */
45      @Override
46      public Parameters getParameters() throws ParameterException
47      {
48          return new ParameterSet().setDefaultParameter(ParameterTypes.LOOKAHEAD).setDefaultParameter(ParameterTypes.LOOKBACKOLD)
49                  .setDefaultParameter(ParameterTypes.PERCEPTION).setDefaultParameter(ParameterTypes.LOOKBACK);
50      }
51  
52  }