Class 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 using boolean 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)
  1. From the same direction (or not a merge): the GTU can be ignored as it is also found on the upstream lane.
  2. 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)
  1. From the same direction: the GTU is considered both through the conflict and as a regular downstream GTU.
  2. From the other direction of a merge: the GTU needs to be considered.

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

Author:
Alexander Verbraeck, Peter Knoppers, Wouter Schakel
  • Constructor Details

    • DownstreamNeighborsIterable

      public DownstreamNeighborsIterable(LaneBasedGtu perceivingGtu, LaneRecordInterface<?> root, org.djunits.value.vdouble.scalar.Length initialPosition, org.djunits.value.vdouble.scalar.Length maxDistance, RelativePosition relativePosition, HeadwayGtuType headwayGtuType, RelativeLane lane, boolean ignoreIfUpstream)
      Constructor.
      Parameters:
      perceivingGtu - LaneBasedGtu; perceiving GTU
      root - LaneRecord<?>; root record
      initialPosition - Length; position on the root record
      maxDistance - Length; maximum distance to search
      relativePosition - RelativePosition; position to which distance are calculated by subclasses
      headwayGtuType - HeadwayGtuType; type of HeadwayGtu to return
      lane - 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 Details

    • getNext

      protected AbstractPerceptionIterable<HeadwayGtu,LaneBasedGtu,Integer>.Entry getNext(LaneRecordInterface<?> record, org.djunits.value.vdouble.scalar.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 be null for the first object(s). For following object(s) it is whatever value is given with the previous output Entry. Hence, this method maintains its own counting system.
      Specified by:
      getNext in class AbstractPerceptionIterable<HeadwayGtu,LaneBasedGtu,Integer>
      Parameters:
      record - LaneRecord<?>; record representing the lane and direction
      position - Length; position to look beyond
      counter - C; counter
      Returns:
      next object(s) on the lane or null if none
      Throws:
      GtuException - on any exception in the process
    • getDistance

      protected org.djunits.value.vdouble.scalar.Length getDistance(LaneBasedGtu object, LaneRecordInterface<?> record, org.djunits.value.vdouble.scalar.Length position)
      Returns the distance to the object. The position fed in to this method is directly taken from an Entry returned by getNext. The two methods need to be consistent with each other.
      Specified by:
      getDistance in class AbstractPerceptionIterable<HeadwayGtu,LaneBasedGtu,Integer>
      Parameters:
      object - U; underlying object
      record - LaneRecord<?>; record representing the lane and direction
      position - Length; position of the object on the lane
      Returns:
      Length; distance to the object
    • perceive

      public HeadwayGtu perceive(LaneBasedGtu perceivingGtu, LaneBasedGtu object, org.djunits.value.vdouble.scalar.Length distance) throws GtuException, org.opentrafficsim.base.parameters.ParameterException
      Returns a perceived version of the underlying object.
      Specified by:
      perceive in class AbstractPerceptionReiterable<HeadwayGtu,LaneBasedGtu>
      Parameters:
      perceivingGtu - LaneBasedGtu; perceiving GTU
      object - U; underlying object
      distance - Length; distance to the object
      Returns:
      H; perceived version of the underlying object
      Throws:
      GtuException - on exception
      org.opentrafficsim.base.parameters.ParameterException - on invalid parameter value or missing parameter