ID - The type of ID, e.g., String or Integerpublic abstract class AbstractLaneBasedGTU<ID> extends AbstractGTU<ID> implements LaneBasedGTU<ID>
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(ID id,
GTUType<?> gtuType,
GTUFollowingModel gtuFollowingModel,
LaneChangeModel laneChangeModel,
Map<Lane<?,?>,DoubleScalar.Rel<LengthUnit>> initialLongitudinalPositions,
DoubleScalar.Abs<SpeedUnit> initialSpeed,
LaneBasedRouteNavigator routeNavigator,
OTSDEVSSimulatorInterface simulator)
Construct a Lane Based GTU.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addFrontToSubsequentLane(Lane<?,?> lane)
Register the lane with a GTU, at the start of the lane.
|
void |
addLane(Lane<?,?> lane,
DoubleScalar.Rel<LengthUnit> position)
insert GTU at a certain position.
|
DoubleScalar.Rel<TimeUnit> |
deltaTimeForDistance(DoubleScalar.Rel<LengthUnit> distance)
Determine the time since last evaluation when this GTU has covered the specified distance from the position of the last
evaluation time.
|
void |
destroy()
destroy the vehicle from the simulation and animation.
|
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,
DoubleScalar.Abs<TimeUnit> 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,
DoubleScalar.Abs<TimeUnit> 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.
|
DoubleScalar.Abs<AccelerationUnit> |
getAcceleration() |
DoubleScalar.Abs<AccelerationUnit> |
getAcceleration(DoubleScalar.Abs<TimeUnit> when) |
javax.media.j3d.Bounds |
getBounds() |
GTUFollowingModel |
getGTUFollowingModel()
Retrieve the GTUFollowingModel of this GTU.
|
LaneChangeUrgeGTUColorer.LaneChangeDistanceAndDirection |
getLaneChangeDistanceAndDirection()
Return the distance available for the next needed lane change and the lateral direction of that lane change.
|
List<Lane<?,?>> |
getLanes() |
DoubleScalar.Abs<TimeUnit> |
getLastEvaluationTime() |
DoubleScalar.Abs<SpeedUnit> |
getLateralVelocity() |
DirectedPoint |
getLocation() |
DoubleScalar.Abs<SpeedUnit> |
getLongitudinalVelocity()
v(t) = v0 + (t - t0) * a.
|
DoubleScalar.Abs<SpeedUnit> |
getLongitudinalVelocity(DoubleScalar.Abs<TimeUnit> when)
Return the speed of this GTU at the specified time.
|
DoubleScalar.Abs<TimeUnit> |
getNextEvaluationTime() |
DoubleScalar.Abs<LengthUnit> |
getOdometer()
Retrieve the odometer value.
|
DoubleScalar.Abs<SpeedUnit> |
getVelocity() |
HeadwayGTU |
headway(DoubleScalar.Rel<LengthUnit> maxDistance)
Determine which GTU in front of this GTU, or behind this GTU.
|
HeadwayGTU |
headway(Lane<?,?> lane,
DoubleScalar.Rel<LengthUnit> maxDistance)
Determine by what distance the front of this GTU is behind the rear an other GTU, or the rear of this GTU is ahead of the
front of an other GTU.
|
protected void |
move()
Move this GTU to it's current location, then compute (and commit to) the next movement step.
|
Set<LaneBasedGTU<?>> |
parallel(Lane<?,?> lane,
DoubleScalar.Abs<TimeUnit> when)
Determine which GTUs are parallel with us on another lane, based on fractional positions.
|
Set<LaneBasedGTU<?>> |
parallel(LateralDirectionality lateralDirection,
DoubleScalar.Abs<TimeUnit> when)
Determine which GTUs are parallel with us in a certain lateral direction, based on fractional positions.
|
DoubleScalar.Rel<LengthUnit> |
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.
|
DoubleScalar.Rel<LengthUnit> |
position(Lane<?,?> lane,
RelativePosition relativePosition,
DoubleScalar.Abs<TimeUnit> when)
Return the longitudinal position of a point relative to this GTU, relative to the center line of the Lane.
|
Map<Lane<?,?>,DoubleScalar.Rel<LengthUnit>> |
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<?,?>,DoubleScalar.Rel<LengthUnit>> |
positions(RelativePosition relativePosition,
DoubleScalar.Abs<TimeUnit> 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.
|
DoubleScalar.Rel<LengthUnit> |
projectedPosition(Lane<?,?> projectionLane,
RelativePosition relativePosition,
DoubleScalar.Abs<TimeUnit> when)
Return the longitudinal position that this GTU would have if it were to change to another Lane with a/the current
CrossSectionLink.
|
void |
removeLane(Lane<?,?> lane)
Unregister the GTU from a lane.
|
DoubleScalar.Abs<TimeUnit> |
timeAtDistance(DoubleScalar.Rel<LengthUnit> distance)
Determine the time when this GTU will have covered the specified distance from the position of the last evaluation time.
|
String |
toString(Lane<?,?> lane,
DoubleScalar.Abs<TimeUnit> when)
Description of Car at specified time.
|
getGTUType, getId, getReference, getRoute, setRouteclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetFront, getGTUType, getId, getLength, getMaximumVelocity, getRear, getReference, getRelativePositions, getSimulator, getWidthpublic AbstractLaneBasedGTU(ID id, GTUType<?> gtuType, GTUFollowingModel gtuFollowingModel, LaneChangeModel laneChangeModel, Map<Lane<?,?>,DoubleScalar.Rel<LengthUnit>> initialLongitudinalPositions, DoubleScalar.Abs<SpeedUnit> initialSpeed, LaneBasedRouteNavigator routeNavigator, OTSDEVSSimulatorInterface simulator) throws RemoteException, NetworkException, SimRuntimeException, GTUException
id - the id of the GTU, could be String or IntegergtuType - the type of GTU, e.g. TruckType, CarType, BusTypegtuFollowingModel - the following model, including a reference to the simulator.laneChangeModel - LaneChangeModel; the lane change modelinitialLongitudinalPositions - the initial positions of the car on one or more lanesinitialSpeed - the initial speed of the car on the lanerouteNavigator - Route; the route that the GTU will takesimulator - to initialize the move method and to get the current timeRemoteException - when the simulator cannot be reachedNetworkException - when the GTU cannot be placed on the given laneSimRuntimeException - when the move method cannot be scheduledGTUException - when gtuFollowingModel is nullpublic final DoubleScalar.Abs<SpeedUnit> getLongitudinalVelocity(DoubleScalar.Abs<TimeUnit> when)
getLongitudinalVelocity in interface LaneBasedGTU<ID>when - time for which the speed must be returnedpublic final DoubleScalar.Abs<SpeedUnit> getLongitudinalVelocity() throws RemoteException
getLongitudinalVelocity in interface LaneBasedGTU<ID>RemoteException - in case of problems getting the simulation time.public final DoubleScalar.Abs<SpeedUnit> getVelocity() throws RemoteException
getVelocity in interface GTU<ID>RemoteException - on communications failurepublic final DoubleScalar.Abs<TimeUnit> getLastEvaluationTime()
getLastEvaluationTime in interface LaneBasedGTU<ID>public final DoubleScalar.Abs<TimeUnit> getNextEvaluationTime()
getNextEvaluationTime in interface LaneBasedGTU<ID>public final DoubleScalar.Abs<AccelerationUnit> getAcceleration(DoubleScalar.Abs<TimeUnit> when)
getAcceleration in interface LaneBasedGTU<ID>when - time for which the speed must be returnedpublic final DoubleScalar.Abs<AccelerationUnit> getAcceleration() throws RemoteException
getAcceleration in interface GTU<ID>getAcceleration in interface LaneBasedGTU<ID>RemoteException - in case of problems getting the simulation time.public final DoubleScalar.Abs<LengthUnit> getOdometer() throws RemoteException
getOdometer in interface GTU<ID>RemoteException - on communications failurepublic final DoubleScalar.Abs<SpeedUnit> getLateralVelocity()
getLateralVelocity in interface LaneBasedGTU<ID>public final void addFrontToSubsequentLane(Lane<?,?> lane) throws RemoteException, NetworkException
addFrontToSubsequentLane in interface LaneBasedGTU<ID>lane - the lane to add to the list of lanes on which the GTU is registered.RemoteException - on communications failureNetworkException - on network inconsistencypublic final void addLane(Lane<?,?> lane, DoubleScalar.Rel<LengthUnit> position) throws NetworkException
addLane in interface LaneBasedGTU<ID>lane - the lane to add to the list of lanes on which the GTU is registered.position - the position on the lane.NetworkException - on network inconsistencypublic final void removeLane(Lane<?,?> lane)
removeLane in interface LaneBasedGTU<ID>lane - the lane to remove from the list of lanes on which the GTU is registered.protected final void move()
throws RemoteException,
NetworkException,
GTUException,
SimRuntimeException,
ValueException
RemoteException - on communications failureNetworkException - on network inconsistencyGTUException - when GTU has not lane change modelSimRuntimeException - on not being able to reschedule this move() method.ValueException - cannot happenpublic final Map<Lane<?,?>,DoubleScalar.Rel<LengthUnit>> positions(RelativePosition relativePosition) throws NetworkException, RemoteException
positions in interface LaneBasedGTU<ID>relativePosition - the position on the vehicle relative to the reference point.NetworkException - when the vehicle is not on one of the lanes on which it is registered.RemoteException - when simulator time cannot be retrieved.public final Map<Lane<?,?>,DoubleScalar.Rel<LengthUnit>> positions(RelativePosition relativePosition, DoubleScalar.Abs<TimeUnit> when) throws NetworkException, RemoteException
positions in interface LaneBasedGTU<ID>relativePosition - the position on the vehicle relative to the reference point.when - the future time for which to calculate the positions.NetworkException - when the vehicle is not on one of the lanes on which it is registered.RemoteException - on communications failurepublic final DoubleScalar.Rel<LengthUnit> position(Lane<?,?> lane, RelativePosition relativePosition) throws NetworkException, RemoteException
position in interface LaneBasedGTU<ID>lane - the position on this lane will be returned.relativePosition - the position on the vehicle relative to the reference point.NetworkException - when the vehicle is not on the given lane.RemoteException - when simulator time cannot be retrieved.public final DoubleScalar.Rel<LengthUnit> projectedPosition(Lane<?,?> projectionLane, RelativePosition relativePosition, DoubleScalar.Abs<TimeUnit> when) throws NetworkException, RemoteException
projectedPosition in interface LaneBasedGTU<ID>projectionLane - Lane; the lane onto which the position of this GTU must be projectedrelativePosition - RelativePosition; the point on this GTU that must be projectedwhen - DoubleScalar.Abs<TimeUnit>; the time for which to project the position of this GTUNetworkException - when projectionLane it not in any of the CrossSectionLink that the GTU is onRemoteException - on communications failurepublic final DoubleScalar.Rel<LengthUnit> position(Lane<?,?> lane, RelativePosition relativePosition, DoubleScalar.Abs<TimeUnit> when) throws NetworkException, RemoteException
position in interface LaneBasedGTU<ID>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.NetworkException - when the vehicle is not on the given lane.RemoteException - on communications failurepublic final Map<Lane<?,?>,Double> fractionalPositions(RelativePosition relativePosition) throws NetworkException, RemoteException
fractionalPositions in interface LaneBasedGTU<ID>relativePosition - the position on the vehicle relative to the reference point.NetworkException - when the vehicle is not on one of the lanes on which it is registered.RemoteException - when simulator time cannot be retrieved.public final Map<Lane<?,?>,Double> fractionalPositions(RelativePosition relativePosition, DoubleScalar.Abs<TimeUnit> when) throws NetworkException, RemoteException
fractionalPositions in interface LaneBasedGTU<ID>relativePosition - the position on the vehicle relative to the reference point.when - the future time for which to calculate the positions.NetworkException - when the vehicle is not on one of the lanes on which it is registered.RemoteException - on communications failurepublic final double fractionalPosition(Lane<?,?> lane, RelativePosition relativePosition, DoubleScalar.Abs<TimeUnit> when) throws NetworkException, RemoteException
fractionalPosition in interface LaneBasedGTU<ID>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.NetworkException - when the vehicle is not on the given lane.RemoteException - on communications failurepublic final double fractionalPosition(Lane<?,?> lane, RelativePosition relativePosition) throws NetworkException, RemoteException
fractionalPosition in interface LaneBasedGTU<ID>lane - the position on this lane will be returned.relativePosition - the position on the vehicle relative to the reference point.NetworkException - when the vehicle is not on the given lane.RemoteException - when simulator time cannot be retrieved.public final HeadwayGTU headway(DoubleScalar.Rel<LengthUnit> maxDistance) throws RemoteException, NetworkException
headway in interface LaneBasedGTU<ID>maxDistance - the maximum distance to look for the nearest GTU; positive values search forwards; negative values
search backwardsRemoteException - when simulator time cannot be retrieved.NetworkException - when there is an error with the next lanes in the network.public final HeadwayGTU headway(Lane<?,?> lane, DoubleScalar.Rel<LengthUnit> maxDistance) throws RemoteException, NetworkException
new DoubleScalar.Rel<LengthUnit>(Double.MAX_VALUE, LengthUnit.METER) is returned. The search will
extend into successive lanes if the maxDistance is larger than the length of the lane.headway in interface LaneBasedGTU<ID>lane - the lane to look for another GTUmaxDistance - the maximum distance to look for; if positive, the search is forwards; if negative, the search is
backwardsRemoteException - when simulator time cannot be retrievedNetworkException - when the vehicle's route is inconclusive or vehicles are not registered correctly on their lanespublic final Set<LaneBasedGTU<?>> parallel(Lane<?,?> lane, DoubleScalar.Abs<TimeUnit> when) throws RemoteException, NetworkException
parallel in interface LaneBasedGTU<ID>lane - the lane to look for parallel (partial or full overlapping) GTUs.when - the future time for which to calculate the headwayRemoteException - when simulator time cannot be retrieved.NetworkException - when the vehicle's route is inconclusive, when vehicles are not registered correctly on their
lanes, or when the given lane is not parallel to one of the lanes where we are registered.public final Set<LaneBasedGTU<?>> parallel(LateralDirectionality lateralDirection, DoubleScalar.Abs<TimeUnit> when) throws RemoteException, NetworkException
parallel in interface LaneBasedGTU<ID>lateralDirection - the direction of the adjacent lane(s) to look for parallel (partial or full overlapping) GTUs.when - the future time for which to calculate the headwayRemoteException - when simulator time cannot be retrieved.NetworkException - when the vehicle's route is inconclusive, when vehicles are not registered correctly on their
lanes, or when there are no lanes parallel to one of the lanes where we are registered in the given
direction.public final DoubleScalar.Abs<TimeUnit> timeAtDistance(DoubleScalar.Rel<LengthUnit> distance)
timeAtDistance in interface LaneBasedGTU<ID>distance - DoubleScalar.Rel<LengthUnit>; the distancepublic final DoubleScalar.Rel<TimeUnit> deltaTimeForDistance(DoubleScalar.Rel<LengthUnit> distance)
deltaTimeForDistance in interface LaneBasedGTU<ID>distance - DoubleScalar.Rel<LengthUnit>; the distancepublic void destroy()
public final GTUFollowingModel getGTUFollowingModel()
getGTUFollowingModel in interface LaneBasedGTU<ID>public final DirectedPoint getLocation() throws RemoteException
getLocation in interface LocatableInterfaceRemoteExceptionpublic final javax.media.j3d.Bounds getBounds()
throws RemoteException
getBounds in interface LocatableInterfaceRemoteExceptionpublic LaneChangeUrgeGTUColorer.LaneChangeDistanceAndDirection getLaneChangeDistanceAndDirection()
LaneBasedGTUgetLaneChangeDistanceAndDirection in interface LaneBasedGTU<ID>public final String toString(Lane<?,?> lane, DoubleScalar.Abs<TimeUnit> when)
lane - the position on this lane will be returned.when - DoubleScalarAbs<TimeUnit>; the timeCopyright © 2014–2015 Delft University of Technology. All rights reserved.