java.lang.Object
org.opentrafficsim.road.gtu.perception.structure.LaneStructure

public class LaneStructure extends Object
The lane structure provides a way to see the world for a lane based model.

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

Author:
Wouter Schakel
  • Constructor Details

    • LaneStructure

      public LaneStructure(LaneBasedGtu gtu, org.djunits.value.vdouble.scalar.Length upstream, org.djunits.value.vdouble.scalar.Length downstream)
      Constructor.
      Parameters:
      gtu - the GTU.
      upstream - guaranteed distance within which objects are found upstream of the GTU, or upstream of downstream merge.
      downstream - guaranteed distance within which objects are found downstream of the GTU.
  • Method Details

    • getDownstreamObjects

      public <T extends LaneBasedObject> Iterable<NavigatingIterable.Entry<T>> getDownstreamObjects(RelativeLane relativeLane, Class<T> clazz, RelativePosition.Type position, boolean onRoute)
      Returns an iterator over objects perceived on a relative lane, ordered close to far. This can be objects on different roads, e.g. from the main line on the right-most lane, the right-hand relative lane can give objects upstream of two on-ramps that are very close by, or even the shoulder. Objects that are partially downstream are also included.

      This method does not support finding objects that start at upstream lanes, but who's length reach the GTU.

      Type Parameters:
      T - type of LaneBasedObject.
      Parameters:
      relativeLane - lane.
      clazz - class of lane-based object type.
      position - relative position relative to which objects are found and distances are given.
      onRoute - whether the objects have to be on-route.
      Returns:
      iterator over objects.
    • getUpstreamObjects

      public <T extends LaneBasedObject> Iterable<NavigatingIterable.Entry<T>> getUpstreamObjects(RelativeLane relativeLane, Class<T> clazz, RelativePosition.Type position)
      Returns an iterator over objects perceived on a relative lane, ordered close to far. This can be objects on different roads, e.g. from the main line on the right-most lane, the right-hand relative lane can give objects upstream of two on-ramps that are very close by, or even the shoulder. Objects that are partially upstream are also included.
      Type Parameters:
      T - type of LaneBasedObject.
      Parameters:
      relativeLane - lane.
      clazz - class of lane-based object type.
      position - relative position relative to which objects are found and distances are given.
      Returns:
      iterator over objects.
    • getDownstreamGtus

      public Iterable<NavigatingIterable.Entry<LaneBasedGtu>> getDownstreamGtus(RelativeLane relativeLane, RelativePosition.Type egoPosition, RelativePosition.Type otherPosition, RelativePosition.Type egoDistancePosition, RelativePosition.Type otherDistancePosition)
      Returns an iterator over GTUs perceived on a relative lane, ordered close to far. This can be GTUs on different roads, e.g. from the main line on the right-most lane, the right-hand relative lane can give objects upstream of two on-ramps that are very close by, or even the shoulder. When from a lane on the route, a downstream lane is not on the route, GTUs on the downstream lane are not included. A split conflict should deal with possible GTUs there.
      Parameters:
      relativeLane - lane.
      egoPosition - position of ego GTU relative to which objects are found.
      otherPosition - position of other GTU that must be downstream of egoPosition.
      egoDistancePosition - position of ego GTU from which the distance is determined.
      otherDistancePosition - position of other GTU to which the distance is determined.
      Returns:
      iterator over GTUs.
    • getUpstreamGtus

      public Iterable<NavigatingIterable.Entry<LaneBasedGtu>> getUpstreamGtus(RelativeLane relativeLane, RelativePosition.Type egoPosition, RelativePosition.Type otherPosition, RelativePosition.Type egoDistancePosition, RelativePosition.Type otherDistancePosition)
      Returns an iterator over GTUs perceived on a relative lane, ordered close to far. This can be GTUs on different roads, e.g. from the main line on the right-most lane, the right-hand relative lane can give objects upstream of two on-ramps that are very close by, or even the shoulder.
      Parameters:
      relativeLane - lane.
      egoPosition - position of ego GTU relative to which objects are found.
      otherPosition - position of other GTU that must be upstream of egoPosition.
      egoDistancePosition - position of ego GTU from which the distance is determined.
      otherDistancePosition - position of other GTU to which the distance is determined.
      Returns:
      iterator over GTUs.
    • getFirstDownstreamGtus

      public Iterable<NavigatingIterable.Entry<LaneBasedGtu>> getFirstDownstreamGtus(RelativeLane relativeLane, RelativePosition.Type egoPosition, RelativePosition.Type otherPosition, RelativePosition.Type egoDistancePosition, RelativePosition.Type otherDistancePosition)
      Returns an iterator over GTUs perceived on a relative lane, ordered close to far. This can be GTUs on different roads, e.g. from the main line on the right-most lane, the right-hand relative lane can give objects upstream of two on-ramps that are very close by, or even the shoulder. This function differs from getDownstreamGtus() in that it will halt further searching on on branch it finds a GTU on.
      Parameters:
      relativeLane - lane.
      egoPosition - position of ego GTU relative to which objects are found.
      otherPosition - position of other GTU that must be downstream of egoPosition.
      egoDistancePosition - position of ego GTU from which the distance is determined.
      otherDistancePosition - position of other GTU to which the distance is determined.
      Returns:
      iterator over GTUs.
    • getFirstUpstreamGtus

      public Iterable<NavigatingIterable.Entry<LaneBasedGtu>> getFirstUpstreamGtus(RelativeLane relativeLane, RelativePosition.Type egoPosition, RelativePosition.Type otherPosition, RelativePosition.Type egoDistancePosition, RelativePosition.Type otherDistancePosition)
      Returns an iterator over GTUs perceived on a relative lane, ordered close to far. This can be GTUs on different roads, e.g. from the main line on the right-most lane, the right-hand relative lane can give objects upstream of two on-ramps that are very close by, or even the shoulder. This function differs from getDownstreamGtus() in that it will halt further searching on on branch it finds a GTU on.
      Parameters:
      relativeLane - lane.
      egoPosition - position of ego GTU relative to which objects are found.
      otherPosition - position of other GTU that must be upstream of egoPosition.
      egoDistancePosition - position of ego GTU from which the distance is determined.
      otherDistancePosition - position of other GTU to which the distance is determined.
      Returns:
      iterator over GTUs.
    • getRootCrossSection

      public SortedSet<RelativeLane> getRootCrossSection()
      Returns all the lanes that are in the root cross-section, i.e. to our direct left and right.
      Returns:
      set of lanes in the root cross-section.
    • exists

      public boolean exists(RelativeLane lane)
      Returns whether the lane exists within the structure.
      Parameters:
      lane - lane.
      Returns:
      whether the lane exists within the structure.
    • getRootRecord

      public LaneRecord getRootRecord(RelativeLane lane)
      Returns the root record on the given lane.
      Parameters:
      lane - lane.
      Returns:
      root record on the lane.
    • getCrossSectionRecords

      public Set<LaneRecord> getCrossSectionRecords(RelativeLane lane)
      Returns the set of records in the cross-section on the given lane.
      Parameters:
      lane - lane.
      Returns:
      set of records in the cross-section on the given lane.