Class LaneStructure
java.lang.Object
org.opentrafficsim.road.gtu.lane.perception.structure.LaneStructure
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordContainer for a perceived object with the distance towards it and the distance until the road of the object and the road of the perceiving GTU merge. -
Constructor Summary
ConstructorsConstructorDescriptionLaneStructure(LaneBasedGtu gtu, org.djunits.value.vdouble.scalar.Length upstream, org.djunits.value.vdouble.scalar.Length downstream) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionbooleanexists(RelativeLane lane) Returns whether the lane exists within the structure.Returns the set of records in the cross-section on the given lane.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.<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.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.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.Returns all the lanes that are in the root cross-section, i.e. to our direct left and right.getRootRecord(RelativeLane lane) Returns the root record on the given lane.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.<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.
-
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 ofLaneBasedObject.- 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 ofLaneBasedObject.- 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 fromgetDownstreamGtus()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 fromgetDownstreamGtus()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
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
Returns whether the lane exists within the structure.- Parameters:
lane- RelativeLane; lane.- Returns:
- boolean; whether the lane exists within the structure.
-
getRootRecord
Returns the root record on the given lane.- Parameters:
lane- RelativeLane; lane.- Returns:
- LaneRecord; root record on the lane.
-
getCrossSectionRecords
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.
-