Class TacticalContextEgo
java.lang.Object
org.opentrafficsim.road.gtu.tactical.TacticalContextEgo
- All Implemented Interfaces:
Identifiable,TacticalContext
Wraps a
LaneBasedGtu and provides bundled and easy-access information that tactical models and their components need
regarding the ego-vehicle. This information may be cached, such that different components do not need to repeat expensive
steps to obtain certain information. Because of the caching, this is a throw-away class that should only have a lifetime
equal to a single model execution.
Copyright (c) 2026-2026 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
- Author:
- Wouter Schakel
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd value for intent.org.djunits.value.vdouble.scalar.AccelerationReturn ego acceleration.org.djunits.value.vdouble.scalar.AccelerationReturns the car-following acceleration from the car-following model and leaders perceived by the neighbor category.Returns the car-following model.org.djunits.value.vdouble.scalar.SpeedReturns the desired speed from the car-following model.Returns the GTU type.getId()<T> Optional<DistancedObject<T>>Returns the nearest value of intent of type given by the class.<T> Optional<DistancedObject<T>>Returns the nearest value of intent of type given by the class, if within a distance.Returns the lane change direction.org.djunits.value.vdouble.scalar.LengthReturn ego length.org.djunits.value.vdouble.scalar.SpeedReturns the maximum seed.Returns the parameters.Returns the perception.Returns the current position.getRoute()Returns the route.org.djunits.value.vdouble.scalar.SpeedgetSpeed()Return ego speed.Returns the speed limits at the current location.org.djunits.value.vdouble.scalar.DurationgetTime()Returns the current time.Returns the GTU.org.djunits.value.vdouble.scalar.LengthgetWidth()Return ego width.toString()
-
Constructor Details
-
TacticalContextEgo
Constructor.- Parameters:
gtu- GTU
-
-
Method Details
-
getUnsafeGtu
Returns the GTU. This is tagged as unsafe because models should not typically interfere with the simulation structure. Still, sometimes information or commands are required outside of the tactical context. This should only be done with care and full understanding of what is being done.- Returns:
- GTU
-
getPerception
Returns the perception.- Returns:
- perception
-
getTime
public org.djunits.value.vdouble.scalar.Duration getTime()Returns the current time.- Returns:
- current time
-
getCarFollowingAcceleration
public org.djunits.value.vdouble.scalar.Acceleration getCarFollowingAcceleration() throws ParameterExceptionReturns the car-following acceleration from the car-following model and leaders perceived by the neighbor category.- Returns:
- car-following acceleration from the car-following model
- Throws:
NoSuchElementException- when neighbors perception is not presentParameterException- if a parameter is not present
-
getPosition
Returns the current position.- Returns:
- current position
-
addIntent
Add value for intent. The type (class) of the value determines the type of intent.- Parameters:
intent- intent valuedistance- distance at which the intent applies
-
getIntent
Returns the nearest value of intent of type given by the class.- Type Parameters:
T- value type- Parameters:
clazz- class of type- Returns:
- nearest value of intent of type given by the class, empty if no such intent
- Throws:
NullPointerException- when any input isnull
-
getIntent
public <T> Optional<DistancedObject<T>> getIntent(Class<T> clazz, org.djunits.value.vdouble.scalar.Length horizon) Returns the nearest value of intent of type given by the class, if within a distance.- Type Parameters:
T- value type- Parameters:
clazz- class of typehorizon- obtain intent only within this distance- Returns:
- nearest value of intent of type given by the class, empty if no such intent
- Throws:
NullPointerException- when any input isnull
-
getId
- Specified by:
getIdin interfaceIdentifiable
-
getGtuType
Description copied from interface:TacticalContextReturns the GTU type.- Specified by:
getGtuTypein interfaceTacticalContext- Returns:
- GTU type
-
getParameters
Description copied from interface:TacticalContextReturns the parameters.- Specified by:
getParametersin interfaceTacticalContext- Returns:
- parameters
-
getCarFollowingModel
Description copied from interface:TacticalContextReturns the car-following model.- Specified by:
getCarFollowingModelin interfaceTacticalContext- Returns:
- car-following model
-
getSpeedLimits
Description copied from interface:TacticalContextReturns the speed limits at the current location.- Specified by:
getSpeedLimitsin interfaceTacticalContext- Returns:
- speed limits
-
getDesiredSpeed
Description copied from interface:TacticalContextReturns the desired speed from the car-following model.- Specified by:
getDesiredSpeedin interfaceTacticalContext- Returns:
- desired speed from the car-following model
- Throws:
ParameterException- if a parameter is not present
-
getRoute
Description copied from interface:TacticalContextReturns the route.- Specified by:
getRoutein interfaceTacticalContext- Returns:
- route
-
getLaneChangeDirection
Description copied from interface:TacticalContextReturns the lane change direction.- Specified by:
getLaneChangeDirectionin interfaceTacticalContext- Returns:
- lane change direction
-
getLength
public org.djunits.value.vdouble.scalar.Length getLength()Description copied from interface:TacticalContextReturn ego length.- Specified by:
getLengthin interfaceTacticalContext- Returns:
- ego length
-
getWidth
public org.djunits.value.vdouble.scalar.Length getWidth()Description copied from interface:TacticalContextReturn ego width.- Specified by:
getWidthin interfaceTacticalContext- Returns:
- ego width
-
getSpeed
public org.djunits.value.vdouble.scalar.Speed getSpeed()Description copied from interface:TacticalContextReturn ego speed.- Specified by:
getSpeedin interfaceTacticalContext- Returns:
- ego speed
-
getMaximumSpeed
public org.djunits.value.vdouble.scalar.Speed getMaximumSpeed()Description copied from interface:TacticalContextReturns the maximum seed.- Specified by:
getMaximumSpeedin interfaceTacticalContext- Returns:
- maximum speed
-
getAcceleration
public org.djunits.value.vdouble.scalar.Acceleration getAcceleration()Description copied from interface:TacticalContextReturn ego acceleration.- Specified by:
getAccelerationin interfaceTacticalContext- Returns:
- ego acceleration
-
toString
-