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:
java.io.Serializable,PerceptionCategory<LaneBasedGTU,LanePerception>,DefaultSimplePerception,LaneBasedPerceptionCategory
public class DirectDefaultSimplePerception extends LaneBasedAbstractPerceptionCategory implements DefaultSimplePerception
Copyright (c) 2013-2020 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 ParameterTypeLengthLOOKAHEADLook ahead parameter type.protected static ParameterTypeLengthLOOKBACKOLDLook 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 LanebestAccessibleAdjacentLane(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.java.util.Map<Lane,java.util.Set<Lane>>getAccessibleAdjacentLanes(LateralDirectionality lateralDirection)java.util.Map<Lane,java.util.Set<Lane>>getAccessibleAdjacentLanesLeft()java.util.Map<Lane,java.util.Set<Lane>>getAccessibleAdjacentLanesRight()HeadwaygetBackwardHeadway()HeadwaygetForwardHeadwayGTU()HeadwaygetForwardHeadwayObject()LanePathInfogetLanePathInfo()Retrieve the last perceived lane path info.java.util.Collection<Headway>getNeighboringHeadways(LateralDirectionality lateralDirection)java.util.Collection<Headway>getNeighboringHeadwaysLeft()java.util.Collection<Headway>getNeighboringHeadwaysRight()java.util.Collection<Headway>getParallelHeadways(LateralDirectionality lateralDirection)java.util.Collection<Headway>getParallelHeadwaysLeft()java.util.Collection<Headway>getParallelHeadwaysRight()SpeedgetSpeedLimit()TimeStampedObject<java.util.Map<Lane,java.util.Set<Lane>>>getTimeStampedAccessibleAdjacentLanes(LateralDirectionality lateralDirection)TimeStampedObject<java.util.Map<Lane,java.util.Set<Lane>>>getTimeStampedAccessibleAdjacentLanesLeft()TimeStampedObject<java.util.Map<Lane,java.util.Set<Lane>>>getTimeStampedAccessibleAdjacentLanesRight()TimeStampedObject<Headway>getTimeStampedBackwardHeadway()TimeStampedObject<Headway>getTimeStampedForwardHeadwayGTU()TimeStampedObject<Headway>getTimeStampedForwardHeadwayObject()TimeStampedObject<LanePathInfo>getTimeStampedLanePathInfo()Retrieve the time stamped last perceived lane path info.TimeStampedObject<java.util.Collection<Headway>>getTimeStampedNeighboringHeadways(LateralDirectionality lateralDirection)TimeStampedObject<java.util.Collection<Headway>>getTimeStampedNeighboringHeadwaysLeft()TimeStampedObject<java.util.Collection<Headway>>getTimeStampedNeighboringHeadwaysRight()TimeStampedObject<java.util.Collection<Headway>>getTimeStampedParallelHeadways(LateralDirectionality lateralDirection)TimeStampedObject<java.util.Collection<Headway>>getTimeStampedParallelHeadwaysLeft()TimeStampedObject<java.util.Collection<Headway>>getTimeStampedParallelHeadwaysRight()TimeStampedObject<Speed>getTimeStampedSpeedLimit()java.lang.StringtoString()voidupdateAccessibleAdjacentLanesLeft()Update the accessible adjacent lanes on the left.voidupdateAccessibleAdjacentLanesRight()Update the accessible adjacent lanes on the right.voidupdateBackwardHeadway()Update the backward headway and first object (e.g., a GTU) behind.voidupdateForwardHeadwayGTU()Update the forward headway and first object (a GTU) in front.voidupdateForwardHeadwayObject()Update the forward headway and first object (but not a GTU) in front.voidupdateLanePathInfo()voidupdateNeighboringHeadways(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.voidupdateNeighboringHeadwaysLeft()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.voidupdateNeighboringHeadwaysRight()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.voidupdateParallelHeadways(LateralDirectionality lateralDirection)Update the parallel objects (e.g., GTUs) for the given direction, with information about their status and parallel overlap with our GTU.voidupdateParallelHeadwaysLeft()Update the parallel objects (e.g., GTUs) on the left, with information about their status and parallel overlap with our GTU.voidupdateParallelHeadwaysRight()Update the parallel objects (e.g., GTUs) on the right, with information about their status and parallel overlap with our GTU.voidupdateSpeedLimit()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
-
-
-
-
Field Detail
-
LOOKAHEAD
protected static final ParameterTypeLength LOOKAHEAD
Look ahead parameter type.
-
LOOKBACKOLD
protected static final ParameterTypeLength LOOKBACKOLD
Look back parameter type.
-
-
Constructor Detail
-
DirectDefaultSimplePerception
public DirectDefaultSimplePerception(LanePerception perception)
- Parameters:
perception- LanePerception; perception
-
-
Method Detail
-
updateLanePathInfo
public final void updateLanePathInfo() throws GTUException, NetworkException, ParameterException- Specified by:
updateLanePathInfoin 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.ParameterException- in case of not being able to retrieve parameter ParameterTypes.LOOKAHEAD
-
updateForwardHeadwayGTU
public final void updateForwardHeadwayGTU() throws GTUException, NetworkException, ParameterExceptionUpdate the forward headway and first object (a GTU) in front.- Specified by:
updateForwardHeadwayGTUin interfaceDefaultSimplePerception- Throws:
GTUException- when the GTU was not yet initializedNetworkException- in case of network exceptionParameterException- if parameter is not defined or out of bounds
-
updateForwardHeadwayObject
public final void updateForwardHeadwayObject() throws GTUException, NetworkException, ParameterExceptionUpdate the forward headway and first object (but not a GTU) in front.- Specified by:
updateForwardHeadwayObjectin interfaceDefaultSimplePerception- Throws:
GTUException- when the GTU was not yet initializedNetworkException- in case of network exceptionParameterException- if parameter is not defined or out of bounds
-
updateBackwardHeadway
public final void updateBackwardHeadway() throws GTUException, ParameterException, NetworkExceptionUpdate the backward headway and first object (e.g., a GTU) behind.- Specified by:
updateBackwardHeadwayin interfaceDefaultSimplePerception- Throws:
GTUException- when the GTU was not yet initializedParameterException- if parameter is not defined or out of boundsNetworkException- in case of network exception
-
updateAccessibleAdjacentLanesLeft
public final void updateAccessibleAdjacentLanesLeft() throws GTUExceptionUpdate the accessible adjacent lanes on the left.- Specified by:
updateAccessibleAdjacentLanesLeftin interfaceDefaultSimplePerception- Throws:
GTUException- when the GTU was not yet initialized
-
updateAccessibleAdjacentLanesRight
public final void updateAccessibleAdjacentLanesRight() throws GTUExceptionUpdate the accessible adjacent lanes on the right.- Specified by:
updateAccessibleAdjacentLanesRightin interfaceDefaultSimplePerception- Throws:
GTUException- when the GTU was not yet initialized
-
updateNeighboringHeadwaysLeft
public final void updateNeighboringHeadwaysLeft() throws GTUException, ParameterException, NetworkExceptionUpdate 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:
updateNeighboringHeadwaysLeftin interfaceDefaultSimplePerception- Throws:
GTUException- when the GTU was not yet initializedParameterException- if parameter is not defined or out of boundsNetworkException- in case of network exception
-
updateNeighboringHeadwaysRight
public final void updateNeighboringHeadwaysRight() throws GTUException, ParameterException, NetworkExceptionUpdate 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:
updateNeighboringHeadwaysRightin interfaceDefaultSimplePerception- Throws:
GTUException- when the GTU was not yet initializedParameterException- if parameter is not defined or out of boundsNetworkException- in case of network exception
-
updateNeighboringHeadways
public final void updateNeighboringHeadways(LateralDirectionality lateralDirection) throws GTUException, 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:
updateNeighboringHeadwaysin interfaceDefaultSimplePerception- Parameters:
lateralDirection- LateralDirectionality; the direction to update the parallel headway collection for- Throws:
GTUException- when the GTU was not yet initializedParameterException- if parameter is not defined or out of boundsNetworkException- in case of network exception
-
updateParallelHeadwaysLeft
public final void updateParallelHeadwaysLeft() throws GTUExceptionUpdate the parallel objects (e.g., GTUs) on the left, with information about their status and parallel overlap with our GTU.- Specified by:
updateParallelHeadwaysLeftin interfaceDefaultSimplePerception- Throws:
GTUException- when the GTU was not yet initialized
-
updateParallelHeadwaysRight
public final void updateParallelHeadwaysRight() throws GTUExceptionUpdate the parallel objects (e.g., GTUs) on the right, with information about their status and parallel overlap with our GTU.- Specified by:
updateParallelHeadwaysRightin 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:
updateParallelHeadwaysin 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, NetworkExceptionUpdate speedLimit.- Specified by:
updateSpeedLimitin 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:
getLanePathInfoin interfaceDefaultSimplePerception- Returns:
- LanePathInfo
-
getForwardHeadwayGTU
public final Headway getForwardHeadwayGTU()
- Specified by:
getForwardHeadwayGTUin interfaceDefaultSimplePerception- Returns:
- forwardHeadway, the forward headway and first object (GTU) in front
-
getForwardHeadwayObject
public final Headway getForwardHeadwayObject()
- Specified by:
getForwardHeadwayObjectin interfaceDefaultSimplePerception- Returns:
- forwardHeadway, the forward headway and first object (not a GTU) in front
-
getBackwardHeadway
public final Headway getBackwardHeadway()
- Specified by:
getBackwardHeadwayin interfaceDefaultSimplePerception- Returns:
- backwardHeadwayGTU, the backward headway and first object (e.g., a GTU) behind
-
getAccessibleAdjacentLanesLeft
public final java.util.Map<Lane,java.util.Set<Lane>> getAccessibleAdjacentLanesLeft()
- Specified by:
getAccessibleAdjacentLanesLeftin interfaceDefaultSimplePerception- Returns:
- accessibleAdjacentLanesLeft, the accessible adjacent lanes on the left
-
getAccessibleAdjacentLanesRight
public final java.util.Map<Lane,java.util.Set<Lane>> getAccessibleAdjacentLanesRight()
- Specified by:
getAccessibleAdjacentLanesRightin interfaceDefaultSimplePerception- Returns:
- accessibleAdjacentLanesRight, the accessible adjacent lanes on the right
-
getAccessibleAdjacentLanes
public final java.util.Map<Lane,java.util.Set<Lane>> getAccessibleAdjacentLanes(LateralDirectionality lateralDirection)
- Specified by:
getAccessibleAdjacentLanesin 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 java.util.Collection<Headway> getNeighboringHeadwaysLeft()
- Specified by:
getNeighboringHeadwaysLeftin 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 java.util.Collection<Headway> getNeighboringHeadwaysRight()
- Specified by:
getNeighboringHeadwaysRightin 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 java.util.Collection<Headway> getNeighboringHeadways(LateralDirectionality lateralDirection)
- Specified by:
getNeighboringHeadwaysin 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 java.util.Collection<Headway> getParallelHeadwaysLeft()
- Specified by:
getParallelHeadwaysLeftin 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 java.util.Collection<Headway> getParallelHeadwaysRight()
- Specified by:
getParallelHeadwaysRightin 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 java.util.Collection<Headway> getParallelHeadways(LateralDirectionality lateralDirection)
- Specified by:
getParallelHeadwaysin 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:
getSpeedLimitin interfaceDefaultSimplePerception- Returns:
- speedLimit
-
getTimeStampedForwardHeadwayGTU
public final TimeStampedObject<Headway> getTimeStampedForwardHeadwayGTU()
- Returns:
- TimeStamped forwardHeadway, the forward headway and first object (GTU) in front
-
getTimeStampedForwardHeadwayObject
public final TimeStampedObject<Headway> getTimeStampedForwardHeadwayObject()
- Returns:
- TimeStamped forwardHeadway, the forward headway and first object (not a GTU) in front
-
getTimeStampedBackwardHeadway
public final TimeStampedObject<Headway> getTimeStampedBackwardHeadway()
- Returns:
- TimeStamped backwardHeadwayGTU, the backward headway and first object (e.g., a GTU) behind
-
getTimeStampedAccessibleAdjacentLanesLeft
public final TimeStampedObject<java.util.Map<Lane,java.util.Set<Lane>>> getTimeStampedAccessibleAdjacentLanesLeft()
- Returns:
- TimeStamped accessibleAdjacentLanesLeft, the accessible adjacent lanes on the left
-
getTimeStampedAccessibleAdjacentLanesRight
public final TimeStampedObject<java.util.Map<Lane,java.util.Set<Lane>>> getTimeStampedAccessibleAdjacentLanesRight()
- Returns:
- TimeStamped accessibleAdjacentLanesRight, the accessible adjacent lanes on the right
-
getTimeStampedAccessibleAdjacentLanes
public final TimeStampedObject<java.util.Map<Lane,java.util.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 TimeStampedObject<java.util.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 TimeStampedObject<java.util.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 TimeStampedObject<java.util.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 TimeStampedObject<java.util.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 TimeStampedObject<java.util.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 TimeStampedObject<java.util.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 TimeStampedObject<Speed> getTimeStampedSpeedLimit()
- Returns:
- TimeStamped speedLimit
-
getTimeStampedLanePathInfo
public final 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:
bestAccessibleAdjacentLanein 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.
-
toString
public final java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-