java.lang.Object
org.opentrafficsim.road.gtu.lane.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-2024 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 - LaneBasedGtu; the GTU.
      upstream - Length; guaranteed distance within which objects are found upstream of the GTU, or upstream of downstream merge.
      downstream - Length; guaranteed distance within which objects are found downstream of the GTU.
  • Method Details

    • getDownstreamObjects

      public <T extends LaneBasedObject> Iterable<LaneStructure.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.
      Type Parameters:
      T - type of LaneBasedObject.
      Parameters:
      relativeLane - RelativeLane; lane.
      clazz - Class<T>; class of lane-based object type.
      position - RelativePosition.Type; position relative to which objects are found and distances are given.
      onRoute - boolean; whether the objects have to be on-route.
      Returns:
      Iterator<Entry<T>>; iterator over objects.
    • getUpstreamObjects

      public <T extends LaneBasedObject> Iterable<LaneStructure.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 - RelativeLane; lane.
      clazz - Class<T>; class of lane-based object type.
      position - RelativePosition.Type; position relative to which objects are found and distances are given.
      Returns:
      Iterator<Entry<T>>; iterator over objects.
    • getDownstreamGtus

      public Iterable<LaneStructure.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.
      Parameters:
      relativeLane - RelativeLane; lane.
      egoPosition - RelativePosition; position of ego GTU relative to which objects are found.
      otherPosition - RelativePosition; position of other GTU that must be downstream of egoPosition.
      egoDistancePosition - RelativePosition; position of ego GTU from which the distance is determined.
      otherDistancePosition - RelativePosition; position of other GTU to which the distance is determined.
      Returns:
      Iterator<Entry<LaneBasedGtu>>; iterator over GTUs.
    • getUpstreamGtus

      public Iterable<LaneStructure.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 - RelativeLane; lane.
      egoPosition - RelativePosition; position of ego GTU relative to which objects are found.
      otherPosition - RelativePosition; position of other GTU that must be upstream of egoPosition.
      egoDistancePosition - RelativePosition; position of ego GTU from which the distance is determined.
      otherDistancePosition - RelativePosition; position of other GTU to which the distance is determined.
      Returns:
      Iterator<Entry<LaneBasedGtu>>; iterator over GTUs.
    • getFirstDownstreamGtus

      public Iterable<LaneStructure.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 - RelativeLane; lane.
      egoPosition - RelativePosition; position of ego GTU relative to which objects are found.
      otherPosition - RelativePosition; position of other GTU that must be downstream of egoPosition.
      egoDistancePosition - RelativePosition; position of ego GTU from which the distance is determined.
      otherDistancePosition - RelativePosition; position of other GTU to which the distance is determined.
      Returns:
      Iterator<Entry<LaneBasedGtu>>; iterator over GTUs.
    • getFirstUpstreamGtus

      public Iterable<LaneStructure.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 - RelativeLane; lane.
      egoPosition - RelativePosition; position of ego GTU relative to which objects are found.
      otherPosition - RelativePosition; position of other GTU that must be upstream of egoPosition.
      egoDistancePosition - RelativePosition; position of ego GTU from which the distance is determined.
      otherDistancePosition - RelativePosition; position of other GTU to which the distance is determined.
      Returns:
      Iterator<Entry<LaneBasedGtu>>; 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:
      SortedSet<RelativeLane>; set of lanes in the root cross-section.
    • exists

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

      public LaneRecord getRootRecord(RelativeLane lane)
      Returns the root record on the given lane.
      Parameters:
      lane - RelativeLane; lane.
      Returns:
      LaneRecord; 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 - RelativeLane; lane.
      Returns:
      Set<LaneRecord>; set of records in the cross-section on the given lane.