Class DirectDefaultSimplePerception
- java.lang.Object
-
- org.opentrafficsim.base.Type<AbstractPerceptionCategory<G,P>>
-
- org.opentrafficsim.core.gtu.perception.AbstractPerceptionCategory<LaneBasedGTU,LanePerception>
-
- org.opentrafficsim.road.gtu.lane.perception.categories.LaneBasedAbstractPerceptionCategory
-
- org.opentrafficsim.road.gtu.lane.perception.categories.DirectDefaultSimplePerception
-
- All Implemented Interfaces:
Serializable
,PerceptionCategory<LaneBasedGTU,LanePerception>
,DefaultSimplePerception
,LaneBasedPerceptionCategory
public class DirectDefaultSimplePerception extends LaneBasedAbstractPerceptionCategory implements DefaultSimplePerception
Copyright (c) 2013-2022 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.- Version:
- $Revision$, $LastChangedDate$, by $Author$, initial version Jul 22, 2016
- Author:
- Alexander Verbraeck, Peter Knoppers, Wouter Schakel
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected static org.opentrafficsim.base.parameters.ParameterTypeLength
LOOKAHEAD
Look ahead parameter type.protected static org.opentrafficsim.base.parameters.ParameterTypeLength
LOOKBACKOLD
Look back parameter type.-
Fields inherited from class org.opentrafficsim.road.gtu.lane.perception.categories.LaneBasedAbstractPerceptionCategory
MAX_RED_DECELERATION, MAX_YELLOW_DECELERATION
-
-
Constructor Summary
Constructors Constructor Description DirectDefaultSimplePerception(LanePerception perception)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Lane
bestAccessibleAdjacentLane(Lane currentLane, LateralDirectionality lateralDirection, Length longitudinalPosition)
Determine whether there is a lane to the left or to the right of this lane, which is accessible from this lane, or null if no lane could be found.Map<Lane,Set<Lane>>
getAccessibleAdjacentLanes(LateralDirectionality lateralDirection)
Map<Lane,Set<Lane>>
getAccessibleAdjacentLanesLeft()
Map<Lane,Set<Lane>>
getAccessibleAdjacentLanesRight()
Headway
getBackwardHeadway()
Headway
getForwardHeadwayGTU()
Headway
getForwardHeadwayObject()
LanePathInfo
getLanePathInfo()
Retrieve the last perceived lane path info.Collection<Headway>
getNeighboringHeadways(LateralDirectionality lateralDirection)
Collection<Headway>
getNeighboringHeadwaysLeft()
Collection<Headway>
getNeighboringHeadwaysRight()
Collection<Headway>
getParallelHeadways(LateralDirectionality lateralDirection)
Collection<Headway>
getParallelHeadwaysLeft()
Collection<Headway>
getParallelHeadwaysRight()
Speed
getSpeedLimit()
org.opentrafficsim.base.TimeStampedObject<Map<Lane,Set<Lane>>>
getTimeStampedAccessibleAdjacentLanes(LateralDirectionality lateralDirection)
org.opentrafficsim.base.TimeStampedObject<Map<Lane,Set<Lane>>>
getTimeStampedAccessibleAdjacentLanesLeft()
org.opentrafficsim.base.TimeStampedObject<Map<Lane,Set<Lane>>>
getTimeStampedAccessibleAdjacentLanesRight()
org.opentrafficsim.base.TimeStampedObject<Headway>
getTimeStampedBackwardHeadway()
org.opentrafficsim.base.TimeStampedObject<Headway>
getTimeStampedForwardHeadwayGTU()
org.opentrafficsim.base.TimeStampedObject<Headway>
getTimeStampedForwardHeadwayObject()
org.opentrafficsim.base.TimeStampedObject<LanePathInfo>
getTimeStampedLanePathInfo()
Retrieve the time stamped last perceived lane path info.org.opentrafficsim.base.TimeStampedObject<Collection<Headway>>
getTimeStampedNeighboringHeadways(LateralDirectionality lateralDirection)
org.opentrafficsim.base.TimeStampedObject<Collection<Headway>>
getTimeStampedNeighboringHeadwaysLeft()
org.opentrafficsim.base.TimeStampedObject<Collection<Headway>>
getTimeStampedNeighboringHeadwaysRight()
org.opentrafficsim.base.TimeStampedObject<Collection<Headway>>
getTimeStampedParallelHeadways(LateralDirectionality lateralDirection)
org.opentrafficsim.base.TimeStampedObject<Collection<Headway>>
getTimeStampedParallelHeadwaysLeft()
org.opentrafficsim.base.TimeStampedObject<Collection<Headway>>
getTimeStampedParallelHeadwaysRight()
org.opentrafficsim.base.TimeStampedObject<Speed>
getTimeStampedSpeedLimit()
String
toString()
void
updateAccessibleAdjacentLanesLeft()
Update the accessible adjacent lanes on the left.void
updateAccessibleAdjacentLanesRight()
Update the accessible adjacent lanes on the right.void
updateBackwardHeadway()
Update the backward headway and first object (e.g., a GTU) behind.void
updateForwardHeadwayGTU()
Update the forward headway and first object (a GTU) in front.void
updateForwardHeadwayObject()
Update the forward headway and first object (but not a GTU) in front.void
updateLanePathInfo()
void
updateNeighboringHeadways(LateralDirectionality lateralDirection)
Update the objects (e.g., GTUs) in parallel, in front and behind for the lane in the given direction, with their headway relative to our GTU, and information about the status of the adjacent objects.void
updateNeighboringHeadwaysLeft()
Update the objects (e.g., GTUs) in parallel, in front and behind on the left neighboring lane, with their headway relative to our GTU, and information about the status of the adjacent objects.void
updateNeighboringHeadwaysRight()
Update the objects (e.g., GTUs) in parallel, in front and behind on the right neighboring lane, with their headway relative to our GTU, and information about the status of the adjacent objects.void
updateParallelHeadways(LateralDirectionality lateralDirection)
Update the parallel objects (e.g., GTUs) for the given direction, with information about their status and parallel overlap with our GTU.void
updateParallelHeadwaysLeft()
Update the parallel objects (e.g., GTUs) on the left, with information about their status and parallel overlap with our GTU.void
updateParallelHeadwaysRight()
Update the parallel objects (e.g., GTUs) on the right, with information about their status and parallel overlap with our GTU.void
updateSpeedLimit()
Update speedLimit.-
Methods inherited from class org.opentrafficsim.road.gtu.lane.perception.categories.LaneBasedAbstractPerceptionCategory
computeIfAbsent, computeIfAbsent, computeIfAbsent
-
Methods inherited from class org.opentrafficsim.core.gtu.perception.AbstractPerceptionCategory
getGtu, getObjectOrNull, getPerception, getTimestamp
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.opentrafficsim.road.gtu.lane.perception.categories.DefaultSimplePerception
updateAccessibleAdjacentLanes, updateAll
-
-
-
-
Constructor Detail
-
DirectDefaultSimplePerception
public DirectDefaultSimplePerception(LanePerception perception)
- Parameters:
perception
- LanePerception; perception
-
-
Method Detail
-
updateLanePathInfo
public final void updateLanePathInfo() throws GTUException, NetworkException, org.opentrafficsim.base.parameters.ParameterException
- Specified by:
updateLanePathInfo
in interfaceDefaultSimplePerception
- Throws:
GTUException
- when the GTU was not initialized yet.NetworkException
- when the speed limit for a GTU type cannot be retrieved from the network.org.opentrafficsim.base.parameters.ParameterException
- in case of not being able to retrieve parameter ParameterTypes.LOOKAHEAD
-
updateForwardHeadwayGTU
public final void updateForwardHeadwayGTU() throws GTUException, NetworkException, org.opentrafficsim.base.parameters.ParameterException
Update the forward headway and first object (a GTU) in front.- Specified by:
updateForwardHeadwayGTU
in interfaceDefaultSimplePerception
- Throws:
GTUException
- when the GTU was not yet initializedNetworkException
- in case of network exceptionorg.opentrafficsim.base.parameters.ParameterException
- if parameter is not defined or out of bounds
-
updateForwardHeadwayObject
public final void updateForwardHeadwayObject() throws GTUException, NetworkException, org.opentrafficsim.base.parameters.ParameterException
Update the forward headway and first object (but not a GTU) in front.- Specified by:
updateForwardHeadwayObject
in interfaceDefaultSimplePerception
- Throws:
GTUException
- when the GTU was not yet initializedNetworkException
- in case of network exceptionorg.opentrafficsim.base.parameters.ParameterException
- if parameter is not defined or out of bounds
-
updateBackwardHeadway
public final void updateBackwardHeadway() throws GTUException, org.opentrafficsim.base.parameters.ParameterException, NetworkException
Update the backward headway and first object (e.g., a GTU) behind.- Specified by:
updateBackwardHeadway
in interfaceDefaultSimplePerception
- Throws:
GTUException
- when the GTU was not yet initializedorg.opentrafficsim.base.parameters.ParameterException
- if parameter is not defined or out of boundsNetworkException
- in case of network exception
-
updateAccessibleAdjacentLanesLeft
public final void updateAccessibleAdjacentLanesLeft() throws GTUException
Update the accessible adjacent lanes on the left.- Specified by:
updateAccessibleAdjacentLanesLeft
in interfaceDefaultSimplePerception
- Throws:
GTUException
- when the GTU was not yet initialized
-
updateAccessibleAdjacentLanesRight
public final void updateAccessibleAdjacentLanesRight() throws GTUException
Update the accessible adjacent lanes on the right.- Specified by:
updateAccessibleAdjacentLanesRight
in interfaceDefaultSimplePerception
- Throws:
GTUException
- when the GTU was not yet initialized
-
updateNeighboringHeadwaysLeft
public final void updateNeighboringHeadwaysLeft() throws GTUException, org.opentrafficsim.base.parameters.ParameterException, NetworkException
Update the objects (e.g., GTUs) in parallel, in front and behind on the left neighboring lane, with their headway relative to our GTU, and information about the status of the adjacent objects.- Specified by:
updateNeighboringHeadwaysLeft
in interfaceDefaultSimplePerception
- Throws:
GTUException
- when the GTU was not yet initializedorg.opentrafficsim.base.parameters.ParameterException
- if parameter is not defined or out of boundsNetworkException
- in case of network exception
-
updateNeighboringHeadwaysRight
public final void updateNeighboringHeadwaysRight() throws GTUException, org.opentrafficsim.base.parameters.ParameterException, NetworkException
Update the objects (e.g., GTUs) in parallel, in front and behind on the right neighboring lane, with their headway relative to our GTU, and information about the status of the adjacent objects.- Specified by:
updateNeighboringHeadwaysRight
in interfaceDefaultSimplePerception
- Throws:
GTUException
- when the GTU was not yet initializedorg.opentrafficsim.base.parameters.ParameterException
- if parameter is not defined or out of boundsNetworkException
- in case of network exception
-
updateNeighboringHeadways
public final void updateNeighboringHeadways(LateralDirectionality lateralDirection) throws GTUException, org.opentrafficsim.base.parameters.ParameterException, NetworkException
Update the objects (e.g., GTUs) in parallel, in front and behind for the lane in the given direction, with their headway relative to our GTU, and information about the status of the adjacent objects.- Specified by:
updateNeighboringHeadways
in interfaceDefaultSimplePerception
- Parameters:
lateralDirection
- LateralDirectionality; the direction to update the parallel headway collection for- Throws:
GTUException
- when the GTU was not yet initializedorg.opentrafficsim.base.parameters.ParameterException
- if parameter is not defined or out of boundsNetworkException
- in case of network exception
-
updateParallelHeadwaysLeft
public final void updateParallelHeadwaysLeft() throws GTUException
Update the parallel objects (e.g., GTUs) on the left, with information about their status and parallel overlap with our GTU.- Specified by:
updateParallelHeadwaysLeft
in interfaceDefaultSimplePerception
- Throws:
GTUException
- when the GTU was not yet initialized
-
updateParallelHeadwaysRight
public final void updateParallelHeadwaysRight() throws GTUException
Update the parallel objects (e.g., GTUs) on the right, with information about their status and parallel overlap with our GTU.- Specified by:
updateParallelHeadwaysRight
in interfaceDefaultSimplePerception
- Throws:
GTUException
- when the GTU was not yet initialized
-
updateParallelHeadways
public final void updateParallelHeadways(LateralDirectionality lateralDirection) throws GTUException
Update the parallel objects (e.g., GTUs) for the given direction, with information about their status and parallel overlap with our GTU.- Specified by:
updateParallelHeadways
in interfaceDefaultSimplePerception
- Parameters:
lateralDirection
- LateralDirectionality; the direction to return the neighboring headway collection for- Throws:
GTUException
- when the GTU was not yet initialized
-
updateSpeedLimit
public final void updateSpeedLimit() throws GTUException, NetworkException
Update speedLimit.- Specified by:
updateSpeedLimit
in interfaceDefaultSimplePerception
- Throws:
GTUException
- when the GTU was not yet initializedNetworkException
- in case of network exception
-
getLanePathInfo
public final LanePathInfo getLanePathInfo()
Retrieve the last perceived lane path info.- Specified by:
getLanePathInfo
in interfaceDefaultSimplePerception
- Returns:
- LanePathInfo
-
getForwardHeadwayGTU
public final Headway getForwardHeadwayGTU()
- Specified by:
getForwardHeadwayGTU
in interfaceDefaultSimplePerception
- Returns:
- forwardHeadway, the forward headway and first object (GTU) in front
-
getForwardHeadwayObject
public final Headway getForwardHeadwayObject()
- Specified by:
getForwardHeadwayObject
in interfaceDefaultSimplePerception
- Returns:
- forwardHeadway, the forward headway and first object (not a GTU) in front
-
getBackwardHeadway
public final Headway getBackwardHeadway()
- Specified by:
getBackwardHeadway
in interfaceDefaultSimplePerception
- Returns:
- backwardHeadwayGTU, the backward headway and first object (e.g., a GTU) behind
-
getAccessibleAdjacentLanesLeft
public final Map<Lane,Set<Lane>> getAccessibleAdjacentLanesLeft()
- Specified by:
getAccessibleAdjacentLanesLeft
in interfaceDefaultSimplePerception
- Returns:
- accessibleAdjacentLanesLeft, the accessible adjacent lanes on the left
-
getAccessibleAdjacentLanesRight
public final Map<Lane,Set<Lane>> getAccessibleAdjacentLanesRight()
- Specified by:
getAccessibleAdjacentLanesRight
in interfaceDefaultSimplePerception
- Returns:
- accessibleAdjacentLanesRight, the accessible adjacent lanes on the right
-
getAccessibleAdjacentLanes
public final Map<Lane,Set<Lane>> getAccessibleAdjacentLanes(LateralDirectionality lateralDirection)
- Specified by:
getAccessibleAdjacentLanes
in interfaceDefaultSimplePerception
- Parameters:
lateralDirection
- LateralDirectionality; the direction to return the accessible adjacent lane map for- Returns:
- the accessible adjacent lane map for the given direction
-
getNeighboringHeadwaysLeft
public final Collection<Headway> getNeighboringHeadwaysLeft()
- Specified by:
getNeighboringHeadwaysLeft
in interfaceDefaultSimplePerception
- Returns:
- neighboringHeadwaysLeft, the objects (e.g., GTUs) in parallel, in front and behind on the left neighboring lane, with their headway relative to our GTU, and information about the status of the adjacent objects
-
getNeighboringHeadwaysRight
public final Collection<Headway> getNeighboringHeadwaysRight()
- Specified by:
getNeighboringHeadwaysRight
in interfaceDefaultSimplePerception
- Returns:
- neighboringHeadwaysRight, the objects (e.g., GTUs) in parallel, in front and behind on the right neighboring lane, with their headway relative to our GTU, and information about the status of the adjacent objects
-
getNeighboringHeadways
public final Collection<Headway> getNeighboringHeadways(LateralDirectionality lateralDirection)
- Specified by:
getNeighboringHeadways
in interfaceDefaultSimplePerception
- Parameters:
lateralDirection
- LateralDirectionality; the direction to return the parallel headway collection for- Returns:
- the the objects (e.g., GTUs) in parallel, in front and behind for the lane in the given direction, with their headway relative to our GTU, and information about the status of the adjacent objects
-
getParallelHeadwaysLeft
public final Collection<Headway> getParallelHeadwaysLeft()
- Specified by:
getParallelHeadwaysLeft
in interfaceDefaultSimplePerception
- Returns:
- parallelHeadwaysLeft, the parallel objects (e.g., GTUs) on the left, with information about their status and parallel overlap with our GTU.
-
getParallelHeadwaysRight
public final Collection<Headway> getParallelHeadwaysRight()
- Specified by:
getParallelHeadwaysRight
in interfaceDefaultSimplePerception
- Returns:
- parallelHeadwaysRight, the parallel objects (e.g., GTUs) on the right, with information about their status and parallel overlap with our GTU.
-
getParallelHeadways
public final Collection<Headway> getParallelHeadways(LateralDirectionality lateralDirection)
- Specified by:
getParallelHeadways
in interfaceDefaultSimplePerception
- Parameters:
lateralDirection
- LateralDirectionality; the direction to return the neighboring headway collection for- Returns:
- the the parallel objects (e.g., GTUs) for the given direction, with information about their status and parallel overlap with our GTU.
-
getSpeedLimit
public final Speed getSpeedLimit()
- Specified by:
getSpeedLimit
in interfaceDefaultSimplePerception
- Returns:
- speedLimit
-
getTimeStampedForwardHeadwayGTU
public final org.opentrafficsim.base.TimeStampedObject<Headway> getTimeStampedForwardHeadwayGTU()
- Returns:
- TimeStamped forwardHeadway, the forward headway and first object (GTU) in front
-
getTimeStampedForwardHeadwayObject
public final org.opentrafficsim.base.TimeStampedObject<Headway> getTimeStampedForwardHeadwayObject()
- Returns:
- TimeStamped forwardHeadway, the forward headway and first object (not a GTU) in front
-
getTimeStampedBackwardHeadway
public final org.opentrafficsim.base.TimeStampedObject<Headway> getTimeStampedBackwardHeadway()
- Returns:
- TimeStamped backwardHeadwayGTU, the backward headway and first object (e.g., a GTU) behind
-
getTimeStampedAccessibleAdjacentLanesLeft
public final org.opentrafficsim.base.TimeStampedObject<Map<Lane,Set<Lane>>> getTimeStampedAccessibleAdjacentLanesLeft()
- Returns:
- TimeStamped accessibleAdjacentLanesLeft, the accessible adjacent lanes on the left
-
getTimeStampedAccessibleAdjacentLanesRight
public final org.opentrafficsim.base.TimeStampedObject<Map<Lane,Set<Lane>>> getTimeStampedAccessibleAdjacentLanesRight()
- Returns:
- TimeStamped accessibleAdjacentLanesRight, the accessible adjacent lanes on the right
-
getTimeStampedAccessibleAdjacentLanes
public final org.opentrafficsim.base.TimeStampedObject<Map<Lane,Set<Lane>>> getTimeStampedAccessibleAdjacentLanes(LateralDirectionality lateralDirection)
- Parameters:
lateralDirection
- LateralDirectionality; the direction to return the accessible adjacent lanes for- Returns:
- TimeStamped accessibleAdjacentLanesRight, the accessible adjacent lanes on the right
-
getTimeStampedNeighboringHeadwaysLeft
public final org.opentrafficsim.base.TimeStampedObject<Collection<Headway>> getTimeStampedNeighboringHeadwaysLeft()
- Returns:
- TimeStamped neighboringHeadwaysLeft, the objects (e.g., GTUs) in parallel, in front and behind on the left neighboring lane, with their headway relative to our GTU, and information about the status of the adjacent objects
-
getTimeStampedNeighboringHeadwaysRight
public final org.opentrafficsim.base.TimeStampedObject<Collection<Headway>> getTimeStampedNeighboringHeadwaysRight()
- Returns:
- TimeStamped neighboringHeadwaysRight, the objects (e.g., GTUs) in parallel, in front and behind on the right neighboring lane, with their headway relative to our GTU, and information about the status of the adjacent objects
-
getTimeStampedNeighboringHeadways
public final org.opentrafficsim.base.TimeStampedObject<Collection<Headway>> getTimeStampedNeighboringHeadways(LateralDirectionality lateralDirection)
- Parameters:
lateralDirection
- LateralDirectionality; the direction to return the neighboring headways for- Returns:
- TimeStamped neighboringHeadwaysRight, the objects (e.g., GTUs) in parallel, in front and behind on the right neighboring lane, with their headway relative to our GTU, and information about the status of the adjacent objects
-
getTimeStampedParallelHeadwaysLeft
public final org.opentrafficsim.base.TimeStampedObject<Collection<Headway>> getTimeStampedParallelHeadwaysLeft()
- Returns:
- TimeStamped parallelHeadwaysLeft, the parallel objects (e.g., GTUs) on the left, with information about their status and parallel overlap with our GTU.
-
getTimeStampedParallelHeadwaysRight
public final org.opentrafficsim.base.TimeStampedObject<Collection<Headway>> getTimeStampedParallelHeadwaysRight()
- Returns:
- TimeStamped parallelHeadwaysRight, the parallel objects (e.g., GTUs) on the right, with information about their status and parallel overlap with our GTU.
-
getTimeStampedParallelHeadways
public final org.opentrafficsim.base.TimeStampedObject<Collection<Headway>> getTimeStampedParallelHeadways(LateralDirectionality lateralDirection)
- Parameters:
lateralDirection
- LateralDirectionality; the direction to return the parallel headways for- Returns:
- TimeStamped parallelHeadwaysRight, the parallel objects (e.g., GTUs) on the right, with information about their status and parallel overlap with our GTU.
-
getTimeStampedSpeedLimit
public final org.opentrafficsim.base.TimeStampedObject<Speed> getTimeStampedSpeedLimit()
- Returns:
- TimeStamped speedLimit
-
getTimeStampedLanePathInfo
public final org.opentrafficsim.base.TimeStampedObject<LanePathInfo> getTimeStampedLanePathInfo()
Retrieve the time stamped last perceived lane path info.- Returns:
- LanePathInfo time stamped last perceived lane path info
-
bestAccessibleAdjacentLane
public final Lane bestAccessibleAdjacentLane(Lane currentLane, LateralDirectionality lateralDirection, Length longitudinalPosition)
Determine whether there is a lane to the left or to the right of this lane, which is accessible from this lane, or null if no lane could be found. The method takes the LongitidinalDirectionality of the lane into account. In other words, if we drive FORWARD and look for a lane on the LEFT, and there is a lane but the Directionality of that lane is not FORWARD or BOTH, null will be returned.
A lane is called adjacent to another lane if the lateral edges are not more than a delta distance apart. This means that a lane that overlaps with another lane is not returned as an adjacent lane.
The algorithm also looks for RoadMarkerAcross elements between the lanes to determine the lateral permeability for a GTU. A RoadMarkerAcross is seen as being between two lanes if its center line is not more than delta distance from the relevant lateral edges of the two adjacent lanes.
When there are multiple lanes that are adjacent, which could e.g. be the case if an overlapping tram lane and a car lane are adjacent to the current lane, the widest lane that best matches the GTU accessibility of the provided GTUType is returned.
Note: LEFT is seen as a negative lateral direction, RIGHT as a positive lateral direction.
FIXME In other places in OTS LEFT is positive (and RIGHT is negative). This should be made more consistent.- Specified by:
bestAccessibleAdjacentLane
in interfaceDefaultSimplePerception
- Parameters:
currentLane
- Lane; the lane to look for the best accessible adjacent lanelateralDirection
- LateralDirectionality; the direction (LEFT, RIGHT) to look atlongitudinalPosition
- Length; the position of the GTU along currentLane- Returns:
- the lane if it is accessible, or null if there is no lane, it is not accessible, or the driving direction does not match.
-
-