Class AbstractHeadway
- java.lang.Object
-
- org.opentrafficsim.road.gtu.lane.perception.headway.AbstractHeadway
-
- All Implemented Interfaces:
Serializable
,Comparable<Headway>
,Identifiable
,PerceivedObject
,Headway
- Direct Known Subclasses:
AbstractHeadwayCopy
,CarFollowingUtil.CarFollowingHeadway
,HeadwayGTUReal
public abstract class AbstractHeadway extends Object implements Headway
Super class for non-delayed and non-erroneous perception. Sub classes should wrap the actual simulation object to obtain information. One exception to this isAbstractHeadwayCopy
(and all it's sub classes), which contains such information directly, and is a super class for delayed and/or erroneous perception.Copyright (c) 2013-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.- Version:
- $Revision$, $LastChangedDate$, by $Author$, initial version 24 mrt. 2017
- Author:
- Alexander Verbraeck, Peter Knoppers, Wouter Schakel
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.opentrafficsim.road.gtu.lane.perception.headway.Headway
Headway.ObjectType
-
-
Constructor Summary
Constructors Modifier Constructor Description AbstractHeadway(Length distance)
Construct a new Headway information object, for an object ahead of us or behind us.AbstractHeadway(Length overlapFront, Length overlap, Length overlapRear)
Construct a new Headway information object, for an object parallel with us.protected
AbstractHeadway(Length distance, Length overlapFront, Length overlap, Length overlapRear)
Construct a new Headway information object, for an object in front, behind, or in parallel with us.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
Length
getDistance()
Retrieve the strongly typed distance to the other object.Length
getOverlap()
Return the (perceived) overlap with the other object.Length
getOverlapFront()
Return the (perceived) front overlap to the other object.Length
getOverlapRear()
Return the (perceived) rear overlap to the other object.int
hashCode()
boolean
isAhead()
boolean
isBehind()
boolean
isParallel()
String
toString()
-
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, getId, getLength, getObjectType, getSpeed
-
-
-
-
Constructor Detail
-
AbstractHeadway
protected AbstractHeadway(Length distance, Length overlapFront, Length overlap, Length overlapRear) throws GTUException
Construct a new Headway information object, for an object in front, behind, or in parallel with us.- Parameters:
distance
- Length; the distance to the other objectoverlapFront
- Length; the front-front distance to the other objectoverlap
- Length; the 'center' overlap with the other objectoverlapRear
- Length; the rear-rear distance to the other object- Throws:
GTUException
- when id is null, or parameters are inconsistent
-
AbstractHeadway
public AbstractHeadway(Length distance) throws GTUException
Construct a new Headway information object, for an object ahead of us or behind us.- Parameters:
distance
- the distance to the other object; if this constructor is used, distance cannot be null.- Throws:
GTUException
- when id is null, or parameters are inconsistent
-
AbstractHeadway
public AbstractHeadway(Length overlapFront, Length overlap, Length overlapRear) throws GTUException
Construct a new Headway information object, for an object parallel with us.- Parameters:
overlapFront
- the front-front distance to the other object; if this constructor is used, this value cannot be null.overlap
- the 'center' overlap with the other object; if this constructor is used, this value cannot be null.overlapRear
- the rear-rear distance to the other object; if this constructor is used, this value cannot be null.- Throws:
GTUException
- when id is null, or parameters are inconsistent
-
-
Method Detail
-
getDistance
public final Length getDistance()
Retrieve the strongly typed distance to the other object.- Specified by:
getDistance
in interfaceHeadway
- Returns:
- Length; the distance to the object, return value null indicates that the other object is parallel to the reference object
-
getOverlapFront
public final Length getOverlapFront()
Return the (perceived) front overlap to the other object. This value should be null if there is no overlap. In the figure for two GTUs below, it is distance c, positive for GTU1, negative for GTU2.---------- | GTU 1 | -----> ---------- --------------- | GTU 2 | -----> --------------- | a | b | c |
- Specified by:
getOverlapFront
in interfaceHeadway
- Returns:
- Length; the (perceived) front overlap to the other object or null if there is no overlap.
-
getOverlapRear
public final Length getOverlapRear()
Return the (perceived) rear overlap to the other object. This value should be null if there is no overlap.In the figure below for two GTUs, it is distance a, positive for GTU1, negative for GTU2.---------- | GTU 1 | -----> ---------- --------------- | GTU 2 | -----> --------------- | a | b | c |
- Specified by:
getOverlapRear
in interfaceHeadway
- Returns:
- Length; the (perceived) rear overlap to the other object or null if there is no overlap.
-
getOverlap
public final Length getOverlap()
Return the (perceived) overlap with the other object. This value should be null if there is no overlap. In the figure below for two GTUs, it is distance b, positive for GTU1 and GTU2.---------- | GTU 1 | -----> ---------- --------------- | GTU 2 | -----> --------------- | a | b | c |
- Specified by:
getOverlap
in interfaceHeadway
- Returns:
- Length, the (perceived) overlap with the other object or null if there is no overlap.
-
isAhead
public final boolean isAhead()
-
isBehind
public final boolean isBehind()
-
isParallel
public final boolean isParallel()
- Specified by:
isParallel
in interfaceHeadway
- Returns:
- whether the other object is parallel the reference object.
-
-