Class NeighborsUtil
- java.lang.Object
-
- org.opentrafficsim.road.gtu.lane.perception.categories.neighbors.NeighborsUtil
-
public final class NeighborsUtil extends Object
Utilities to perceive neighbors.Copyright (c) 2013-2022 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 19 okt. 2018
- Author:
- Alexander Verbraeck, Peter Knoppers, Wouter Schakel
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
NeighborsUtil.DistanceGTU
GTU at a distance, as preliminary info towards perceiving it.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static SortedSet<NeighborsUtil.DistanceGTU>
getFirstDownstreamGTUs(LaneStructureRecord startRecord, RelativePosition egoRelativePosition, RelativePosition egoFrontPosition, RelativePosition.TYPE otherRelativePosition, Time now)
Returns a set of first leaders per branch, relative to given relative position.static SortedSet<NeighborsUtil.DistanceGTU>
getFirstUpstreamGTUs(LaneStructureRecord startRecord, RelativePosition egoRelativePosition, RelativePosition egoRearPosition, RelativePosition.TYPE otherRelativePosition, Time now)
Returns a set of first followers per branch, relative to given relative position.static SortedSet<HeadwayGTU>
perceive(SortedSet<NeighborsUtil.DistanceGTU> base, HeadwayGtuType headwayGtuType, LaneBasedGTU perceivingGtu, boolean downstream)
Translation from a set ofDistanceGTU
's, to a sorted set ofHeadwayGTU
's.
-
-
-
Method Detail
-
getFirstDownstreamGTUs
public static SortedSet<NeighborsUtil.DistanceGTU> getFirstDownstreamGTUs(LaneStructureRecord startRecord, RelativePosition egoRelativePosition, RelativePosition egoFrontPosition, RelativePosition.TYPE otherRelativePosition, Time now) throws GTUException, org.opentrafficsim.base.parameters.ParameterException
Returns a set of first leaders per branch, relative to given relative position. Helper method to find first leaders and GTU's alongside.- Parameters:
startRecord
- LaneStructureRecord; lane structure record to start the search fromegoRelativePosition
- RelativePosition; position of GTU to start search fromegoFrontPosition
- RelativePosition; front position of GTU to determine headwayotherRelativePosition
- RelativePosition.TYPE; position of other GTU that has to be downstreamnow
- Time; current time- Returns:
- set of first leaders per branch
- Throws:
GTUException
- if the GTU was not initializedorg.opentrafficsim.base.parameters.ParameterException
- if a parameter was not present or out of bounds
-
getFirstUpstreamGTUs
public static SortedSet<NeighborsUtil.DistanceGTU> getFirstUpstreamGTUs(LaneStructureRecord startRecord, RelativePosition egoRelativePosition, RelativePosition egoRearPosition, RelativePosition.TYPE otherRelativePosition, Time now) throws GTUException, org.opentrafficsim.base.parameters.ParameterException
Returns a set of first followers per branch, relative to given relative position. Helper method to find first followers and GTU's alongside.- Parameters:
startRecord
- LaneStructureRecord; lane structure record to start the search fromegoRelativePosition
- RelativePosition; position of GTU to start search fromegoRearPosition
- RelativePosition; rear position of GTU to determine headwayotherRelativePosition
- RelativePosition.TYPE; type of position of other GTU that has to be upstreamnow
- Time; current time- Returns:
- set of first followers per branch
- Throws:
GTUException
- if the GTU was not initializedorg.opentrafficsim.base.parameters.ParameterException
- if a parameter was not present or out of bounds
-
perceive
public static SortedSet<HeadwayGTU> perceive(SortedSet<NeighborsUtil.DistanceGTU> base, HeadwayGtuType headwayGtuType, LaneBasedGTU perceivingGtu, boolean downstream)
Translation from a set ofDistanceGTU
's, to a sorted set ofHeadwayGTU
's. This bridges the gap between a raw network search, and the perceived result.- Parameters:
base
- SortedSet<DistanceGTU>; base set of GTU's at distanceheadwayGtuType
- HeadwayGtuType; headway type for perceived GTU'sperceivingGtu
- LaneBasedGTU; perceiving GTUdownstream
- boolean; whether the GTU's are downstream- Returns:
- SortedSet<HeadwayGTU>; set of perceived GTU's
-
-