Class AbstractPerception<G extends Gtu>
- java.lang.Object
-
- org.opentrafficsim.core.gtu.perception.AbstractPerception<G>
-
- Type Parameters:
G- GTU type
- All Implemented Interfaces:
Serializable,Perception<G>
public abstract class AbstractPerception<G extends Gtu> extends 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 Summary
Constructors Constructor Description AbstractPerception(G egoGtu)Construct a new AbstractPerception.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends PerceptionCategory<?,?>>
voidaddPerceptionCategory(T perceptionCategory)Adds a perception category to the perception.<T extends PerceptionCategory<?,?>>
booleancontains(Class<T> category)Returns whether the given perception category is present in this Perception.GgetEgoGtu()Return the perceiving GTU.<T extends PerceptionCategory<?,?>>
TgetPerceptionCategory(Class<T> category)Returns the given perception category.<T extends PerceptionCategory<?,?>>
TgetPerceptionCategoryOrNull(Class<T> category)Returns the given perception category, ornullif not present.voidperceive()Invoked by the GTU prior while determining an operational plan.voidremovePerceptionCategory(PerceptionCategory<?,?> perceptionCategory)Remove a perception category.StringtoString()
-
-
-
Constructor Detail
-
AbstractPerception
public AbstractPerception(G egoGtu)
Construct a new AbstractPerception.- Parameters:
egoGtu- G; the perceiving GTU
-
-
Method Detail
-
getEgoGtu
public G getEgoGtu()
Return the perceiving GTU.- Specified by:
getEgoGtuin interfacePerception<G extends Gtu>- Returns:
- G; the GTU of this perception
-
addPerceptionCategory
public final <T extends PerceptionCategory<?,?>> void addPerceptionCategory(T perceptionCategory)
Adds a perception category to the perception.- Specified by:
addPerceptionCategoryin interfacePerception<G extends Gtu>- Type Parameters:
T- perception category type- Parameters:
perceptionCategory- T; perception category to add
-
contains
public final <T extends PerceptionCategory<?,?>> boolean contains(Class<T> category)
Returns whether the given perception category is present in this Perception.- Specified by:
containsin interfacePerception<G extends Gtu>- Type Parameters:
T- perception category- Parameters:
category- Class<T>; perception category class- Returns:
- boolean; true if the given perception category is present; false if the given perception category is not present
-
getPerceptionCategory
public final <T extends PerceptionCategory<?,?>> T getPerceptionCategory(Class<T> category) throws OperationalPlanException
Returns the given perception category.- Specified by:
getPerceptionCategoryin interfacePerception<G extends Gtu>- Type Parameters:
T- perception category- Parameters:
category- Class<T>; perception category class- Returns:
- T; the given perception category
- Throws:
OperationalPlanException- if the perception category is not present
-
getPerceptionCategoryOrNull
public final <T extends PerceptionCategory<?,?>> T getPerceptionCategoryOrNull(Class<T> category)
Returns the given perception category, ornullif not present.- Specified by:
getPerceptionCategoryOrNullin interfacePerception<G extends Gtu>- Type Parameters:
T- perception category- Parameters:
category- Class<T>; perception category class- Returns:
- T; the given perception category
-
removePerceptionCategory
public final void removePerceptionCategory(PerceptionCategory<?,?> perceptionCategory)
Remove a perception category. TODO should this throw an exception if the perception category is not among the current set?- Specified by:
removePerceptionCategoryin interfacePerception<G extends Gtu>- Parameters:
perceptionCategory- PerceptionCategory<?,?>; perception category to remove
-
perceive
public void perceive() throws GtuException, NetworkException, ParameterExceptionInvoked by the GTU prior while determining an 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:
perceivein interfacePerception<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.
-
-