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-2015 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
Constructor and Description |
---|
AbstractLaneBasedGTU(String id,
org.opentrafficsim.core.gtu.GTUType gtuType,
Set<DirectedLanePosition> initialLongitudinalPositions,
org.djunits.value.vdouble.scalar.Speed initialSpeed,
org.opentrafficsim.core.dsol.OTSDEVSSimulatorInterface simulator,
LaneBasedStrategicalPlanner strategicalPlanner,
LanePerception perception,
org.opentrafficsim.core.network.OTSNetwork network)
Construct a Lane Based GTU.
|
Modifier and Type | Method and Description |
---|---|
void |
addTrigger(Lane lane,
nl.tudelft.simulation.dsol.formalisms.eventscheduling.SimEvent<org.opentrafficsim.core.dsol.OTSSimTimeDouble> event)
Add an event to the list of lane triggers scheduled for this GTU.
|
void |
destroy() |
void |
enterLane(Lane lane,
org.djunits.value.vdouble.scalar.Length.Rel position,
org.opentrafficsim.core.gtu.GTUDirectionality gtuDirection)
insert GTU at a certain position.
|
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.Abs 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.Abs 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.
|
LaneBasedBehavioralCharacteristics |
getBehavioralCharacteristics() |
javax.media.j3d.Bounds |
getBounds() |
Map<Lane,org.opentrafficsim.core.gtu.GTUDirectionality> |
getLanes() |
LanePerceptionFull |
getPerception() |
LaneBasedStrategicalPlanner |
getStrategicalPlanner() |
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.Rel |
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.Rel |
position(Lane lane,
org.opentrafficsim.core.gtu.RelativePosition relativePosition,
org.djunits.value.vdouble.scalar.Time.Abs 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.Rel> |
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.Rel> |
positions(org.opentrafficsim.core.gtu.RelativePosition relativePosition,
org.djunits.value.vdouble.scalar.Time.Abs 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.Rel |
projectedPosition(Lane projectionLane,
org.opentrafficsim.core.gtu.RelativePosition relativePosition,
org.djunits.value.vdouble.scalar.Time.Abs when)
Return the longitudinal position that this GTU would have if it were to change to another Lane with a / the current
CrossSectionLink.
|
String |
toString() |
getAcceleration, getAcceleration, getGTUType, getId, getLocation, getMaximumAcceleration, getMaximumDeceleration, getOdometer, getOperationalPlan, getPerceivableContext, getReference, getSimulator, getTacticalPlanner, getTurnIndicatorStatus, getVelocity, getVelocity, interruptMove, isDestroyed, setMaximumAcceleration, setMaximumDeceleration, setTurnIndicatorStatus
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getAcceleration, getAcceleration, getFront, getGTUType, getId, getLength, getLocation, getMaximumAcceleration, getMaximumDeceleration, getMaximumVelocity, getOdometer, getOperationalPlan, getRear, getReference, getRelativePositions, getSimulator, getTacticalPlanner, getTurnIndicatorStatus, getVelocity, getVelocity, getWidth, setTurnIndicatorStatus
public AbstractLaneBasedGTU(String id, org.opentrafficsim.core.gtu.GTUType gtuType, Set<DirectedLanePosition> initialLongitudinalPositions, org.djunits.value.vdouble.scalar.Speed initialSpeed, org.opentrafficsim.core.dsol.OTSDEVSSimulatorInterface simulator, LaneBasedStrategicalPlanner strategicalPlanner, LanePerception perception, org.opentrafficsim.core.network.OTSNetwork network) throws org.opentrafficsim.core.network.NetworkException, nl.tudelft.simulation.dsol.SimRuntimeException, org.opentrafficsim.core.gtu.GTUException, org.opentrafficsim.core.geometry.OTSGeometryException
id
- the id of the GTUgtuType
- the type of GTU, e.g. TruckType, CarType, BusTypeinitialLongitudinalPositions
- the initial positions of the car on one or more lanes with their directionsinitialSpeed
- the initial speed of the car on the lanesimulator
- to initialize the move method and to get the current timestrategicalPlanner
- the strategical planner (e.g., route determination) to useperception
- the lane-based perception model of the GTUnetwork
- the network that the GTU is initially registered inorg.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 gtuFollowingModel is nullorg.opentrafficsim.core.geometry.OTSGeometryException
- when the initial path is wrongpublic final void enterLane(Lane lane, org.djunits.value.vdouble.scalar.Length.Rel 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
velocity, it is moving in this direction.org.opentrafficsim.core.gtu.GTUException
- when positioning the GTU on the lane causes a problempublic final 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 final 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 final Map<Lane,org.opentrafficsim.core.gtu.GTUDirectionality> getLanes()
getLanes
in interface LaneBasedGTU
protected final 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
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
public final Map<Lane,org.djunits.value.vdouble.scalar.Length.Rel> 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.Rel> positions(org.opentrafficsim.core.gtu.RelativePosition relativePosition, org.djunits.value.vdouble.scalar.Time.Abs 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.Rel 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 final org.djunits.value.vdouble.scalar.Length.Rel projectedPosition(Lane projectionLane, org.opentrafficsim.core.gtu.RelativePosition relativePosition, org.djunits.value.vdouble.scalar.Time.Abs 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.Abs; 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 final org.djunits.value.vdouble.scalar.Length.Rel position(Lane lane, org.opentrafficsim.core.gtu.RelativePosition relativePosition, org.djunits.value.vdouble.scalar.Time.Abs 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 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.Abs 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.Abs 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 LanePerceptionFull getPerception()
getPerception
in interface org.opentrafficsim.core.gtu.GTU
getPerception
in interface LaneBasedGTU
getPerception
in class org.opentrafficsim.core.gtu.AbstractGTU
public LaneBasedStrategicalPlanner getStrategicalPlanner()
getStrategicalPlanner
in interface org.opentrafficsim.core.gtu.GTU
getStrategicalPlanner
in interface LaneBasedGTU
getStrategicalPlanner
in class org.opentrafficsim.core.gtu.AbstractGTU
public LaneBasedBehavioralCharacteristics getBehavioralCharacteristics()
getBehavioralCharacteristics
in interface org.opentrafficsim.core.gtu.GTU
getBehavioralCharacteristics
in interface LaneBasedGTU
public void addTrigger(Lane lane, nl.tudelft.simulation.dsol.formalisms.eventscheduling.SimEvent<org.opentrafficsim.core.dsol.OTSSimTimeDouble> event)
addTrigger
in interface LaneBasedGTU
lane
- Lane; the lane on which the event occursevent
- SimeEvent<OTSSimTimeDouble> the eventpublic 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.LocatableInterface
getBounds
in interface org.opentrafficsim.core.gtu.GTU
Copyright © 2014–2016 Delft University of Technology. All rights reserved.