Package org.opentrafficsim.road.gtu.lane
Interface LaneBasedGTU
- All Superinterfaces:
Drawable,EventProducerInterface,GTU,Identifiable,Locatable,java.io.Serializable
- All Known Implementing Classes:
AbstractLaneBasedGTU,AbstractLaneBasedGTU2,AbstractLaneBasedIndividualGTU,LaneBasedIndividualGTU
public interface LaneBasedGTU extends GTU
This interface defines a lane based GTU.
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: 1401 $, $LastChangedDate: 2015-09-14 01:33:02 +0200 (Mon, 14 Sep 2015) $, by $Author: averbraeck $,
initial version Oct 22, 2014
- Author:
- Alexander Verbraeck, Peter Knoppers
-
Field Summary
Fields Modifier and Type Field Description static EventTypeLANE_CHANGE_EVENTThe event type for pub/sub indicating that the GTU change lane.static EventTypeLANE_ENTER_EVENTThe event type for pub/sub indicating that the GTU entered a new lane (with the FRONT position if driving forward; REAR if driving backward).static EventTypeLANE_EXIT_EVENTThe event type for pub/sub indicating that the GTU exited a lane (with the REAR position if driving forward; FRONT if driving backward).static EventTypeLANEBASED_DESTROY_EVENTThe lane-based event type for pub/sub indicating destruction of the GTU.static EventTypeLANEBASED_INIT_EVENTThe lane-based event type for pub/sub indicating the initialization of a new GTU.static EventTypeLANEBASED_MOVE_EVENTThe lane-based event type for pub/sub indicating a move.static EventTypeLINK_ENTER_EVENTThe event type for pub/sub indicating that the GTU entered a new link (with the FRONT position if driving forward; REAR if driving backward).static EventTypeLINK_EXIT_EVENTThe event type for pub/sub indicating that the GTU exited a link (with the REAR position if driving forward; FRONT if driving backward).Fields inherited from interface org.djutils.event.EventProducerInterface
FIRST_POSITION, LAST_POSITIONFields inherited from interface org.opentrafficsim.core.gtu.GTU
DESTROY_EVENT, INIT_EVENT, MOVE_EVENT -
Method Summary
Modifier and Type Method Description voidaddTrigger(Lane lane, SimEventInterface<SimTimeDoubleUnit> event)Add an event to the list of lane triggers scheduled for this GTU.voidchangeLaneInstantaneously(LateralDirectionality laneChangeDirection)Change lanes instantaneously.doublefractionalPosition(Lane lane, RelativePosition relativePosition)Return the longitudinal position of a point relative to this GTU, relative to the center line of the Lane, as a fraction of the length of the lane.doublefractionalPosition(Lane lane, RelativePosition relativePosition, Time when)Return the longitudinal position of a point relative to this GTU, relative to the center line of the Lane, as a fraction of the length of the lane.java.util.Map<Lane,java.lang.Double>fractionalPositions(RelativePosition relativePosition)Return the longitudinal positions of a point relative to this GTU, relative to the center line of the Lanes in which the vehicle is registered, as fractions of the length of the lane.java.util.Map<Lane,java.lang.Double>fractionalPositions(RelativePosition relativePosition, Time when)Return the longitudinal positions of a point relative to this GTU, relative to the center line of the Lanes in which the vehicle is registered, as fractions of the length of the lane.AccelerationgetCarFollowingAcceleration()This method returns the current car-following acceleration of the GTU.SpeedgetDesiredSpeed()This method returns the current desired speed of the GTU.GTUDirectionalitygetDirection(Lane lane)Return the directionality of a lane on which the GTU is registered for its current operational plan.LengthgetLateralPosition(Lane lane)Returns the lateral position of the GTU relative to the lane center line.DirectedPointgetLocation()Return the location without a RemoteException.RoadNetworkgetNetwork()default LengthgetProjectedLength(Lane lane)Get projected length on the lane.DirectedLanePositiongetReferencePosition()Return the current Lane, position and directionality of the GTU.LaneBasedStrategicalPlannergetStrategicalPlanner()LaneBasedStrategicalPlannergetStrategicalPlanner(Time time)default LaneBasedTacticalPlannergetTacticalPlanner()default LaneBasedTacticalPlannergetTacticalPlanner(Time time)TurnIndicatorStatusgetTurnIndicatorStatus()TurnIndicatorStatusgetTurnIndicatorStatus(Time time)default VehicleModelgetVehicleModel()Returns the vehicle model.voidinitLaneChange(LateralDirectionality laneChangeDirection)Register on lanes in target lane.default booleanisBrakingLightsOn()The default implementation returnstrueif the deceleration is larger than a speed-dependent threshold given by:
c0 * g(v) + c1 + c3*v^2
where c0 = 0.2, c1 = 0.15 and c3 = 0.00025 (with c2 = 0 implicit) are empirically derived averages, and g(v) is 0 below 25 km/h or 1 otherwise, representing that the engine is disengaged at low speeds.default booleanisBrakingLightsOn(Time when)The default implementation returnstrueif the deceleration is larger than a speed-dependent threshold given by:
c0 * g(v) + c1 + c3*v^2
where c0 = 0.2, c1 = 0.15 and c3 = 0.00025 (with c2 = 0 implicit) are empirically derived averages, and g(v) is 0 below 25 km/h or 1 otherwise, representing that the engine is disengaged at low speeds.booleanisInstantaneousLaneChange()Returns whether the GTU perform lane changes instantaneously or not.booleanlaneChangeAllowed()Returns whether a lane change is allowed.Lengthposition(Lane lane, RelativePosition relativePosition)Return the longitudinal position of a point relative to this GTU, relative to the center line of the Lane at the current simulation time.Lengthposition(Lane lane, RelativePosition relativePosition, Time when)Return the longitudinal position of a point relative to this GTU, relative to the center line of the Lane.java.util.Map<Lane,Length>positions(RelativePosition relativePosition)Return the longitudinal positions of a point relative to this GTU, relative to the center line of the Lanes in which the vehicle is registered.java.util.Map<Lane,Length>positions(RelativePosition relativePosition, Time when)Return the longitudinal positions of a point relative to this GTU, relative to the center line of the Lanes in which the vehicle is registered.voidsetFinalizeLaneChangeEvent(SimEventInterface<SimTimeDoubleUnit> event)Sets event to finalize lane change.voidsetInstantaneousLaneChange(boolean instantaneous)Sets whether the GTU perform lane changes instantaneously or not.voidsetNoLaneChangeDistance(Length distance)Set distance over which the GTU should not change lane after being created.voidsetTurnIndicatorStatus(TurnIndicatorStatus turnIndicatorStatus)Set the status of the turn indicator.Methods inherited from interface org.djutils.event.EventProducerInterface
addListener, addListener, addListener, addListener, getEventTypesWithListeners, getSourceId, hasListeners, numberOfListeners, removeListenerMethods inherited from interface org.opentrafficsim.core.gtu.GTU
addGtu, destroy, getAcceleration, getAcceleration, getCenter, getChildren, getContourPoints, getFront, getGTUType, getId, getLength, getMaximumAcceleration, getMaximumDeceleration, getMaximumSpeed, getOdometer, getOdometer, getOperationalPlan, getOperationalPlan, getParameters, getParent, getPerceivableContext, getRear, getReference, getRelativePositions, getSimulator, getSpeed, getSpeed, getWidth, isDestroyed, removeGtu, setErrorHandler, setParameters, setParent
-
Field Details
-
LANEBASED_INIT_EVENT
The lane-based event type for pub/sub indicating the initialization of a new GTU.
Payload: [String gtuId, DirectedPoint initialPosition, Length length, Length width, Lane referenceLane, Length positionOnReferenceLane, GTUDirectionality direction, GTUType gtuType] -
LANEBASED_MOVE_EVENT
The lane-based event type for pub/sub indicating a move.
Payload: [String gtuId, DirectedPoint position, Speed speed, Acceleration acceleration, TurnIndicatorStatus turnIndicatorStatus, Length odometer, Lane referenceLane, Length positionOnReferenceLane, GTUDirectionality direction] -
LANEBASED_DESTROY_EVENT
The lane-based event type for pub/sub indicating destruction of the GTU.
Payload: [String gtuId, DirectedPoint lastPosition, Length odometer, Lane referenceLane, Length positionOnReferenceLane, GTUDirectionality direction] -
LINK_ENTER_EVENT
The event type for pub/sub indicating that the GTU entered a new link (with the FRONT position if driving forward; REAR if driving backward).
Payload: [String gtuId, Link link] -
LINK_EXIT_EVENT
The event type for pub/sub indicating that the GTU exited a link (with the REAR position if driving forward; FRONT if driving backward).
Payload: [String gtuId, Link link] -
LANE_ENTER_EVENT
The event type for pub/sub indicating that the GTU entered a new lane (with the FRONT position if driving forward; REAR if driving backward).
Payload: [String gtuId, Lane lane] -
LANE_EXIT_EVENT
The event type for pub/sub indicating that the GTU exited a lane (with the REAR position if driving forward; FRONT if driving backward).
Payload: [String gtuId, Lane lane] -
LANE_CHANGE_EVENT
The event type for pub/sub indicating that the GTU change lane.
Payload: [String gtuId, LateralDirectionality direction, DirectedLanePosition from]
-
-
Method Details
-
getNetwork
RoadNetwork getNetwork()- Returns:
- the road network to which the LaneBasedGTU belongs
-
getStrategicalPlanner
LaneBasedStrategicalPlanner getStrategicalPlanner()- Specified by:
getStrategicalPlannerin interfaceGTU
-
getStrategicalPlanner
- Specified by:
getStrategicalPlannerin interfaceGTU
-
getTacticalPlanner
- Specified by:
getTacticalPlannerin interfaceGTU
-
getTacticalPlanner
- Specified by:
getTacticalPlannerin interfaceGTU
-
getLocation
DirectedPoint getLocation()Return the location without a RemoteException.- Specified by:
getLocationin interfaceLocatable
-
changeLaneInstantaneously
Change lanes instantaneously.- Parameters:
laneChangeDirection- LateralDirectionality; the direction to change to- Throws:
GTUException- in case lane change fails
-
initLaneChange
Register on lanes in target lane.- Parameters:
laneChangeDirection- LateralDirectionality; direction of lane change- Throws:
GTUException- exception
-
setFinalizeLaneChangeEvent
Sets event to finalize lane change.- Parameters:
event- SimEventInterface<SimTimeDoubleUnit>; event
-
getProjectedLength
Get projected length on the lane.- Parameters:
lane- Lane; lane to project the vehicle on- Returns:
- Length; the length on the lane, which is different from the actual length during deviative tactical plans
- Throws:
GTUException- when the vehicle is not on the given lane
-
setInstantaneousLaneChange
void setInstantaneousLaneChange(boolean instantaneous)Sets whether the GTU perform lane changes instantaneously or not.- Parameters:
instantaneous- boolean; whether the GTU perform lane changes instantaneously or not
-
isInstantaneousLaneChange
boolean isInstantaneousLaneChange()Returns whether the GTU perform lane changes instantaneously or not.- Returns:
- boolean; whether the GTU perform lane changes instantaneously or not
-
positions
Return the longitudinal positions of a point relative to this GTU, relative to the center line of the Lanes in which the vehicle is registered.
Note: If a GTU is registered in multiple parallel lanes, the lateralLaneChangeModel is used to determine the center line of the vehicle at this point in time. Otherwise, the average of the center positions of the lines will be taken.- Parameters:
relativePosition- RelativePosition; the position on the vehicle relative to the reference point.- Returns:
- the lanes and the position on the lanes where the GTU is currently registered, for the given position of the GTU.
- Throws:
GTUException- when the vehicle is not on one of the lanes on which it is registered.
-
positions
java.util.Map<Lane,Length> positions(RelativePosition relativePosition, Time when) throws GTUExceptionReturn the longitudinal positions of a point relative to this GTU, relative to the center line of the Lanes in which the vehicle is registered.- Parameters:
relativePosition- RelativePosition; the position on the vehicle relative to the reference point.when- Time; the future time for which to calculate the positions.- Returns:
- the lanes and the position on the lanes where the GTU will be registered at the time, for the given position of the GTU.
- Throws:
GTUException- when the vehicle is not on one of the lanes on which it is registered.
-
position
Return the longitudinal position of a point relative to this GTU, relative to the center line of the Lane at the current simulation time.- Parameters:
lane- Lane; the position on this lane will be returned.relativePosition- RelativePosition; the position on the vehicle relative to the reference point.- Returns:
- DoubleScalarAbs<LengthUnit>; the position, relative to the center line of the Lane.
- Throws:
GTUException- when the vehicle is not on the given lane.
-
position
Return the longitudinal position of a point relative to this GTU, relative to the center line of the Lane.- Parameters:
lane- Lane; the position on this lane will be returned.relativePosition- RelativePosition; the position on the vehicle relative to the reference point.when- Time; the future time for which to calculate the positions.- Returns:
- DoubleScalarAbs<LengthUnit>; the position, relative to the center line of the Lane.
- Throws:
GTUException- when the vehicle is not on the given lane.
-
fractionalPositions
java.util.Map<Lane,java.lang.Double> fractionalPositions(RelativePosition relativePosition) throws GTUExceptionReturn the longitudinal positions of a point relative to this GTU, relative to the center line of the Lanes in which the vehicle is registered, as fractions of the length of the lane. This is important when we want to see if two vehicles are next to each other and we compare an 'inner' and 'outer' curve.- Parameters:
relativePosition- RelativePosition; the position on the vehicle relative to the reference point.- Returns:
- the lanes and the position on the lanes where the GTU is currently registered, for the given position of the GTU.
- Throws:
GTUException- when the vehicle is not on one of the lanes on which it is registered.
-
fractionalPositions
java.util.Map<Lane,java.lang.Double> fractionalPositions(RelativePosition relativePosition, Time when) throws GTUExceptionReturn the longitudinal positions of a point relative to this GTU, relative to the center line of the Lanes in which the vehicle is registered, as fractions of the length of the lane. This is important when we want to see if two vehicles are next to each other and we compare an 'inner' and 'outer' curve.- Parameters:
relativePosition- RelativePosition; the position on the vehicle relative to the reference point.when- Time; the future time for which to calculate the positions.- Returns:
- the lanes and the position on the lanes where the GTU will be registered at the time, for the given position of the GTU.
- Throws:
GTUException- when the vehicle is not on one of the lanes on which it is registered.
-
fractionalPosition
double fractionalPosition(Lane lane, RelativePosition relativePosition, Time when) throws GTUExceptionReturn the longitudinal position of a point relative to this GTU, relative to the center line of the Lane, as a fraction of the length of the lane. This is important when we want to see if two vehicles are next to each other and we compare an 'inner' and 'outer' curve.- Parameters:
lane- Lane; the position on this lane will be returned.relativePosition- RelativePosition; the position on the vehicle relative to the reference point.when- Time; the future time for which to calculate the positions.- Returns:
- the fractional relative position on the lane at the given time.
- Throws:
GTUException- when the vehicle is not on the given lane.
-
fractionalPosition
Return the longitudinal position of a point relative to this GTU, relative to the center line of the Lane, as a fraction of the length of the lane. This is important when we want to see if two vehicles are next to each other and we compare an 'inner' and 'outer' curve.- Parameters:
lane- Lane; the position on this lane will be returned.relativePosition- RelativePosition; the position on the vehicle relative to the reference point.- Returns:
- the fractional relative position on the lane at the given time.
- Throws:
GTUException- when the vehicle is not on the given lane.
-
getReferencePosition
Return the current Lane, position and directionality of the GTU.- Returns:
- DirectedLanePosition; the current Lane, position and directionality of the GTU
- Throws:
GTUException- in case the reference position of the GTU cannot be found on the lanes in its current path
-
getDirection
Return the directionality of a lane on which the GTU is registered for its current operational plan.- Parameters:
lane- Lane; the lane for which we want to know the direction- Returns:
- GTUDirectionality; the direction on the given lane
- Throws:
GTUException- in case the GTU is not registered on the Lane
-
addTrigger
Add an event to the list of lane triggers scheduled for this GTU.- Parameters:
lane- Lane; the lane on which the event occursevent- SimEventInterface<SimTimeDoubleUnit>; SimeEvent<SimTimeDoubleUnit> the event
-
setNoLaneChangeDistance
Set distance over which the GTU should not change lane after being created.- Parameters:
distance- Length; distance over which the GTU should not change lane after being created
-
laneChangeAllowed
boolean laneChangeAllowed()Returns whether a lane change is allowed.- Returns:
- whether a lane change is allowed
-
getDesiredSpeed
Speed getDesiredSpeed()This method returns the current desired speed of the GTU. This value is required often, so implementations can cache it.- Returns:
- Speed; current desired speed
-
getCarFollowingAcceleration
Acceleration getCarFollowingAcceleration()This method returns the current car-following acceleration of the GTU. This value is required often, so implementations can cache it.- Returns:
- Acceleration; current car-following acceleration
-
getVehicleModel
Returns the vehicle model.- Returns:
- VehicleModel; vehicle model
-
isBrakingLightsOn
default boolean isBrakingLightsOn()The default implementation returnstrueif the deceleration is larger than a speed-dependent threshold given by:
c0 * g(v) + c1 + c3*v^2
where c0 = 0.2, c1 = 0.15 and c3 = 0.00025 (with c2 = 0 implicit) are empirically derived averages, and g(v) is 0 below 25 km/h or 1 otherwise, representing that the engine is disengaged at low speeds.- Returns:
- boolean; whether the braking lights are on
-
isBrakingLightsOn
The default implementation returnstrueif the deceleration is larger than a speed-dependent threshold given by:
c0 * g(v) + c1 + c3*v^2
where c0 = 0.2, c1 = 0.15 and c3 = 0.00025 (with c2 = 0 implicit) are empirically derived averages, and g(v) is 0 below 25 km/h or 1 otherwise, representing that the engine is disengaged at low speeds.- Parameters:
when- Time; time- Returns:
- boolean; whether the braking lights are on
-
getLateralPosition
Returns the lateral position of the GTU relative to the lane center line. Negative values are towards the right.- Parameters:
lane- Lane; lane to consider (most important regarding left/right, not upstream downstream)- Returns:
- Length; lateral position of the GTU relative to the lane center line
- Throws:
GTUException- when the vehicle is not on the given lane.
-
getTurnIndicatorStatus
TurnIndicatorStatus getTurnIndicatorStatus()- Returns:
- the status of the turn indicator
-
getTurnIndicatorStatus
- Parameters:
time- Time; time to obtain the turn indicator status at- Returns:
- the status of the turn indicator at the given time
-
setTurnIndicatorStatus
Set the status of the turn indicator.- Parameters:
turnIndicatorStatus- TurnIndicatorStatus; the new status of the turn indicator.- Throws:
GTUException- when GTUType does not have a turn indicator
-