Class RollingLaneStructure
- All Implemented Interfaces:
Serializable
,Remote
,EventListener
,org.djutils.event.EventListener
,LaneStructure
(---- a ----)(---- b ----)(---- c ----)(---- d ----)(---- e ----)(---- f ----)(---- g ----) __________ __________ / _________ 1 / _________ 2 / / / / __________/ / _______________________/ / 1 ____________ ____________ /_ _ _ _ _ _/____________ /_ _ _ _ _ _ _ _ _ _ _ _ / 0 |_ _X_ _ _ _ |_ _ _ _ _ _ |_ _ _ _ _ _ |_ _ _ _ _ _ |_ _ _ _ _ _ |_ _ _ _ _ _ \____________ -1 |____________|_ _ _ _ _ _ |____________|____________| __________|____________|____________| 3 -2 / __________/ \ \ ________/ / \ \___________ 5 _________/ \____________ 4When the GTU is looking ahead, it needs to know that when it continues to destination 3, it needs to shift one lane to the right at some point, but not two lanes to the right in link b, and not later than at the end of link f. When it needs to go to destination 1, it needs to shift to the left in link c. When it has to go to destination 2, it has to shift to the left, but not earlier than at link e. At node [de], it is possible to leave the rightmost lane of link e, and go to destination 4. The rightmost lane just splits into two lanes at the end of link d, and the GTU can either continue driving to destination 3, turn right to destination 4. This means that the right lane of link d has two successor lanes.
In the data structures, lanes are numbered laterally. Suppose that the lane where vehicle X resides would be number 0. Consistent with "left is positive" for angles, the lane right of X would have number -1, and entry 5 would have number -2.
In the data structure, this can be indicated as follows (N = next, P = previous, L = left, R = right, D = lane drop, . = continued but not in this structure). The merge lane in b is considered "off limits" for the GTUs on the "main" lane -1; the "main" lane 0 is considered off limits from the exit lanes on c, e, and f. Still, we need to maintain pointers to these lanes, as we are interested in the GTUs potentially driving next to us, feeding into our lane, etc.
1 0 -1 -2 ROOT _____|_____ ___________ ___________ |_-_|_._|_R_|----|_L_|_._|_-_| |_-_|_._|_-_| a | | | _____V_____ _____V_____ _____V_____ |_-_|_N_|_R_|----|_L_|_N_|_R_|<---|_L_|_D_|_-_| b | | ___________ _____V_____ _____V_____ |_-_|_N_|_R_|<---|_L_|_N_|_R_|----|_L_|_N_|_-_| c | | | _____V_____ _____V_____ _____V_____ |_-_|_._|_-_| |_-_|_N_|_R_|----|_L_|_NN|_-_| d | ||_______________ ___________ _____V_____ _____V_____ _____V_____ |_-_|_N_|_R_|<---|_L_|_N_|_R_|----|_L_|_N_|_-_| |_-_|_N_|_-_| e | | | | _____V_____ _____V_____ _____V_____ _____V_____ |_-_|_N_|_R_|<---|_L_|_D_|_R_|----|_L_|_N_|_-_| |_-_|_._|_-_| f | | _____V_____ _____V_____ |_-_|_._|_-_| |_-_|_._|_-_| g
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
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclass
AnimationAccess provides access to a number of private fields in the structure, which should only be used read-only!
Copyright (c) 2003-2024 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands.Nested classes/interfaces inherited from interface org.opentrafficsim.road.gtu.lane.perception.LaneStructure
LaneStructure.Entry<T extends LaneBasedObject>
-
Field Summary
FieldsModifier and TypeFieldDescriptionthe animation access. -
Constructor Summary
ConstructorsConstructorDescriptionRollingLaneStructure
(org.djunits.value.vdouble.scalar.Length lookAhead, org.djunits.value.vdouble.scalar.Length down, org.djunits.value.vdouble.scalar.Length up, org.djunits.value.vdouble.scalar.Length downSplit, org.djunits.value.vdouble.scalar.Length upMerge, LaneBasedGtu gtu) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionfinal <T extends LaneBasedObject>
Map<RelativeLane,SortedSet<LaneStructure.Entry<T>>> getDownstreamObjects
(Class<T> clazz, LaneBasedGtu gtu, RelativePosition.Type pos) Retrieve objects of a specific type.final <T extends LaneBasedObject>
SortedSet<LaneStructure.Entry<T>>getDownstreamObjects
(RelativeLane lane, Class<T> clazz, LaneBasedGtu gtu, RelativePosition.Type pos) Retrieve objects on a lane of a specific type.final <T extends LaneBasedObject>
Map<RelativeLane,SortedSet<LaneStructure.Entry<T>>> getDownstreamObjectsOnRoute
(Class<T> clazz, LaneBasedGtu gtu, RelativePosition.Type pos, Route route) Retrieve objects of a specific type.final <T extends LaneBasedObject>
SortedSet<LaneStructure.Entry<T>>getDownstreamObjectsOnRoute
(RelativeLane lane, Class<T> clazz, LaneBasedGtu gtu, RelativePosition.Type pos, Route route) Retrieve objects on a lane of a specific type.final SortedSet<RelativeLane>
Returns the extended cross-section, which includes all lanes for which a first record is present.getFirstRecord
(RelativeLane lane) Returns the first record on the given lane.final LaneStructureRecord
Returns the root record.final LaneStructureRecord
getRootRecord
(org.djunits.value.vdouble.scalar.Time time) final <T extends LaneBasedObject>
SortedSet<LaneStructure.Entry<T>>getUpstreamObjects
(RelativeLane lane, Class<T> clazz, LaneBasedGtu gtu, RelativePosition.Type pos) Retrieve objects on a lane of a specific type.void
notify
(org.djutils.event.Event event) static String
print
(RollingLaneStructure ls, LaneBasedGtu gtu) Print the lane structure as a number of lines in a String.final String
toString()
final void
update
(LanePosition pos, Route route, GtuType gtuType) Updates the underlying structure shifting the root position to the input.
-
Field Details
-
animationAccess
the animation access.
-
-
Constructor Details
-
RollingLaneStructure
public RollingLaneStructure(org.djunits.value.vdouble.scalar.Length lookAhead, org.djunits.value.vdouble.scalar.Length down, org.djunits.value.vdouble.scalar.Length up, org.djunits.value.vdouble.scalar.Length downSplit, org.djunits.value.vdouble.scalar.Length upMerge, LaneBasedGtu gtu) Constructor.- Parameters:
lookAhead
- Length; distance over which visual objects are includeddown
- Length; downstream distance over which the structure is madeup
- Length; upstream distance over which the structure is made, should include a margin for reaction timedownSplit
- Length; downstream distance at splits (links not on route) included in the structureupMerge
- Length; upstream distance at downstream merges (links not on route) included in the structuregtu
- LaneBasedGtu; GTU
-
-
Method Details
-
update
Updates the underlying structure shifting the root position to the input.- Specified by:
update
in interfaceLaneStructure
- Parameters:
pos
- LanePosition; current position of the GTUroute
- Route; current route of the GTUgtuType
- GtuType; GTU type- Throws:
GtuException
- on a problem while updating the structure
-
getRootRecord
Returns the root record.- Specified by:
getRootRecord
in interfaceLaneStructure
- Returns:
- LaneRecord; root record
-
getRootRecord
- Parameters:
time
- Time; time to obtain the root at- Returns:
- rootRecord
-
getExtendedCrossSection
Returns the extended cross-section, which includes all lanes for which a first record is present.- Specified by:
getExtendedCrossSection
in interfaceLaneStructure
- Returns:
- SortedSet; the cross-section
-
getFirstRecord
Returns the first record on the given lane. This is often a record in the current cross section, but it may be one downstream for a lane that starts further downstream.- Specified by:
getFirstRecord
in interfaceLaneStructure
- Parameters:
lane
- RelativeLane; lane- Returns:
- first record on the given lane, or
null
if no such record
-
getDownstreamObjects
public final <T extends LaneBasedObject> Map<RelativeLane,SortedSet<LaneStructure.Entry<T>>> getDownstreamObjects(Class<T> clazz, LaneBasedGtu gtu, RelativePosition.Type pos) throws GtuException Retrieve objects of a specific type. Returns objects over a maximum length of the look ahead distance downstream from the relative position, or as far as the lane map goes.- Specified by:
getDownstreamObjects
in interfaceLaneStructure
- Type Parameters:
T
- type of objects to find- Parameters:
clazz
- Class<T>; class of objects to findgtu
- LaneBasedGtu; gtupos
- RelativePosition.TYPE; relative position to start search from- Returns:
- Sorted set of objects of requested type per lane
- Throws:
GtuException
- if lane is not in current set
-
getDownstreamObjects
public final <T extends LaneBasedObject> SortedSet<LaneStructure.Entry<T>> getDownstreamObjects(RelativeLane lane, Class<T> clazz, LaneBasedGtu gtu, RelativePosition.Type pos) throws GtuException Retrieve objects on a lane of a specific type. Returns objects over a maximum length of the look ahead distance downstream from the relative position, or as far as the lane map goes.- Specified by:
getDownstreamObjects
in interfaceLaneStructure
- Type Parameters:
T
- type of objects to find- Parameters:
lane
- RelativeLane; laneclazz
- Class<T>; class of objects to findgtu
- LaneBasedGtu; gtupos
- RelativePosition.TYPE; relative position to start search from- Returns:
- Sorted set of objects of requested type
- Throws:
GtuException
- if lane is not in current set
-
getDownstreamObjectsOnRoute
public final <T extends LaneBasedObject> SortedSet<LaneStructure.Entry<T>> getDownstreamObjectsOnRoute(RelativeLane lane, Class<T> clazz, LaneBasedGtu gtu, RelativePosition.Type pos, Route route) throws GtuException Retrieve objects on a lane of a specific type. Returns objects over a maximum length of the look ahead distance downstream from the relative position, or as far as the lane map goes. Objects on links not on the route are ignored.- Specified by:
getDownstreamObjectsOnRoute
in interfaceLaneStructure
- Type Parameters:
T
- type of objects to find- Parameters:
lane
- RelativeLane; laneclazz
- Class<T>; class of objects to findgtu
- LaneBasedGtu; gtupos
- RelativePosition.TYPE; relative position to start search fromroute
- Route; the route- Returns:
- Sorted set of objects of requested type
- Throws:
GtuException
- if lane is not in current set
-
getDownstreamObjectsOnRoute
public final <T extends LaneBasedObject> Map<RelativeLane,SortedSet<LaneStructure.Entry<T>>> getDownstreamObjectsOnRoute(Class<T> clazz, LaneBasedGtu gtu, RelativePosition.Type pos, Route route) throws GtuException Retrieve objects of a specific type. Returns objects over a maximum length of the look ahead distance downstream from the relative position, or as far as the lane map goes. Objects on links not on the route are ignored.- Specified by:
getDownstreamObjectsOnRoute
in interfaceLaneStructure
- Type Parameters:
T
- type of objects to find- Parameters:
clazz
- Class<T>; class of objects to findgtu
- LaneBasedGtu; gtupos
- RelativePosition.TYPE; relative position to start search fromroute
- Route; the route- Returns:
- Sorted set of objects of requested type per lane
- Throws:
GtuException
- if lane is not in current set
-
getUpstreamObjects
public final <T extends LaneBasedObject> SortedSet<LaneStructure.Entry<T>> getUpstreamObjects(RelativeLane lane, Class<T> clazz, LaneBasedGtu gtu, RelativePosition.Type pos) throws GtuException Retrieve objects on a lane of a specific type. Returns upstream objects from the relative position for as far as the lane map goes. Distances to upstream objects are given as positive values.- Specified by:
getUpstreamObjects
in interfaceLaneStructure
- Type Parameters:
T
- type of objects to find- Parameters:
lane
- RelativeLane; laneclazz
- Class<T>; class of objects to findgtu
- LaneBasedGtu; gtupos
- RelativePosition.TYPE; relative position to start search from- Returns:
- Sorted set of objects of requested type
- Throws:
GtuException
- if lane is not in current set
-
print
Print the lane structure as a number of lines in a String.- Parameters:
ls
- RollingLaneStructure; the lane structure to printgtu
- LaneBasedGtu; the GTTU for which the lane structure is printed- Returns:
- a String with information about the RollingLaneStructire
-
toString
-
notify
- Specified by:
notify
in interfaceorg.djutils.event.EventListener
- Throws:
RemoteException
-