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-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
22   * BSD-style license. See <a href="http://opentrafficsim.org/node/13">OpenTrafficSim License</a>.
23   * <p>
24   * @version $Revision$, $LastChangedDate$, by $Author$, initial version 15 feb. 2017 <br>
25   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
26   * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
27   * @author <a href="http://www.transport.citg.tudelft.nl">Wouter Schakel</a>
28   */
29  public class DefaultLMRSPerceptionFactory implements PerceptionFactory
30  {
31  
32      /** {@inheritDoc} */
33      @Override
34      public LanePerception generatePerception(final LaneBasedGTU gtu)
35      {
36          LanePerception perception = new CategoricalLanePerception(gtu);
37          perception.addPerceptionCategory(new DirectEgoPerception(perception));
38          perception.addPerceptionCategory(new DirectInfrastructurePerception(perception));
39          perception.addPerceptionCategory(new DirectNeighborsPerception(perception, HeadwayGtuType.WRAP));
40          perception.addPerceptionCategory(new AnticipationTrafficPerception(perception));
41          perception.addPerceptionCategory(new DirectIntersectionPerception(perception, HeadwayGtuType.WRAP));
42          return perception;
43      }
44  
45      /** {@inheritDoc} */
46      @Override
47      public Parameters getParameters() throws ParameterException
48      {
49          return new ParameterSet().setDefaultParameter(ParameterTypes.LOOKAHEAD).setDefaultParameter(ParameterTypes.LOOKBACKOLD)
50                  .setDefaultParameter(ParameterTypes.PERCEPTION).setDefaultParameter(ParameterTypes.LOOKBACK);
51      }
52  
53  }