Class AbstractHeadwayGtu
java.lang.Object
org.opentrafficsim.road.gtu.lane.perception.headway.AbstractHeadway
org.opentrafficsim.road.gtu.lane.perception.headway.AbstractHeadwayCopy
org.opentrafficsim.road.gtu.lane.perception.headway.AbstractHeadwayGtu
- All Implemented Interfaces:
Serializable
,Comparable<Headway>
,org.djutils.base.Identifiable
,PerceivedObject
,Headway
,HeadwayGtu
- Direct Known Subclasses:
HeadwayGtuRealCopy
,HeadwayGtuSimple
,HeadwayGtuType
Container for a reference to information about a (lane based) GTU and a headway. The Headway can store information about GTUs
or objects ahead of the reference GTU, behind the reference GTU, or (partially) parallel to the reference GTU. In addition to
the (perceived) headway, several other pieces of information can be stored, such as (perceived) speed, (perceived)
acceleration, (perceived) turn indicators, and (perceived) braking lights.
Special care must be taken in curves when perceiving headway of a GTU or object on an adjacent lane.The question is whether we perceive the parallel or ahead/behind based on a line perpendicular to the front/back of the GTU (rectangular), or perpendicular to the center line of the lane (wedge-shaped in case of a curve). The difficulty of a wedge-shaped situation is that reciprocity might be violated: in case of a clothoid, for instance, it is not sure that the point on the center line when projected from lane 1 to lane 2 is the same as the projection from lane 2 to lane 1. The same holds for shapes with sharp bends. Therefore, algorithms implementing headway should only project the reference point of the reference GTU on the center line of the adjacent lane, and then calculate the forward position and backward position on the adjacent lane based on the reference point. Still, our human perception of what is parallel and what not, is not reflected by fractional positions.
Special care must be taken in curves when perceiving headway of a GTU or object on an adjacent lane.The question is whether we perceive the parallel or ahead/behind based on a line perpendicular to the front/back of the GTU (rectangular), or perpendicular to the center line of the lane (wedge-shaped in case of a curve). The difficulty of a wedge-shaped situation is that reciprocity might be violated: in case of a clothoid, for instance, it is not sure that the point on the center line when projected from lane 1 to lane 2 is the same as the projection from lane 2 to lane 1. The same holds for shapes with sharp bends. Therefore, algorithms implementing headway should only project the reference point of the reference GTU on the center line of the adjacent lane, and then calculate the forward position and backward position on the adjacent lane based on the reference point. Still, our human perception of what is parallel and what not, is not reflected by fractional positions.
Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
- Author:
- Alexander Verbraeck, Peter Knoppers
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.opentrafficsim.road.gtu.lane.perception.headway.Headway
Headway.ObjectType
-
Constructor Summary
ConstructorDescriptionAbstractHeadwayGtu
(String id, GtuType gtuType, org.djunits.value.vdouble.scalar.Length distance, boolean facingSameDirection, org.djunits.value.vdouble.scalar.Length length, org.djunits.value.vdouble.scalar.Length width, org.djunits.value.vdouble.scalar.Speed speed, org.djunits.value.vdouble.scalar.Acceleration acceleration, org.djunits.value.vdouble.scalar.Speed desiredSpeed, GtuStatus... gtuStatus) Construct a new Headway information object, for a moving GTU ahead of us or behind us.AbstractHeadwayGtu
(String id, GtuType gtuType, org.djunits.value.vdouble.scalar.Length distance, boolean facingSameDirection, org.djunits.value.vdouble.scalar.Length length, org.djunits.value.vdouble.scalar.Length width, org.djunits.value.vdouble.scalar.Speed desiredSpeed, GtuStatus... gtuStatus) Construct a new Headway information object, for a non-moving GTU ahead of us or behind us.AbstractHeadwayGtu
(String id, GtuType gtuType, org.djunits.value.vdouble.scalar.Length overlapFront, org.djunits.value.vdouble.scalar.Length overlap, org.djunits.value.vdouble.scalar.Length overlapRear, boolean facingSameDirection, org.djunits.value.vdouble.scalar.Length length, org.djunits.value.vdouble.scalar.Length width, org.djunits.value.vdouble.scalar.Speed speed, org.djunits.value.vdouble.scalar.Acceleration acceleration, org.djunits.value.vdouble.scalar.Speed desiredSpeed, GtuStatus... gtuStatus) Construct a new Headway information object, for a moving GTU parallel with us.AbstractHeadwayGtu
(String id, GtuType gtuType, org.djunits.value.vdouble.scalar.Length overlapFront, org.djunits.value.vdouble.scalar.Length overlap, org.djunits.value.vdouble.scalar.Length overlapRear, boolean facingSameDirection, org.djunits.value.vdouble.scalar.Length length, org.djunits.value.vdouble.scalar.Length width, org.djunits.value.vdouble.scalar.Speed desiredSpeed, GtuStatus... gtuStatus) Construct a new Headway information object, for a non-moving GTU parallel with us. -
Method Summary
Modifier and TypeMethodDescriptionfinal org.djunits.value.vdouble.scalar.Speed
Returns the perceived desired speed of the neighbor.protected final GtuStatus[]
For subclasses that create a copy of themselves.static final GtuStatus[]
getGtuStatuses
(LaneBasedGtu gtu, org.djunits.value.vdouble.scalar.Time when) Collects GTU statuses from a gtu.final GtuType
static SpeedLimitInfo
Creates speed limit info for given GTU.org.djunits.value.vdouble.scalar.Length
getWidth()
Returns the width of the GTU.final boolean
final boolean
final boolean
final boolean
final boolean
final boolean
toString()
Methods inherited from class org.opentrafficsim.road.gtu.lane.perception.headway.AbstractHeadwayCopy
equals, getAcceleration, getId, getLength, getObjectType, getSpeed, hashCode
Methods inherited from class org.opentrafficsim.road.gtu.lane.perception.headway.AbstractHeadway
getDistance, getOverlap, getOverlapFront, getOverlapRear, isAhead, isBehind, isParallel
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.opentrafficsim.road.gtu.lane.perception.headway.Headway
compareTo, getAcceleration, getDistance, getId, getLength, getObjectType, getOverlap, getOverlapFront, getOverlapRear, getSpeed, isAhead, isBehind, isParallel
Methods inherited from interface org.opentrafficsim.road.gtu.lane.perception.headway.HeadwayGtu
getCarFollowingModel, getParameters, getRoute, getSpeedLimitInfo, moved
-
Constructor Details
-
AbstractHeadwayGtu
public AbstractHeadwayGtu(String id, GtuType gtuType, org.djunits.value.vdouble.scalar.Length distance, boolean facingSameDirection, org.djunits.value.vdouble.scalar.Length length, org.djunits.value.vdouble.scalar.Length width, org.djunits.value.vdouble.scalar.Speed speed, org.djunits.value.vdouble.scalar.Acceleration acceleration, org.djunits.value.vdouble.scalar.Speed desiredSpeed, GtuStatus... gtuStatus) throws GtuException Construct a new Headway information object, for a moving GTU ahead of us or behind us.- Parameters:
id
- String; the id of the GTU for comparison purposes, can not be null.gtuType
- GtuType; the perceived GTU Type, or null if unknown.distance
- the distance to the other object; if this constructor is used, distance cannot be null.facingSameDirection
- boolean; whether the GTU is facing the same direction.length
- the (perceived) length of the other object; can not be null.width
- the (perceived) width of the other object; can not be null.speed
- the (perceived) speed of the other object; can be null if unknown.acceleration
- the (perceived) acceleration of the other object; can be null if unknown.desiredSpeed
- Speed; desired speedgtuStatus
- GtuStatus...; the observable characteristics of the GTU.- Throws:
GtuException
- when id is null, objectType is null, or parameters are inconsistent
-
AbstractHeadwayGtu
public AbstractHeadwayGtu(String id, GtuType gtuType, org.djunits.value.vdouble.scalar.Length distance, boolean facingSameDirection, org.djunits.value.vdouble.scalar.Length length, org.djunits.value.vdouble.scalar.Length width, org.djunits.value.vdouble.scalar.Speed desiredSpeed, GtuStatus... gtuStatus) throws GtuException Construct a new Headway information object, for a non-moving GTU ahead of us or behind us.- Parameters:
id
- String; the id of the GTU for comparison purposes, can not be null.gtuType
- GtuType; the perceived GTU Type, or null if unknown.distance
- Length; the distance to the other Gtu; if this constructor is used, distance cannot be null.facingSameDirection
- boolean; whether the GTU is facing the same direction.length
- the (perceived) length of the other object; can not be null.width
- the (perceived) width of the other object; can not be null.desiredSpeed
- Speed; desired speedgtuStatus
- GtuStatus...; the observable characteristics of the GTU.- Throws:
GtuException
- when id is null, or parameters are inconsistent
-
AbstractHeadwayGtu
public AbstractHeadwayGtu(String id, GtuType gtuType, org.djunits.value.vdouble.scalar.Length overlapFront, org.djunits.value.vdouble.scalar.Length overlap, org.djunits.value.vdouble.scalar.Length overlapRear, boolean facingSameDirection, org.djunits.value.vdouble.scalar.Length length, org.djunits.value.vdouble.scalar.Length width, org.djunits.value.vdouble.scalar.Speed speed, org.djunits.value.vdouble.scalar.Acceleration acceleration, org.djunits.value.vdouble.scalar.Speed desiredSpeed, GtuStatus... gtuStatus) throws GtuException Construct a new Headway information object, for a moving GTU parallel with us.- Parameters:
id
- String; the id of the GTU for comparison purposes, can not be null.gtuType
- GtuType; the perceived GTU Type, or null if unknown.overlapFront
- the front-front distance to the other Gtu; if this constructor is used, this value cannot be null.overlap
- the 'center' overlap with the other Gtu; if this constructor is used, this value cannot be null.overlapRear
- the rear-rear distance to the other Gtu; if this constructor is used, this value cannot be null.facingSameDirection
- boolean; whether the GTU is facing the same direction.length
- the (perceived) length of the other object; can not be null.width
- the (perceived) width of the other object; can not be null.speed
- the (perceived) speed of the other Gtu; can be null if unknown.acceleration
- the (perceived) acceleration of the other Gtu; can be null if unknown.desiredSpeed
- Speed; desired speedgtuStatus
- GtuStatus...; the observable characteristics of the GTU.- Throws:
GtuException
- when id is null, or parameters are inconsistent
-
AbstractHeadwayGtu
public AbstractHeadwayGtu(String id, GtuType gtuType, org.djunits.value.vdouble.scalar.Length overlapFront, org.djunits.value.vdouble.scalar.Length overlap, org.djunits.value.vdouble.scalar.Length overlapRear, boolean facingSameDirection, org.djunits.value.vdouble.scalar.Length length, org.djunits.value.vdouble.scalar.Length width, org.djunits.value.vdouble.scalar.Speed desiredSpeed, GtuStatus... gtuStatus) throws GtuException Construct a new Headway information object, for a non-moving GTU parallel with us.- Parameters:
id
- String; the id of the GTU for comparison purposes, can not be null.gtuType
- GtuType; the perceived GTU Type, or null if unknown.overlapFront
- the front-front distance to the other Gtu; if this constructor is used, this value cannot be null.overlap
- the 'center' overlap with the other Gtu; if this constructor is used, this value cannot be null.overlapRear
- the rear-rear distance to the other Gtu; if this constructor is used, this value cannot be null.facingSameDirection
- boolean; whether the GTU is facing the same direction.length
- the (perceived) length of the other object; can not be null.width
- the (perceived) width of the other object; can not be null.desiredSpeed
- Speed; desired speedgtuStatus
- GtuStatus...; the observable characteristics of the GTU.- Throws:
GtuException
- when id is null, or parameters are inconsistent
-
-
Method Details
-
getGtuType
- Specified by:
getGtuType
in interfaceHeadwayGtu
- Returns:
- gtuType
-
getDesiredSpeed
public final org.djunits.value.vdouble.scalar.Speed getDesiredSpeed()Returns the perceived desired speed of the neighbor.- Specified by:
getDesiredSpeed
in interfaceHeadwayGtu
- Returns:
- Speed; perceived desired speed of the neighbor
-
isFacingSameDirection
public final boolean isFacingSameDirection()- Specified by:
isFacingSameDirection
in interfaceHeadwayGtu
- Returns:
- facingSameDirection
-
isBrakingLightsOn
public final boolean isBrakingLightsOn()- Specified by:
isBrakingLightsOn
in interfaceHeadwayGtu
- Returns:
- were the braking lights on?
-
isLeftTurnIndicatorOn
public final boolean isLeftTurnIndicatorOn()- Specified by:
isLeftTurnIndicatorOn
in interfaceHeadwayGtu
- Returns:
- was the left turn indicator on?
-
isRightTurnIndicatorOn
public final boolean isRightTurnIndicatorOn()- Specified by:
isRightTurnIndicatorOn
in interfaceHeadwayGtu
- Returns:
- was the right turn indicator on?
-
isEmergencyLightsOn
public final boolean isEmergencyLightsOn()- Specified by:
isEmergencyLightsOn
in interfaceHeadwayGtu
- Returns:
- were the emergency lights on?
-
isHonking
public final boolean isHonking()- Specified by:
isHonking
in interfaceHeadwayGtu
- Returns:
- was the vehicle honking or ringing its bell when being observed for the headway?
-
getGtuStatus
For subclasses that create a copy of themselves.- Returns:
- set of gtu status
-
getGtuStatuses
public static final GtuStatus[] getGtuStatuses(LaneBasedGtu gtu, org.djunits.value.vdouble.scalar.Time when) Collects GTU statuses from a gtu.- Parameters:
gtu
- LaneBasedGtu; gtuwhen
- Time; time- Returns:
- GTU statuses
-
getSpeedLimitInfo
Creates speed limit info for given GTU.- Parameters:
gtu
- LaneBasedGtu; gtu to the the speed limit info for- Returns:
- speed limit info for given GTU
-
getWidth
public org.djunits.value.vdouble.scalar.Length getWidth()Returns the width of the GTU.- Specified by:
getWidth
in interfaceHeadwayGtu
- Returns:
- Length; width of the GTU
-
toString
- Overrides:
toString
in classAbstractHeadway
-