Class DirectNeighborsPerception
java.lang.Object
org.opentrafficsim.base.Type<AbstractPerceptionCategory<G,P>>
org.opentrafficsim.core.gtu.perception.AbstractPerceptionCategory<LaneBasedGTU,LanePerception>
org.opentrafficsim.road.gtu.lane.perception.categories.LaneBasedAbstractPerceptionCategory
org.opentrafficsim.road.gtu.lane.perception.categories.neighbors.DirectNeighborsPerception
- All Implemented Interfaces:
Serializable,PerceptionCategory<LaneBasedGTU,LanePerception>,LaneBasedPerceptionCategory,NeighborsPerception
public class DirectNeighborsPerception extends LaneBasedAbstractPerceptionCategory implements NeighborsPerception
Perception of surrounding traffic on the own road, i.e. without crossing traffic.
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 22, 2016
- Author:
- Alexander Verbraeck, Peter Knoppers, Wouter Schakel
- See Also:
- Serialized Form
-
Field Summary
Fields Modifier and Type Field Description protected static ParameterTypeLengthLOOKAHEADLook ahead parameter type.protected static ParameterTypeLengthLOOKBACKLook back parameter type.Fields inherited from class org.opentrafficsim.road.gtu.lane.perception.categories.LaneBasedAbstractPerceptionCategory
MAX_RED_DECELERATION, MAX_YELLOW_DECELERATION -
Constructor Summary
Constructors Constructor Description DirectNeighborsPerception(LanePerception perception, HeadwayGtuType headwayGtuType)DirectNeighborsPerception(LanePerception perception, HeadwayGtuType headwayGtuType, HeadwayGtuType headwayGtuTypeGap) -
Method Summary
Modifier and Type Method Description booleancomputeGtuAlongside(LateralDirectionality lat)Computes whether there is a GTU alongside.SortedSet<HeadwayGTU>getFirstFollowers(LateralDirectionality lat)Set of followers on a lane, which is usually 0 or 1, but possibly more in case of an upstream merge with no intermediate GTU.SortedSet<HeadwayGTU>getFirstLeaders(LateralDirectionality lat)Set of leaders on a lane, which is usually 0 or 1, but possibly more in case of a downstream split with no intermediate GTU.PerceptionCollectable<HeadwayGTU,LaneBasedGTU>getFollowers(RelativeLane lane)Set of followers on a lane, including adjacent GTU's who's FRONT is back of the own vehicle FRONT.PerceptionCollectable<HeadwayGTU,LaneBasedGTU>getLeaders(RelativeLane lane)Set of leaders on a lane, including adjacent GTU's who's FRONT is ahead of the own vehicle FRONT.booleanisGtuAlongside(LateralDirectionality lat)Whether there is a GTU alongside, i.e.StringtoString()voidupdateAll()Methods inherited from class org.opentrafficsim.road.gtu.lane.perception.categories.LaneBasedAbstractPerceptionCategory
computeIfAbsent, computeIfAbsent, computeIfAbsentMethods inherited from class org.opentrafficsim.core.gtu.perception.AbstractPerceptionCategory
getGtu, getObjectOrNull, getPerception, getTimestamp
-
Field Details
-
Constructor Details
-
DirectNeighborsPerception
- Parameters:
perception- LanePerception; perceptionheadwayGtuType- HeadwayGtuType; type of headway gtu to generate
-
DirectNeighborsPerception
public DirectNeighborsPerception(LanePerception perception, HeadwayGtuType headwayGtuType, HeadwayGtuType headwayGtuTypeGap)- Parameters:
perception- LanePerception; perceptionheadwayGtuType- HeadwayGtuType; type of headway gtu to generateheadwayGtuTypeGap- HeadwayGtuType; type of headway gtu to assess gaps
-
-
Method Details
-
updateAll
- Specified by:
updateAllin interfacePerceptionCategory<LaneBasedGTU,LanePerception>- Throws:
GTUExceptionNetworkExceptionParameterException
-
getFirstLeaders
public final SortedSet<HeadwayGTU> getFirstLeaders(LateralDirectionality lat) throws ParameterException, NullPointerException, IllegalArgumentExceptionSet of leaders on a lane, which is usually 0 or 1, but possibly more in case of a downstream split with no intermediate GTU. This is shown below. Suppose A needs to go straight. If A considers a lane change to the left, both GTUs B (who's tail ~ is still on the straight lane) and C need to be considered for whether it's safe to do so. In case of multiple splits close to one another, the returned set may contain even more than 2 leaders. Leaders are sorted by headway value.| | _________/B/_____ _ _?_ _ _~_ _C_ _ _ _A_ _ _ _ _ _ _ _________________Only vehicles who's rear is beyond the own front are considered, no alongside vehicles.
- Specified by:
getFirstLeadersin interfaceNeighborsPerception- Parameters:
lat- LateralDirectionality; LEFT or RIGHT- Returns:
- list of followers on a lane
- Throws:
ParameterException- if parameter is not definedNullPointerException- iflatisnullIllegalArgumentException- iflatisNONE
-
getFirstFollowers
public final SortedSet<HeadwayGTU> getFirstFollowers(LateralDirectionality lat) throws ParameterException, NullPointerException, IllegalArgumentExceptionSet of followers on a lane, which is usually 0 or 1, but possibly more in case of an upstream merge with no intermediate GTU. This is shown below. If A considers a lane change to the left, both GTUs B and C need to be considered for whether it's safe to do so. In case of multiple merges close to one another, the returned set may contain even more than 2 followers. Followers are sorted by tailway value.| | |C| ________\ \______ _ _B_|_ _ _ _ _?_ _ _ _|_ _ _ _ _A_ _____|___________Only vehicles who's front is before the own rear are considered, no alongside vehicles.
- Specified by:
getFirstFollowersin interfaceNeighborsPerception- Parameters:
lat- LateralDirectionality; LEFT or RIGHT- Returns:
- list of followers on a lane
- Throws:
ParameterException- if parameter is not definedNullPointerException- iflatisnullIllegalArgumentException- iflatisNONE
-
isGtuAlongside
public final boolean isGtuAlongside(LateralDirectionality lat) throws ParameterException, NullPointerException, IllegalArgumentExceptionWhether there is a GTU alongside, i.e. with overlap, in an adjacent lane.- Specified by:
isGtuAlongsidein interfaceNeighborsPerception- Parameters:
lat- LateralDirectionality; LEFT or RIGHT- Returns:
- whether there is a GTU alongside, i.e. with overlap, in an adjacent lane
- Throws:
ParameterException- if parameter is not definedNullPointerException- iflatisnullIllegalArgumentException- iflatisNONE
-
computeGtuAlongside
Computes whether there is a GTU alongside.- Parameters:
lat- LateralDirectionality; lateral directionality- Returns:
- boolean; whether there is a GTU alongside
-
getLeaders
Set of leaders on a lane, including adjacent GTU's who's FRONT is ahead of the own vehicle FRONT. Leaders are sorted by headway value.- Specified by:
getLeadersin interfaceNeighborsPerception- Parameters:
lane- RelativeLane; relative lateral lane- Returns:
- set of leaders on a lane, including adjacent GTU's who's FRONT is ahead of the own vehicle FRONT
-
getFollowers
Set of followers on a lane, including adjacent GTU's who's FRONT is back of the own vehicle FRONT. Follower are are sorted by distance.- Specified by:
getFollowersin interfaceNeighborsPerception- Parameters:
lane- RelativeLane; relative lateral lane- Returns:
- set of followers on a lane, including adjacent GTU's who's FRONT is back of the own vehicle FRONT
-
toString
-