public abstract class AbstractLaneBasedGTU2 extends 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-2019 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 Length |
eventMargin
Margin to add to plan to check of the path will enter the next section.
|
static 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
DESTROY_EVENT, INIT_EVENT, MOVE_EVENT
Constructor and Description |
---|
AbstractLaneBasedGTU2(String id,
GTUType gtuType,
OTSSimulatorInterface simulator,
OTSRoadNetwork network)
Construct a Lane Based GTU.
|
Modifier and Type | Method and Description |
---|---|
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(LateralDirectionality laneChangeDirection)
Change lanes instantaneously.
|
void |
destroy() |
protected void |
enterCrossSection()
Appends a new cross-section at the downstream end.
|
protected void |
finalizeLaneChange(LateralDirectionality laneChangeDirection)
Performs the finalization of a lane change by leaving the from lanes.
|
double |
fractionalPosition(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.
|
double |
fractionalPosition(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.
|
Map<Lane,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.
|
Map<Lane,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.
|
javax.media.j3d.Bounds |
getBounds() |
Acceleration |
getCarFollowingAcceleration()
This method returns the current car-following acceleration of the GTU.
|
Speed |
getDesiredSpeed()
This method returns the current desired speed of the GTU.
|
GTUDirectionality |
getDirection(Lane lane)
Return the directionality of a lane on which the GTU is registered for its current operational plan.
|
Length |
getLateralPosition(Lane lane)
Returns the lateral position of the GTU relative to the lane center line.
|
RoadNetwork |
getNetwork() |
DirectedLanePosition |
getReferencePosition()
Return the current Lane, position and directionality of the GTU.
|
LaneBasedStrategicalPlanner |
getStrategicalPlanner() |
LaneBasedStrategicalPlanner |
getStrategicalPlanner(Time time) |
TurnIndicatorStatus |
getTurnIndicatorStatus() |
TurnIndicatorStatus |
getTurnIndicatorStatus(Time time) |
VehicleModel |
getVehicleModel()
Returns the vehicle model.
|
void |
init(LaneBasedStrategicalPlanner strategicalPlanner,
Set<DirectedLanePosition> initialLongitudinalPositions,
Speed initialSpeed) |
void |
initLaneChange(LateralDirectionality laneChangeDirection)
Register on lanes in target lane.
|
boolean |
isInstantaneousLaneChange()
Returns whether the GTU perform lane changes instantaneously or not.
|
protected void |
leaveCrossSection()
Removes registration between the GTU and the lanes in the most upstream cross-section.
|
protected boolean |
move(nl.tudelft.simulation.language.d3.DirectedPoint fromLocation) |
Length |
position(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.
|
Length |
position(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.
|
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.
|
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.
|
void |
reinit(Set<DirectedLanePosition> initialLongitudinalPositions)
Reinitializes the GTU on the network using the existing strategical planner and zero speed.
|
protected void |
scheduleEnterEvent()
Checks whether the GTU will enter a next cross-section during the (remainder of) the tactical plan.
|
protected void |
scheduleLeaveEvent()
Checks whether the GTU will leave a cross-section during the (remainder of) the tactical plan.
|
protected void |
scheduleTriggers(Lane lane,
GTUDirectionality direction)
Schedules all trigger events during the current operational plan on the lane.
|
void |
setFinalizeLaneChangeEvent(nl.tudelft.simulation.dsol.formalisms.eventscheduling.SimEventInterface<nl.tudelft.simulation.dsol.simtime.SimTimeDoubleUnit> event)
Sets event to finalize lane change.
|
void |
setInstantaneousLaneChange(boolean instantaneous)
Sets whether the GTU perform lane changes instantaneously or not.
|
void |
setParent(GTU gtu)
All lanes the GTU is on will be left.
|
void |
setTurnIndicatorStatus(TurnIndicatorStatus turnIndicatorStatus)
Set the status of the turn indicator.
|
void |
setVehicleModel(VehicleModel vehicleModel)
Sets a vehicle model.
|
String |
toString() |
addGtu, equals, getAcceleration, getAcceleration, getChildren, getErrorHandler, getGTUType, getId, getLocation, getMaximumAcceleration, getMaximumDeceleration, getNextMoveEvent, getOdometer, getOdometer, getOperationalPlan, getOperationalPlan, getParameters, getParent, getPerceivableContext, getReference, getSimulator, getSpeed, getSpeed, hashCode, init, interruptMove, isDestroyed, removeGtu, setErrorHandler, 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, getProjectedLength, getTacticalPlanner, getTacticalPlanner, isBrakingLightsOn, isBrakingLightsOn, laneChangeAllowed, setNoLaneChangeDistance
addGtu, 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
public static Length initialLocationThresholdDifference
public static Length eventMargin
public static boolean CACHING
public static int CACHED_POSITION
public static int NON_CACHED_POSITION
public AbstractLaneBasedGTU2(String id, GTUType gtuType, OTSSimulatorInterface simulator, OTSRoadNetwork network) throws GTUException
id
- String; the id of the GTUgtuType
- GTUType; the type of GTU, e.g. TruckType, CarType, BusTypesimulator
- OTSSimulatorInterface; to initialize the move method and to get the current timenetwork
- OTSRoadNetwork; the network that the GTU is initially registered inGTUException
- when initial values are not correctpublic void init(LaneBasedStrategicalPlanner strategicalPlanner, Set<DirectedLanePosition> initialLongitudinalPositions, Speed initialSpeed) throws NetworkException, nl.tudelft.simulation.dsol.SimRuntimeException, GTUException, OTSGeometryException
strategicalPlanner
- LaneBasedStrategicalPlanner; the strategical planner (e.g., route determination) to useinitialLongitudinalPositions
- Set<DirectedLanePosition>; the initial positions of the car on one or more
lanes with their directionsinitialSpeed
- Speed; the initial speed of the car on the laneNetworkException
- when the GTU cannot be placed on the given lanenl.tudelft.simulation.dsol.SimRuntimeException
- when the move method cannot be scheduledGTUException
- when initial values are not correctOTSGeometryException
- when the initial path is wrongpublic void setParent(GTU gtu) throws GTUException
setParent
in interface GTU
setParent
in class AbstractGTU
GTUException
public void reinit(Set<DirectedLanePosition> initialLongitudinalPositions) throws NetworkException, nl.tudelft.simulation.dsol.SimRuntimeException, GTUException, OTSGeometryException
initialLongitudinalPositions
- Set<DirectedLanePosition>; initial positionNetworkException
- when the GTU cannot be placed on the given lanenl.tudelft.simulation.dsol.SimRuntimeException
- when the move method cannot be scheduledGTUException
- when initial values are not correctOTSGeometryException
- when the initial path is wrongpublic void changeLaneInstantaneously(LateralDirectionality laneChangeDirection) throws GTUException
changeLaneInstantaneously
in interface LaneBasedGTU
laneChangeDirection
- LateralDirectionality; the direction to change toGTUException
- in case lane change failspublic void initLaneChange(LateralDirectionality laneChangeDirection) throws GTUException
initLaneChange
in interface LaneBasedGTU
laneChangeDirection
- LateralDirectionality; direction of lane changeGTUException
- exceptionprotected void finalizeLaneChange(LateralDirectionality laneChangeDirection) throws GTUException
laneChangeDirection
- LateralDirectionality; direction of lane changeGTUException
- if position or direction could not be obtainedpublic void setFinalizeLaneChangeEvent(nl.tudelft.simulation.dsol.formalisms.eventscheduling.SimEventInterface<nl.tudelft.simulation.dsol.simtime.SimTimeDoubleUnit> event)
setFinalizeLaneChangeEvent
in interface LaneBasedGTU
event
- SimEventInterface<SimTimeDoubleUnit>; eventpublic final GTUDirectionality getDirection(Lane lane) throws GTUException
getDirection
in interface LaneBasedGTU
lane
- Lane; the lane for which we want to know the directionGTUException
- in case the GTU is not registered on the Laneprotected boolean move(nl.tudelft.simulation.language.d3.DirectedPoint fromLocation) throws nl.tudelft.simulation.dsol.SimRuntimeException, GTUException, OperationalPlanException, NetworkException, ParameterException
move
in class AbstractGTU
nl.tudelft.simulation.dsol.SimRuntimeException
GTUException
OperationalPlanException
NetworkException
ParameterException
protected void scheduleEnterEvent() throws GTUException, OperationalPlanException, nl.tudelft.simulation.dsol.SimRuntimeException
GTUException
- exceptionOperationalPlanException
- exceptionnl.tudelft.simulation.dsol.SimRuntimeException
- exceptionprotected void enterCrossSection() throws GTUException, OperationalPlanException, nl.tudelft.simulation.dsol.SimRuntimeException
GTUException
- exceptionOperationalPlanException
- exceptionnl.tudelft.simulation.dsol.SimRuntimeException
- exceptionprotected void scheduleLeaveEvent() throws GTUException, OperationalPlanException, nl.tudelft.simulation.dsol.SimRuntimeException
GTUException
- exceptionOperationalPlanException
- exceptionnl.tudelft.simulation.dsol.SimRuntimeException
- exceptionprotected void leaveCrossSection() throws GTUException, OperationalPlanException, nl.tudelft.simulation.dsol.SimRuntimeException
GTUException
- exceptionOperationalPlanException
- exceptionnl.tudelft.simulation.dsol.SimRuntimeException
- exceptionprotected void scheduleTriggers(Lane lane, GTUDirectionality direction) throws GTUException, OperationalPlanException, nl.tudelft.simulation.dsol.SimRuntimeException
lane
- Lane; lanedirection
- GTUDirectionality; directionGTUException
- exceptionOperationalPlanException
- exceptionnl.tudelft.simulation.dsol.SimRuntimeException
- exceptionpublic final Map<Lane,Length> positions(RelativePosition relativePosition) throws GTUException
positions
in interface LaneBasedGTU
relativePosition
- RelativePosition; the position on the vehicle relative to the reference point.GTUException
- when the vehicle is not on one of the lanes on which it is registered.public final Map<Lane,Length> positions(RelativePosition relativePosition, Time when) throws GTUException
positions
in interface LaneBasedGTU
relativePosition
- RelativePosition; the position on the vehicle relative to the reference point.when
- Time; the future time for which to calculate the positions.GTUException
- when the vehicle is not on one of the lanes on which it is registered.public final Length position(Lane lane, RelativePosition relativePosition) throws GTUException
position
in interface LaneBasedGTU
lane
- Lane; the position on this lane will be returned.relativePosition
- RelativePosition; the position on the vehicle relative to the reference point.GTUException
- when the vehicle is not on the given lane.public Length position(Lane lane, RelativePosition relativePosition, Time when) throws GTUException
position
in interface LaneBasedGTU
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.GTUException
- when the vehicle is not on the given lane.public DirectedLanePosition getReferencePosition() throws GTUException
getReferencePosition
in interface LaneBasedGTU
GTUException
- in case the reference position of the GTU cannot be found on the lanes in its current pathpublic final Map<Lane,Double> fractionalPositions(RelativePosition relativePosition) throws GTUException
fractionalPositions
in interface LaneBasedGTU
relativePosition
- RelativePosition; the position on the vehicle relative to the reference point.GTUException
- when the vehicle is not on one of the lanes on which it is registered.public final Map<Lane,Double> fractionalPositions(RelativePosition relativePosition, Time when) throws GTUException
fractionalPositions
in interface LaneBasedGTU
relativePosition
- RelativePosition; the position on the vehicle relative to the reference point.when
- Time; the future time for which to calculate the positions.GTUException
- when the vehicle is not on one of the lanes on which it is registered.public final double fractionalPosition(Lane lane, RelativePosition relativePosition, Time when) throws GTUException
fractionalPosition
in interface LaneBasedGTU
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.GTUException
- when the vehicle is not on the given lane.public final double fractionalPosition(Lane lane, RelativePosition relativePosition) throws GTUException
fractionalPosition
in interface LaneBasedGTU
lane
- Lane; the position on this lane will be returned.relativePosition
- RelativePosition; the position on the vehicle relative to the reference point.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
- SimEventInterface<SimTimeDoubleUnit>; SimeEvent<SimTimeDoubleUnit> the eventpublic void setVehicleModel(VehicleModel vehicleModel)
vehicleModel
- VehicleModel; vehicle modelpublic VehicleModel getVehicleModel()
getVehicleModel
in interface LaneBasedGTU
public void destroy()
destroy
in interface GTU
destroy
in class AbstractGTU
public final javax.media.j3d.Bounds getBounds()
getBounds
in interface nl.tudelft.simulation.dsol.animation.Locatable
public final LaneBasedStrategicalPlanner getStrategicalPlanner()
getStrategicalPlanner
in interface GTU
getStrategicalPlanner
in interface LaneBasedGTU
getStrategicalPlanner
in class AbstractGTU
public final LaneBasedStrategicalPlanner getStrategicalPlanner(Time time)
getStrategicalPlanner
in interface GTU
getStrategicalPlanner
in interface LaneBasedGTU
getStrategicalPlanner
in class AbstractGTU
public RoadNetwork getNetwork()
getNetwork
in interface LaneBasedGTU
public Speed getDesiredSpeed()
getDesiredSpeed
in interface LaneBasedGTU
public Acceleration getCarFollowingAcceleration()
getCarFollowingAcceleration
in interface LaneBasedGTU
public final TurnIndicatorStatus getTurnIndicatorStatus()
getTurnIndicatorStatus
in interface LaneBasedGTU
public final TurnIndicatorStatus getTurnIndicatorStatus(Time time)
getTurnIndicatorStatus
in interface LaneBasedGTU
time
- Time; time to obtain the turn indicator status atpublic final void setTurnIndicatorStatus(TurnIndicatorStatus turnIndicatorStatus)
setTurnIndicatorStatus
in interface LaneBasedGTU
turnIndicatorStatus
- TurnIndicatorStatus; the new status of the turn indicator.public Length getLateralPosition(Lane lane) throws GTUException
getLateralPosition
in interface LaneBasedGTU
lane
- Lane; lane to consider (most important regarding left/right, not upstream downstream)GTUException
- when the vehicle is not on the given lane.public void setInstantaneousLaneChange(boolean instantaneous)
setInstantaneousLaneChange
in interface LaneBasedGTU
instantaneous
- boolean; whether the GTU perform lane changes instantaneously or notpublic boolean isInstantaneousLaneChange()
isInstantaneousLaneChange
in interface LaneBasedGTU
Copyright © 2014–2019 Delft University of Technology. All rights reserved.