Class AbstractPerception<G extends GTU>

  • Type Parameters:
    G - GTU type
    All Implemented Interfaces:
    java.io.Serializable, Perception<G>

    public abstract class AbstractPerception<G extends GTU>
    extends java.lang.Object
    implements Perception<G>

    Copyright (c) 2013-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
    BSD-style license. See OpenTrafficSim License.

    Version:
    $Revision$, $LastChangedDate$, by $Author$, initial version Jul 29, 2016
    Author:
    Alexander Verbraeck, Peter Knoppers, Wouter Schakel
    See Also:
    Serialized Form
    • Constructor Detail

      • AbstractPerception

        public AbstractPerception​(G gtu)
        Construct perception.
        Parameters:
        gtu - G; GTU
    • Method Detail

      • getGtu

        public G getGtu()
        Return the GTU of this perception.
        Specified by:
        getGtu in interface Perception<G extends GTU>
        Returns:
        GTU of this perception
      • addPerceptionCategory

        public final <T extends PerceptionCategory<?,​?>> void addPerceptionCategory​(T perceptionCategory)
        Adds given perception category to the perception.
        Specified by:
        addPerceptionCategory in interface Perception<G extends GTU>
        Type Parameters:
        T - perception category type
        Parameters:
        perceptionCategory - T; perception category
      • contains

        public final <T extends PerceptionCategory<?,​?>> boolean contains​(java.lang.Class<T> category)
        Returns whether the given perception category is present.
        Specified by:
        contains in interface Perception<G extends GTU>
        Type Parameters:
        T - perception category
        Parameters:
        category - Class<T>; perception category class
        Returns:
        whether the given perception category is present
      • getPerceptionCategoryOrNull

        public final <T extends PerceptionCategory<?,​?>> T getPerceptionCategoryOrNull​(java.lang.Class<T> category)
        Returns the given perception category, or null if not present.
        Specified by:
        getPerceptionCategoryOrNull in interface Perception<G extends GTU>
        Type Parameters:
        T - perception category
        Parameters:
        category - Class<T>; perception category class
        Returns:
        given perception category
      • removePerceptionCategory

        public final void removePerceptionCategory​(PerceptionCategory<?,​?> perceptionCategory)
        Remove give perception category.
        Specified by:
        removePerceptionCategory in interface Perception<G extends GTU>
        Parameters:
        perceptionCategory - PerceptionCategory<?,?>; perception category to remove
      • perceive

        public void perceive()
                      throws GTUException,
                             NetworkException,
                             ParameterException
        Invoked by the GTU prior to determining the operational plan. If the implementation works in-sync with the tactical planner, this method is used to update perceived information. It is however possible for the implementation to ignore this and have fully autonomous perception.
        Specified by:
        perceive in interface Perception<G extends GTU>
        Throws:
        GTUException - when GTU has not been properly initialized.
        NetworkException - in case of inconsistencies in the network during perception calculations.
        ParameterException - in case of a parameter error.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object