Class DirectInfrastructurePerception
- 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.DirectInfrastructurePerception
-
- All Implemented Interfaces:
Serializable
,PerceptionCategory<LaneBasedGTU,LanePerception>
,InfrastructurePerception
,LaneBasedPerceptionCategory
public class DirectInfrastructurePerception extends LaneBasedAbstractPerceptionCategory implements InfrastructurePerception
Perceives information concerning the infrastructure, including splits, lanes, speed limits and road markings. This category is optimized by cooperating closely with theLaneStructure
and only updating internal information when the GTU is on a newLane
. On theLane
information is defined relative to the start, and thus easily calculated at each time.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 14, 2016
- Author:
- Alexander Verbraeck, Peter Knoppers, Wouter Schakel
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.opentrafficsim.road.gtu.lane.perception.categories.LaneBasedAbstractPerceptionCategory
MAX_RED_DECELERATION, MAX_YELLOW_DECELERATION
-
-
Constructor Summary
Constructors Constructor Description DirectInfrastructurePerception(LanePerception perception)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SortedSet<RelativeLane>
getCrossSection()
Returns a set of relative lanes representing the cross section.SortedSet<InfrastructureLaneChangeInfo>
getInfrastructureLaneChangeInfo(RelativeLane lane)
Returns infrastructure lane change info of a lane.Length
getLegalLaneChangePossibility(RelativeLane fromLane, LateralDirectionality lat)
Returns the distance over which a lane change remains legally possible.Length
getPhysicalLaneChangePossibility(RelativeLane fromLane, LateralDirectionality lat)
Returns the distance over which a lane change remains physically possible.SpeedLimitProspect
getSpeedLimitProspect(RelativeLane lane)
Returns the prospect for speed limits on a lane (dynamic speed limits may vary between lanes).org.opentrafficsim.base.TimeStampedObject<SortedSet<RelativeLane>>
getTimeStampedCrossSection()
Returns a time stamped set of relative lanes representing the cross section.org.opentrafficsim.base.TimeStampedObject<SortedSet<InfrastructureLaneChangeInfo>>
getTimeStampedInfrastructureLaneChangeInfo(RelativeLane lane)
Returns time stamped infrastructure lane change info of a lane.org.opentrafficsim.base.TimeStampedObject<Length>
getTimeStampedLegalLaneChangePossibility(RelativeLane fromLane, LateralDirectionality lat)
Returns the time stamped distance over which a lane change remains legally possible.org.opentrafficsim.base.TimeStampedObject<Length>
getTimeStampedPhysicalLaneChangePossibility(RelativeLane fromLane, LateralDirectionality lat)
Returns the time stamped distance over which a lane change remains physically possible.org.opentrafficsim.base.TimeStampedObject<SpeedLimitProspect>
getTimeStampedSpeedLimitProspect(RelativeLane lane)
Returns the time stamped prospect for speed limits on a lane (dynamic speed limits may vary between lanes).String
toString()
void
updateAll()
void
updateCrossSection()
Updates a set of relative lanes representing the cross section.void
updateInfrastructureLaneChangeInfo(RelativeLane lane)
Updates the infrastructural lane change info.void
updateLegalLaneChangePossibility(RelativeLane lane, LateralDirectionality lat)
Updates the distance over which lane changes remains legally possible.void
updatePhysicalLaneChangePossibility(RelativeLane lane, LateralDirectionality lat)
Updates the distance over which lane changes remains physically possible.void
updateSpeedLimitProspect(RelativeLane lane)
Updates the speed limit prospect.-
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
-
-
-
-
Constructor Detail
-
DirectInfrastructurePerception
public DirectInfrastructurePerception(LanePerception perception)
- Parameters:
perception
- LanePerception; perception
-
-
Method Detail
-
updateAll
public void updateAll() throws GTUException, org.opentrafficsim.base.parameters.ParameterException
- Specified by:
updateAll
in interfaceInfrastructurePerception
- Specified by:
updateAll
in interfacePerceptionCategory<LaneBasedGTU,LanePerception>
- Throws:
GTUException
org.opentrafficsim.base.parameters.ParameterException
-
updateInfrastructureLaneChangeInfo
public final void updateInfrastructureLaneChangeInfo(RelativeLane lane) throws GTUException, org.opentrafficsim.base.parameters.ParameterException
Updates the infrastructural lane change info. It starts at the given lane and moves downstream over the network. Whenever a point is encountered where lane changes are required, this information is saved.- Specified by:
updateInfrastructureLaneChangeInfo
in interfaceInfrastructurePerception
- Parameters:
lane
- RelativeLane; relative lateral lane- Throws:
GTUException
- if the GTU was not initialized or if the lane is not in the cross sectionorg.opentrafficsim.base.parameters.ParameterException
- if a parameter is not defined
-
updateSpeedLimitProspect
public final void updateSpeedLimitProspect(RelativeLane lane) throws GTUException, org.opentrafficsim.base.parameters.ParameterException
Updates the speed limit prospect.- Specified by:
updateSpeedLimitProspect
in interfaceInfrastructurePerception
- Parameters:
lane
- RelativeLane; relative lateral lane- Throws:
GTUException
- if the GTU was not initialized or if the lane is not in the cross sectionorg.opentrafficsim.base.parameters.ParameterException
- if a parameter is not defined
-
updateLegalLaneChangePossibility
public final void updateLegalLaneChangePossibility(RelativeLane lane, LateralDirectionality lat) throws GTUException, org.opentrafficsim.base.parameters.ParameterException
Updates the distance over which lane changes remains legally possible.- Specified by:
updateLegalLaneChangePossibility
in interfaceInfrastructurePerception
- Parameters:
lane
- RelativeLane; lane from which the lane change possibility is requestedlat
- LateralDirectionality; LEFT or RIGHT, null not allowed- Throws:
GTUException
- if the GTU was not initialized or if the lane is not in the cross sectionorg.opentrafficsim.base.parameters.ParameterException
- if a parameter is not defined
-
updatePhysicalLaneChangePossibility
public final void updatePhysicalLaneChangePossibility(RelativeLane lane, LateralDirectionality lat) throws GTUException, org.opentrafficsim.base.parameters.ParameterException
Updates the distance over which lane changes remains physically possible.- Specified by:
updatePhysicalLaneChangePossibility
in interfaceInfrastructurePerception
- Parameters:
lane
- RelativeLane; lane from which the lane change possibility is requestedlat
- LateralDirectionality; LEFT or RIGHT, null not allowed- Throws:
GTUException
- if the GTU was not initialized or if the lane is not in the cross sectionorg.opentrafficsim.base.parameters.ParameterException
- if a parameter is not defined
-
updateCrossSection
public final void updateCrossSection() throws GTUException, org.opentrafficsim.base.parameters.ParameterException
Updates a set of relative lanes representing the cross section. This set consists of all lanes on the current link, and an additional lane on the left and/or right side in case of a merge that is sufficiently nearby.- Specified by:
updateCrossSection
in interfaceInfrastructurePerception
- Throws:
GTUException
- if the GTU was not initializedorg.opentrafficsim.base.parameters.ParameterException
- if a parameter is not defined
-
getInfrastructureLaneChangeInfo
public final SortedSet<InfrastructureLaneChangeInfo> getInfrastructureLaneChangeInfo(RelativeLane lane)
Returns infrastructure lane change info of a lane. A set is returned as multiple points may force lane changes. Which point is considered most critical is a matter of driver interpretation and may change over time. This is shown below. Suppose vehicle A needs to take the off-ramp, and that behavior is that the minimum distance per required lane change determines how critical it is. First, 400m before the lane-drop, the off-ramp is critical. 300m downstream, the lane-drop is critical. Info is sorted by distance, closest first._______ _ _A_ _\_________ _ _ _ _ _ _ _ _ _ _________ _ _ ___ \_______ (-) Lane-drop: 1 lane change in 400m (400m per lane change) (--------) Off-ramp: 3 lane changes in 900m (300m per lane change, critical) (-) Lane-drop: 1 lane change in 100m (100m per lane change, critical) (--------) Off-ramp: 3 lane changes in 600m (200m per lane change)
- Specified by:
getInfrastructureLaneChangeInfo
in interfaceInfrastructurePerception
- Parameters:
lane
- RelativeLane; relative lateral lane- Returns:
- infrastructure lane change info of a lane
-
getSpeedLimitProspect
public final SpeedLimitProspect getSpeedLimitProspect(RelativeLane lane)
Returns the prospect for speed limits on a lane (dynamic speed limits may vary between lanes).- Specified by:
getSpeedLimitProspect
in interfaceInfrastructurePerception
- Parameters:
lane
- RelativeLane; relative lateral lane- Returns:
- prospect for speed limits on a lane
-
getLegalLaneChangePossibility
public final Length getLegalLaneChangePossibility(RelativeLane fromLane, LateralDirectionality lat)
Returns the distance over which a lane change remains legally possible. Negative values indicate the distance over which a lane change is legally not possible.- Specified by:
getLegalLaneChangePossibility
in interfaceInfrastructurePerception
- Parameters:
fromLane
- RelativeLane; lane from which the lane change possibility is requestedlat
- LateralDirectionality; LEFT or RIGHT, null not allowed- Returns:
- distance over which a lane change remains possible
-
getPhysicalLaneChangePossibility
public final Length getPhysicalLaneChangePossibility(RelativeLane fromLane, LateralDirectionality lat)
Returns the distance over which a lane change remains physically possible. Negative values indicate the distance over which a lane change is physically not possible.- Specified by:
getPhysicalLaneChangePossibility
in interfaceInfrastructurePerception
- Parameters:
fromLane
- RelativeLane; lane from which the lane change possibility is requestedlat
- LateralDirectionality; LEFT or RIGHT, null not allowed- Returns:
- distance over which a lane change remains possible
-
getCrossSection
public final SortedSet<RelativeLane> getCrossSection()
Returns a set of relative lanes representing the cross section. Lanes are sorted left to right.- Specified by:
getCrossSection
in interfaceInfrastructurePerception
- Returns:
- set of relative lanes representing the cross section
-
getTimeStampedInfrastructureLaneChangeInfo
public final org.opentrafficsim.base.TimeStampedObject<SortedSet<InfrastructureLaneChangeInfo>> getTimeStampedInfrastructureLaneChangeInfo(RelativeLane lane)
Returns time stamped infrastructure lane change info of a lane. A set is returned as multiple points may force lane changes. Which point is considered most critical is a matter of driver interpretation and may change over time. This is shown below. Suppose vehicle A needs to take the off-ramp, and that behavior is that the minimum distance per required lane change determines how critical it is. First, 400m before the lane-drop, the off-ramp is critical. 300m downstream, the lane-drop is critical. Info is sorted by distance, closest first._______ _ _A_ _\_________ _ _ _ _ _ _ _ _ _ _________ _ _ ___ \_______ (-) Lane-drop: 1 lane change in 400m (400m per lane change) (--------) Off-ramp: 3 lane changes in 900m (300m per lane change, critical) (-) Lane-drop: 1 lane change in 100m (100m per lane change, critical) (--------) Off-ramp: 3 lane changes in 600m (200m per lane change)
- Parameters:
lane
- RelativeLane; relative lateral lane- Returns:
- time stamped infrastructure lane change info of a lane
-
getTimeStampedSpeedLimitProspect
public final org.opentrafficsim.base.TimeStampedObject<SpeedLimitProspect> getTimeStampedSpeedLimitProspect(RelativeLane lane)
Returns the time stamped prospect for speed limits on a lane (dynamic speed limits may vary between lanes).- Parameters:
lane
- RelativeLane; relative lateral lane- Returns:
- time stamped prospect for speed limits on a lane
-
getTimeStampedLegalLaneChangePossibility
public final org.opentrafficsim.base.TimeStampedObject<Length> getTimeStampedLegalLaneChangePossibility(RelativeLane fromLane, LateralDirectionality lat)
Returns the time stamped distance over which a lane change remains legally possible.- Parameters:
fromLane
- RelativeLane; lane from which the lane change possibility is requestedlat
- LateralDirectionality; LEFT or RIGHT, null not allowed- Returns:
- time stamped distance over which a lane change remains possible
- Throws:
NullPointerException
- iflat == null
-
getTimeStampedPhysicalLaneChangePossibility
public final org.opentrafficsim.base.TimeStampedObject<Length> getTimeStampedPhysicalLaneChangePossibility(RelativeLane fromLane, LateralDirectionality lat)
Returns the time stamped distance over which a lane change remains physically possible.- Parameters:
fromLane
- RelativeLane; lane from which the lane change possibility is requestedlat
- LateralDirectionality; LEFT or RIGHT, null not allowed- Returns:
- time stamped distance over which a lane change remains possible
- Throws:
NullPointerException
- iflat == null
-
getTimeStampedCrossSection
public final org.opentrafficsim.base.TimeStampedObject<SortedSet<RelativeLane>> getTimeStampedCrossSection()
Returns a time stamped set of relative lanes representing the cross section. Lanes are sorted left to right.- Returns:
- time stamped set of relative lanes representing the cross section
-
-