public abstract class AbstractLaneBasedGTU extends org.opentrafficsim.core.gtu.AbstractGTU implements LaneBasedGTU
When calculating a headway, the GTU has to look in successive lanes. When Lanes (or underlying CrossSectionLinks) diverge, the headway algorithms have to look at multiple Lanes and return the minimum headway in each of the Lanes. When the Lanes (or underlying CrossSectionLinks) converge, "parallel" traffic is not taken into account in the headway calculation. Instead, gap acceptance algorithms or their equivalent should guide the merging behavior.
To decide its movement, an AbstractLaneBasedGTU applies its car following algorithm and lane change algorithm to set the acceleration and any lane change operation to perform. It then schedules the triggers that will add it to subsequent lanes and remove it from current lanes as needed during the time step that is has committed to. Finally, it re-schedules its next movement evaluation with the simulator.
Copyright (c) 2013-2018 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
Modifier and Type | Field and Description |
---|---|
static int |
CACHED_POSITION
cached position count.
|
static boolean |
CACHING
Caching on or off.
|
static org.djunits.value.vdouble.scalar.Length |
initialLocationThresholdDifference
The threshold distance for differences between initial locations of the GTU on different lanes.
|
static int |
NON_CACHED_POSITION
cached position count.
|
ALIGN_COUNT, ALIGNED, operationalPlan
LANE_CHANGE_EVENT, LANE_ENTER_EVENT, LANE_EXIT_EVENT, LANEBASED_DESTROY_EVENT, LANEBASED_INIT_EVENT, LANEBASED_MOVE_EVENT, LINK_ENTER_EVENT, LINK_EXIT_EVENT
Constructor and Description |
---|
AbstractLaneBasedGTU(String id,
org.opentrafficsim.core.gtu.GTUType gtuType,
nl.tudelft.simulation.dsol.simulators.DEVSSimulatorInterface.TimeDoubleUnit simulator,
org.opentrafficsim.core.network.OTSNetwork network)
Construct a Lane Based GTU.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addGtuToLane(Lane lane,
org.djunits.value.vdouble.scalar.Length position)
Part of 'enterLane' which registers the GTU with the lane so the lane can report its GTUs.
|
void |
addTrigger(Lane lane,
nl.tudelft.simulation.dsol.formalisms.eventscheduling.SimEventInterface<nl.tudelft.simulation.dsol.simtime.SimTimeDoubleUnit> event)
Add an event to the list of lane triggers scheduled for this GTU.
|
void |
changeLaneInstantaneously(org.opentrafficsim.core.network.LateralDirectionality laneChangeDirection)
Change lanes instantaneously.
|
void |
destroy() |
void |
enterLane(Lane lane,
org.djunits.value.vdouble.scalar.Length position,
org.opentrafficsim.core.gtu.GTUDirectionality gtuDirection)
insert GTU at a certain position.
|
protected void |
finalizeLaneChange(org.opentrafficsim.core.network.LateralDirectionality laneChangeDirection)
Performs the finalization of a lane change by leaving the from lanes.
|
double |
fractionalPosition(Lane lane,
org.opentrafficsim.core.gtu.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.
|
double |
fractionalPosition(Lane lane,
org.opentrafficsim.core.gtu.RelativePosition relativePosition,
org.djunits.value.vdouble.scalar.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.
|
Map<Lane,Double> |
fractionalPositions(org.opentrafficsim.core.gtu.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.
|
Map<Lane,Double> |
fractionalPositions(org.opentrafficsim.core.gtu.RelativePosition relativePosition,
org.djunits.value.vdouble.scalar.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.
|
javax.media.j3d.Bounds |
getBounds() |
org.djunits.value.vdouble.scalar.Acceleration |
getCarFollowingAcceleration()
This method returns the current car-following acceleration of the GTU.
|
org.djunits.value.vdouble.scalar.Speed |
getDesiredSpeed()
This method returns the current desired speed of the GTU.
|
org.opentrafficsim.core.gtu.GTUDirectionality |
getDirection(Lane lane)
Return the directionality of a lane on which the GTU is registered for its current operational plan.
|
DirectedLanePosition |
getReferencePosition()
Return the current Lane, position and directionality of the GTU.
|
LaneBasedStrategicalPlanner |
getStrategicalPlanner() |
LaneBasedStrategicalPlanner |
getStrategicalPlanner(org.djunits.value.vdouble.scalar.Time time) |
org.opentrafficsim.core.gtu.TurnIndicatorStatus |
getTurnIndicatorStatus() |
org.opentrafficsim.core.gtu.TurnIndicatorStatus |
getTurnIndicatorStatus(org.djunits.value.vdouble.scalar.Time time) |
VehicleModel |
getVehicleModel()
Returns the vehicle model.
|
void |
init(LaneBasedStrategicalPlanner strategicalPlanner,
Set<DirectedLanePosition> initialLongitudinalPositions,
org.djunits.value.vdouble.scalar.Speed initialSpeed) |
void |
initLaneChange(org.opentrafficsim.core.network.LateralDirectionality laneChangeDirection)
Register on lanes in target lane.
|
boolean |
isSafeToChange()
Hack method.
|
void |
leaveLane(Lane lane)
Unregister the GTU from a lane.
|
void |
leaveLane(Lane lane,
boolean beingDestroyed)
Leave a lane but do not complain about having no lanes left when beingDestroyed is true.
|
protected void |
move(nl.tudelft.simulation.language.d3.DirectedPoint fromLocation) |
org.djunits.value.vdouble.scalar.Length |
position(Lane lane,
org.opentrafficsim.core.gtu.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.
|
org.djunits.value.vdouble.scalar.Length |
position(Lane lane,
org.opentrafficsim.core.gtu.RelativePosition relativePosition,
org.djunits.value.vdouble.scalar.Time when)
Return the longitudinal position of a point relative to this GTU, relative to the center line of the Lane.
|
Map<Lane,org.djunits.value.vdouble.scalar.Length> |
positions(org.opentrafficsim.core.gtu.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.
|
Map<Lane,org.djunits.value.vdouble.scalar.Length> |
positions(org.opentrafficsim.core.gtu.RelativePosition relativePosition,
org.djunits.value.vdouble.scalar.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.
|
org.djunits.value.vdouble.scalar.Length |
projectedPosition(Lane projectionLane,
org.opentrafficsim.core.gtu.RelativePosition relativePosition,
org.djunits.value.vdouble.scalar.Time when)
Return the longitudinal position on the projection lane that has the same fractional position on one of the current lanes
of the indicated relative position.
|
void |
reinit(Set<DirectedLanePosition> initialLongitudinalPositions)
Reinitializes the GTU on the network using the existing strategical planner and zero speed.
|
protected void |
scheduleEnterLeaveTriggers()
Schedule the triggers for this GTU that are going to happen until the next evaluation time.
|
void |
setParent(org.opentrafficsim.core.gtu.GTU gtu)
All lanes the GTU is on will be left.
|
void |
setTurnIndicatorStatus(org.opentrafficsim.core.gtu.TurnIndicatorStatus turnIndicatorStatus)
Set the status of the turn indicator.
|
void |
setVehicleModel(VehicleModel vehicleModel)
Sets a vehicle model.
|
String |
toString() |
org.djunits.value.vdouble.scalar.Length |
translatedPosition(Lane projectionLane,
org.opentrafficsim.core.gtu.RelativePosition relativePosition,
org.djunits.value.vdouble.scalar.Time when)
Return the longitudinal position that the indicated relative position of this GTU would have if it were to change to
another Lane with a / the current CrossSectionLink.
|
addGtu, equals, getAcceleration, getAcceleration, getBaseColor, getChildren, getGTUType, getId, getLocation, getMaximumAcceleration, getMaximumDeceleration, getOdometer, getOdometer, getOperationalPlan, getOperationalPlan, getParameters, getParent, getPerceivableContext, getReference, getSimulator, getSpeed, getSpeed, hashCode, init, interruptMove, isDestroyed, removeGtu, setMaximumAcceleration, setMaximumDeceleration, setParameters
addListener, addListener, addListener, addListener, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, removeAllListeners, removeAllListeners, removeListener
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getLocation, getTacticalPlanner, getTacticalPlanner, isBrakingLightsOn, isBrakingLightsOn, laneChangeAllowed, setNoLaneChangeDistance
addGtu, getAcceleration, getAcceleration, getBaseColor, getCenter, getChildren, getContourPoints, getFront, getGTUType, getId, getLength, getMaximumAcceleration, getMaximumDeceleration, getMaximumSpeed, getOdometer, getOdometer, getOperationalPlan, getOperationalPlan, getParameters, getParent, getRear, getReference, getRelativePositions, getSimulator, getSpeed, getSpeed, getWidth, isDestroyed, removeGtu, setParameters
public static org.djunits.value.vdouble.scalar.Length initialLocationThresholdDifference
public static boolean CACHING
public static int CACHED_POSITION
public static int NON_CACHED_POSITION
public AbstractLaneBasedGTU(String id, org.opentrafficsim.core.gtu.GTUType gtuType, nl.tudelft.simulation.dsol.simulators.DEVSSimulatorInterface.TimeDoubleUnit simulator, org.opentrafficsim.core.network.OTSNetwork network) throws org.opentrafficsim.core.gtu.GTUException
id
- the id of the GTUgtuType
- the type of GTU, e.g. TruckType, CarType, BusTypesimulator
- to initialize the move method and to get the current timenetwork
- the network that the GTU is initially registered inorg.opentrafficsim.core.gtu.GTUException
- when initial values are not correctpublic void init(LaneBasedStrategicalPlanner strategicalPlanner, Set<DirectedLanePosition> initialLongitudinalPositions, org.djunits.value.vdouble.scalar.Speed initialSpeed) throws org.opentrafficsim.core.network.NetworkException, nl.tudelft.simulation.dsol.SimRuntimeException, org.opentrafficsim.core.gtu.GTUException, org.opentrafficsim.core.geometry.OTSGeometryException
strategicalPlanner
- the strategical planner (e.g., route determination) to useinitialLongitudinalPositions
- the initial positions of the car on one or more lanes with their directionsinitialSpeed
- the initial speed of the car on the laneorg.opentrafficsim.core.network.NetworkException
- when the GTU cannot be placed on the given lanenl.tudelft.simulation.dsol.SimRuntimeException
- when the move method cannot be scheduledorg.opentrafficsim.core.gtu.GTUException
- when initial values are not correctorg.opentrafficsim.core.geometry.OTSGeometryException
- when the initial path is wrongpublic void setParent(org.opentrafficsim.core.gtu.GTU gtu) throws org.opentrafficsim.core.gtu.GTUException
setParent
in interface org.opentrafficsim.core.gtu.GTU
setParent
in class org.opentrafficsim.core.gtu.AbstractGTU
org.opentrafficsim.core.gtu.GTUException
public void reinit(Set<DirectedLanePosition> initialLongitudinalPositions) throws org.opentrafficsim.core.network.NetworkException, nl.tudelft.simulation.dsol.SimRuntimeException, org.opentrafficsim.core.gtu.GTUException, org.opentrafficsim.core.geometry.OTSGeometryException
initialLongitudinalPositions
- <Set>; initial positionorg.opentrafficsim.core.network.NetworkException
- when the GTU cannot be placed on the given lanenl.tudelft.simulation.dsol.SimRuntimeException
- when the move method cannot be scheduledorg.opentrafficsim.core.gtu.GTUException
- when initial values are not correctorg.opentrafficsim.core.geometry.OTSGeometryException
- when the initial path is wrongpublic final boolean isSafeToChange() throws org.opentrafficsim.core.gtu.GTUException
org.opentrafficsim.core.gtu.GTUException
- on errorpublic void enterLane(Lane lane, org.djunits.value.vdouble.scalar.Length position, org.opentrafficsim.core.gtu.GTUDirectionality gtuDirection) throws org.opentrafficsim.core.gtu.GTUException
enterLane
in interface LaneBasedGTU
lane
- the lane to add to the list of lanes on which the GTU is registered.position
- the position on the lane.gtuDirection
- the direction of the GTU on the lane (which can be bidirectional). If the GTU has a positive speed,
it is moving in this direction.org.opentrafficsim.core.gtu.GTUException
- when positioning the GTU on the lane causes a problemprotected void addGtuToLane(Lane lane, org.djunits.value.vdouble.scalar.Length position) throws org.opentrafficsim.core.gtu.GTUException
lane
- Lane; laneposition
- Length; positionorg.opentrafficsim.core.gtu.GTUException
- on exceptionpublic void leaveLane(Lane lane) throws org.opentrafficsim.core.gtu.GTUException
leaveLane
in interface LaneBasedGTU
lane
- the lane to remove from the list of lanes on which the GTU is registered.org.opentrafficsim.core.gtu.GTUException
- when leaveLane should not be calledpublic void leaveLane(Lane lane, boolean beingDestroyed) throws org.opentrafficsim.core.gtu.GTUException
lane
- the lane to leavebeingDestroyed
- if true, no complaints about having no lanes leftorg.opentrafficsim.core.gtu.GTUException
- in case leaveLane should not be calledpublic void changeLaneInstantaneously(org.opentrafficsim.core.network.LateralDirectionality laneChangeDirection) throws org.opentrafficsim.core.gtu.GTUException
changeLaneInstantaneously
in interface LaneBasedGTU
laneChangeDirection
- the direction to change toorg.opentrafficsim.core.gtu.GTUException
- in case lane change failspublic void initLaneChange(org.opentrafficsim.core.network.LateralDirectionality laneChangeDirection) throws org.opentrafficsim.core.gtu.GTUException
laneChangeDirection
- direction of lane changeorg.opentrafficsim.core.gtu.GTUException
- exceptionprotected void finalizeLaneChange(org.opentrafficsim.core.network.LateralDirectionality laneChangeDirection)
laneChangeDirection
- direction of lane changepublic final org.opentrafficsim.core.gtu.GTUDirectionality getDirection(Lane lane) throws org.opentrafficsim.core.gtu.GTUException
getDirection
in interface LaneBasedGTU
lane
- Lane; the lane for which we want to know the directionorg.opentrafficsim.core.gtu.GTUException
- in case the GTU is not registered on the Laneprotected void move(nl.tudelft.simulation.language.d3.DirectedPoint fromLocation) throws nl.tudelft.simulation.dsol.SimRuntimeException, org.opentrafficsim.core.gtu.GTUException, org.opentrafficsim.core.gtu.plan.operational.OperationalPlanException, org.opentrafficsim.core.network.NetworkException, org.opentrafficsim.base.parameters.ParameterException
move
in class org.opentrafficsim.core.gtu.AbstractGTU
nl.tudelft.simulation.dsol.SimRuntimeException
org.opentrafficsim.core.gtu.GTUException
org.opentrafficsim.core.gtu.plan.operational.OperationalPlanException
org.opentrafficsim.core.network.NetworkException
org.opentrafficsim.base.parameters.ParameterException
public final Map<Lane,org.djunits.value.vdouble.scalar.Length> positions(org.opentrafficsim.core.gtu.RelativePosition relativePosition) throws org.opentrafficsim.core.gtu.GTUException
positions
in interface LaneBasedGTU
relativePosition
- the position on the vehicle relative to the reference point.org.opentrafficsim.core.gtu.GTUException
- when the vehicle is not on one of the lanes on which it is registered.public final Map<Lane,org.djunits.value.vdouble.scalar.Length> positions(org.opentrafficsim.core.gtu.RelativePosition relativePosition, org.djunits.value.vdouble.scalar.Time when) throws org.opentrafficsim.core.gtu.GTUException
positions
in interface LaneBasedGTU
relativePosition
- the position on the vehicle relative to the reference point.when
- the future time for which to calculate the positions.org.opentrafficsim.core.gtu.GTUException
- when the vehicle is not on one of the lanes on which it is registered.public final org.djunits.value.vdouble.scalar.Length position(Lane lane, org.opentrafficsim.core.gtu.RelativePosition relativePosition) throws org.opentrafficsim.core.gtu.GTUException
position
in interface LaneBasedGTU
lane
- the position on this lane will be returned.relativePosition
- the position on the vehicle relative to the reference point.org.opentrafficsim.core.gtu.GTUException
- when the vehicle is not on the given lane.public org.djunits.value.vdouble.scalar.Length translatedPosition(Lane projectionLane, org.opentrafficsim.core.gtu.RelativePosition relativePosition, org.djunits.value.vdouble.scalar.Time when) throws org.opentrafficsim.core.gtu.GTUException
translatedPosition
in interface LaneBasedGTU
projectionLane
- Lane; the lane onto which the position of this GTU must be projectedrelativePosition
- RelativePosition; the point on this GTU that must be projectedwhen
- Time; the time for which to project the position of this GTUorg.opentrafficsim.core.gtu.GTUException
- when projectionLane it not in any of the CrossSectionLink that the GTU is onpublic org.djunits.value.vdouble.scalar.Length projectedPosition(Lane projectionLane, org.opentrafficsim.core.gtu.RelativePosition relativePosition, org.djunits.value.vdouble.scalar.Time when) throws org.opentrafficsim.core.gtu.GTUException
projectedPosition
in interface LaneBasedGTU
projectionLane
- Lane; the lane onto which the position of this GTU must be projectedrelativePosition
- RelativePosition; the point on this GTU that must be projectedwhen
- Time; the time for which to project the position of this GTUorg.opentrafficsim.core.gtu.GTUException
- when projectionLane it not in any of the CrossSectionLink that the GTU is onpublic org.djunits.value.vdouble.scalar.Length position(Lane lane, org.opentrafficsim.core.gtu.RelativePosition relativePosition, org.djunits.value.vdouble.scalar.Time when) throws org.opentrafficsim.core.gtu.GTUException
position
in interface LaneBasedGTU
lane
- the position on this lane will be returned.relativePosition
- the position on the vehicle relative to the reference point.when
- the future time for which to calculate the positions.org.opentrafficsim.core.gtu.GTUException
- when the vehicle is not on the given lane.public DirectedLanePosition getReferencePosition() throws org.opentrafficsim.core.gtu.GTUException
getReferencePosition
in interface LaneBasedGTU
org.opentrafficsim.core.gtu.GTUException
- in case the reference position of the GTU cannot be found on the lanes in its current pathprotected void scheduleEnterLeaveTriggers() throws org.opentrafficsim.core.network.NetworkException, nl.tudelft.simulation.dsol.SimRuntimeException, org.opentrafficsim.core.gtu.GTUException
org.opentrafficsim.core.network.NetworkException
- on network inconsistencynl.tudelft.simulation.dsol.SimRuntimeException
- should never happenorg.opentrafficsim.core.gtu.GTUException
- when a branch is reached where the GTU does not know where to go nextpublic final Map<Lane,Double> fractionalPositions(org.opentrafficsim.core.gtu.RelativePosition relativePosition) throws org.opentrafficsim.core.gtu.GTUException
fractionalPositions
in interface LaneBasedGTU
relativePosition
- the position on the vehicle relative to the reference point.org.opentrafficsim.core.gtu.GTUException
- when the vehicle is not on one of the lanes on which it is registered.public final Map<Lane,Double> fractionalPositions(org.opentrafficsim.core.gtu.RelativePosition relativePosition, org.djunits.value.vdouble.scalar.Time when) throws org.opentrafficsim.core.gtu.GTUException
fractionalPositions
in interface LaneBasedGTU
relativePosition
- the position on the vehicle relative to the reference point.when
- the future time for which to calculate the positions.org.opentrafficsim.core.gtu.GTUException
- when the vehicle is not on one of the lanes on which it is registered.public final double fractionalPosition(Lane lane, org.opentrafficsim.core.gtu.RelativePosition relativePosition, org.djunits.value.vdouble.scalar.Time when) throws org.opentrafficsim.core.gtu.GTUException
fractionalPosition
in interface LaneBasedGTU
lane
- the position on this lane will be returned.relativePosition
- the position on the vehicle relative to the reference point.when
- the future time for which to calculate the positions.org.opentrafficsim.core.gtu.GTUException
- when the vehicle is not on the given lane.public final double fractionalPosition(Lane lane, org.opentrafficsim.core.gtu.RelativePosition relativePosition) throws org.opentrafficsim.core.gtu.GTUException
fractionalPosition
in interface LaneBasedGTU
lane
- the position on this lane will be returned.relativePosition
- the position on the vehicle relative to the reference point.org.opentrafficsim.core.gtu.GTUException
- when the vehicle is not on the given lane.public final void addTrigger(Lane lane, nl.tudelft.simulation.dsol.formalisms.eventscheduling.SimEventInterface<nl.tudelft.simulation.dsol.simtime.SimTimeDoubleUnit> event)
addTrigger
in interface LaneBasedGTU
lane
- Lane; the lane on which the event occursevent
- SimeEvent<SimTimeDoubleUnit> the eventpublic void setVehicleModel(VehicleModel vehicleModel)
vehicleModel
- VehicleModel; vehicle modelpublic VehicleModel getVehicleModel()
getVehicleModel
in interface LaneBasedGTU
public void destroy()
destroy
in interface org.opentrafficsim.core.gtu.GTU
destroy
in class org.opentrafficsim.core.gtu.AbstractGTU
public final javax.media.j3d.Bounds getBounds()
getBounds
in interface nl.tudelft.simulation.dsol.animation.Locatable
public final LaneBasedStrategicalPlanner getStrategicalPlanner()
getStrategicalPlanner
in interface org.opentrafficsim.core.gtu.GTU
getStrategicalPlanner
in interface LaneBasedGTU
getStrategicalPlanner
in class org.opentrafficsim.core.gtu.AbstractGTU
public final LaneBasedStrategicalPlanner getStrategicalPlanner(org.djunits.value.vdouble.scalar.Time time)
getStrategicalPlanner
in interface org.opentrafficsim.core.gtu.GTU
getStrategicalPlanner
in interface LaneBasedGTU
getStrategicalPlanner
in class org.opentrafficsim.core.gtu.AbstractGTU
public org.djunits.value.vdouble.scalar.Speed getDesiredSpeed()
getDesiredSpeed
in interface LaneBasedGTU
public org.djunits.value.vdouble.scalar.Acceleration getCarFollowingAcceleration()
getCarFollowingAcceleration
in interface LaneBasedGTU
public final org.opentrafficsim.core.gtu.TurnIndicatorStatus getTurnIndicatorStatus()
getTurnIndicatorStatus
in interface LaneBasedGTU
public final org.opentrafficsim.core.gtu.TurnIndicatorStatus getTurnIndicatorStatus(org.djunits.value.vdouble.scalar.Time time)
getTurnIndicatorStatus
in interface LaneBasedGTU
time
- Time; time to obtain the turn indicator status atpublic final void setTurnIndicatorStatus(org.opentrafficsim.core.gtu.TurnIndicatorStatus turnIndicatorStatus)
setTurnIndicatorStatus
in interface LaneBasedGTU
turnIndicatorStatus
- the new status of the turn indicator.Copyright © 2014–2018 Delft University of Technology. All rights reserved.