Class DownstreamNeighborsIterable
- java.lang.Object
-
- org.opentrafficsim.road.gtu.lane.perception.AbstractPerceptionReiterable<H,U>
-
- org.opentrafficsim.road.gtu.lane.perception.AbstractPerceptionIterable<HeadwayGTU,LaneBasedGTU,Integer>
-
- org.opentrafficsim.road.gtu.lane.perception.DownstreamNeighborsIterable
-
- All Implemented Interfaces:
Iterable<HeadwayGTU>
,PerceptionCollectable<HeadwayGTU,LaneBasedGTU>
,PerceptionIterable<HeadwayGTU>
public class DownstreamNeighborsIterable extends AbstractPerceptionIterable<HeadwayGTU,LaneBasedGTU,Integer>
Iterable to find downstream GTU's.
The behavior of this search is slightly altered usingboolean ignoreIfUpstream
. This is to deal with the following situations in case a GTU with it's rear upstream of the considered lane is found:
Following downstream GTUs (ignoreIfUpstream = true
)- From the same direction (or not a merge): the GTU can be ignored as it is also found on the upstream lane.
- From the other direction of a merge: the GTU can be ignored as it is followed through considering the merge conflict. Note that we cannot follow the GTU in a regular fashion. If the rear of the GTU is upstream of the conflict, the subject GTU can move up to the conflict without hitting the GTU from the other direction. Considering the GTU through the conflict deals with this, and the GTU can be ignored for regular following of downstream GTUs.
GTUs downstream of a conflict (ignoreIfUpstream = false
)- From the same direction: the GTU is considered both through the conflict and as a regular downstream GTU.
- From the other direction of a merge: the GTU needs to be considered.
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 19 feb. 2018
- Author:
- Alexander Verbraeck, Peter Knoppers, Wouter Schakel
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.opentrafficsim.road.gtu.lane.perception.AbstractPerceptionIterable
AbstractPerceptionIterable.Entry
-
Nested classes/interfaces inherited from class org.opentrafficsim.road.gtu.lane.perception.AbstractPerceptionReiterable
AbstractPerceptionReiterable.PerceptionIterator, AbstractPerceptionReiterable.PrimaryIteratorEntry
-
Nested classes/interfaces inherited from interface org.opentrafficsim.road.gtu.lane.perception.PerceptionCollectable
PerceptionCollectable.Intermediate<I>, PerceptionCollectable.PerceptionAccumulator<U,I>, PerceptionCollectable.PerceptionCollector<C,U,I>, PerceptionCollectable.PerceptionFinalizer<C,I>, PerceptionCollectable.UnderlyingDistance<U>
-
-
Constructor Summary
Constructors Constructor Description DownstreamNeighborsIterable(LaneBasedGTU perceivingGtu, LaneRecord<?> root, Length initialPosition, Length maxDistance, RelativePosition relativePosition, HeadwayGtuType headwayGtuType, RelativeLane lane, boolean ignoreIfUpstream)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Length
getDistance(LaneBasedGTU object, LaneRecord<?> record, Length position)
Returns the distance to the object.protected AbstractPerceptionIterable.Entry
getNext(LaneRecord<?> record, Length position, Integer counter)
Returns the next object(s) on the lane represented by the record.HeadwayGTU
perceive(LaneBasedGTU perceivingGtu, LaneBasedGTU object, Length distance)
Returns a perceived version of the underlying object.-
Methods inherited from class org.opentrafficsim.road.gtu.lane.perception.AbstractPerceptionIterable
getDx, isDownstream, primaryIterator
-
Methods inherited from class org.opentrafficsim.road.gtu.lane.perception.AbstractPerceptionReiterable
collect, first, getGtu, isEmpty, iterator, underlying, underlyingWithDistance
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Methods inherited from interface org.opentrafficsim.road.gtu.lane.perception.PerceptionCollectable
collect
-
-
-
-
Constructor Detail
-
DownstreamNeighborsIterable
public DownstreamNeighborsIterable(LaneBasedGTU perceivingGtu, LaneRecord<?> root, Length initialPosition, Length maxDistance, RelativePosition relativePosition, HeadwayGtuType headwayGtuType, RelativeLane lane, boolean ignoreIfUpstream)
Constructor.- Parameters:
perceivingGtu
- LaneBasedGTU; perceiving GTUroot
- LaneRecord<?>; root recordinitialPosition
- Length; position on the root recordmaxDistance
- Length; maximum distance to searchrelativePosition
- RelativePosition; position to which distance are calculated by subclassesheadwayGtuType
- HeadwayGtuType; type of HeadwayGTU to returnlane
- RelativeLane; relative lane (used for a left/right distinction to prevent dead-locks)ignoreIfUpstream
- boolean; whether to ignore GTU that are partially upstream of a record
-
-
Method Detail
-
getNext
protected AbstractPerceptionIterable.Entry getNext(LaneRecord<?> record, Length position, Integer counter) throws GTUException
Returns the next object(s) on the lane represented by the record. This should only consider objects on the given lane. This method should not check the distance towards objects with the maximum distance. The counter will benull
for the first object(s). For following object(s) it is whatever value is given with the previous outputEntry
. Hence, this method maintains its own counting system.- Specified by:
getNext
in classAbstractPerceptionIterable<HeadwayGTU,LaneBasedGTU,Integer>
- Parameters:
record
- LaneRecord<?>; record representing the lane and directionposition
- Length; position to look beyondcounter
- C; counter- Returns:
- next object(s) on the lane or
null
if none - Throws:
GTUException
- on any exception in the process
-
getDistance
protected Length getDistance(LaneBasedGTU object, LaneRecord<?> record, Length position)
Returns the distance to the object. The position fed in to this method is directly taken from anEntry
returned bygetNext
. The two methods need to be consistent with each other.- Specified by:
getDistance
in classAbstractPerceptionIterable<HeadwayGTU,LaneBasedGTU,Integer>
- Parameters:
object
- U; underlying objectrecord
- LaneRecord<?>; record representing the lane and directionposition
- Length; position of the object on the lane- Returns:
- Length; distance to the object
-
perceive
public HeadwayGTU perceive(LaneBasedGTU perceivingGtu, LaneBasedGTU object, Length distance) throws GTUException, ParameterException
Returns a perceived version of the underlying object.- Specified by:
perceive
in classAbstractPerceptionReiterable<HeadwayGTU,LaneBasedGTU>
- Parameters:
perceivingGtu
- LaneBasedGTU; perceiving GTUobject
- U; underlying objectdistance
- Length; distance to the object- Returns:
- H; perceived version of the underlying object
- Throws:
GTUException
- on exceptionParameterException
- on invalid parameter value or missing parameter
-
-