Class UpstreamNeighborsIterable

    • Constructor Detail

      • UpstreamNeighborsIterable

        public UpstreamNeighborsIterable​(LaneBasedGTU perceivingGtu,
                                         LaneRecord<?> root,
                                         Length initialPosition,
                                         Length maxDistance,
                                         RelativePosition relativePosition,
                                         HeadwayGtuType headwayGtuType,
                                         RelativeLane lane)
        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)
    • 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 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 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 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,
                                   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