Class LaneDetector
java.lang.Object
org.djutils.event.LocalEventProducer
org.opentrafficsim.core.object.StaticObject
org.opentrafficsim.road.network.object.AbstractLaneBasedObject
org.opentrafficsim.road.network.object.detector.LaneDetector
- All Implemented Interfaces:
Comparable<LaneDetector>,nl.tudelft.simulation.dsol.animation.Locatable,Identifiable,EventProducer,OtsShape,HierarchicallyTyped<DetectorType,,Detector> Detector,LocatedObject,LaneBasedObject
- Direct Known Subclasses:
LoopDetector,ReportingDetector,SinkDetector,TrafficLightDetector.StartEndDetector
public abstract class LaneDetector
extends AbstractLaneBasedObject
implements Comparable<LaneDetector>, LaneBasedObject, Detector
A detector is a lane-based object that can be triggered by a relative position of the GTU (e.g., front, back) when that
relative position passes over the detector location on the lane.
Copyright (c) 2013-2026 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, Wouter Schakel
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final org.djunits.value.vdouble.scalar.LengthDefault elevation of a detector; if the lane is not at elevation 0; this value is probably far off.static final EventTypeThe timed event type for pub/sub indicating the triggering of a Detector on a lane.Fields inherited from interface org.djutils.event.EventProducer
FIRST_POSITION, LAST_POSITIONFields inherited from interface org.opentrafficsim.base.geometry.OtsShape
DEFAULT_POLYGON_SEGMENTS, WORLD_MARGIN_LINE -
Constructor Summary
ConstructorsConstructorDescriptionLaneDetector(String id, Lane lane, org.djunits.value.vdouble.scalar.Length longitudinalPosition, RelativePosition.Type positionType, PolyLine2d line, org.djunits.value.vdouble.scalar.Length elevation, DetectorType detectorType) Create a detector on a lane at a position on that lane.LaneDetector(String id, Lane lane, org.djunits.value.vdouble.scalar.Length longitudinalPosition, RelativePosition.Type positionType, PolyLine2d line, DetectorType detectorType) Create a detector on a lane at a position on that lane at elevationDetector.DEFAULT_DETECTOR_ELEVATION.LaneDetector(String id, Lane lane, org.djunits.value.vdouble.scalar.Length longitudinalPosition, RelativePosition.Type positionType, DetectorType detectorType) Create a new Detector on a lane at a position on that lane at elevationDetector.DEFAULT_DETECTOR_ELEVATIONand default geometry. -
Method Summary
Modifier and TypeMethodDescriptionintbooleanfinal RelativePosition.TypeReturns the relative position type of the vehicle (e.g., FRONT, BACK) that triggers the detector.getType()inthashCode()final booleanisCompatible(GtuType gtuType) Returns whether this Detector can detector GTUs of the given type.toString()final voidtrigger(LaneBasedGtu gtu) Trigger an action on the GTU.protected abstract voidImplementation of the response to a trigger of this detector by a GTU.Methods inherited from class org.opentrafficsim.road.network.object.AbstractLaneBasedObject
getFullId, getLane, getLine, getLongitudinalPosition, initMethods inherited from class org.opentrafficsim.core.object.StaticObject
create, create, getAbsoluteContour, getHeight, getId, getLocation, getRelativeBounds, getRelativeContourMethods inherited from class org.djutils.event.LocalEventProducer
getEventListenerMapMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.djutils.event.EventProducer
addListener, addListener, addListener, addListener, fireEvent, fireEvent, fireEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, getEventListenerMap, getEventTypesWithListeners, getListenerReferences, hasListeners, numberOfListeners, removeAllListeners, removeAllListeners, removeListenerMethods inherited from interface org.opentrafficsim.base.HierarchicallyTyped
isOfTypeMethods inherited from interface org.djutils.base.Identifiable
getIdMethods inherited from interface org.opentrafficsim.road.network.object.LaneBasedObject
getLane, getLength, getLine, getLocation, getLongitudinalPosition, getSimulatorMethods inherited from interface nl.tudelft.simulation.dsol.animation.Locatable
getZMethods inherited from interface org.opentrafficsim.core.object.LocatedObject
getFullId, getHeightMethods inherited from interface org.opentrafficsim.base.geometry.OtsShape
contains, contains, getAbsoluteBounds, getAbsoluteContour, getAbsoluteContour, getDirZ, getRelativeBounds, getRelativeContour, signedDistance, signedDistance
-
Field Details
-
DETECTOR_TRIGGER_EVENT
The timed event type for pub/sub indicating the triggering of a Detector on a lane.
Payload: Object[] {String detectorId, Detector detector, LaneBasedGtu gtu, RelativePosition.TYPE relativePosition} -
DEFAULT_DETECTOR_ELEVATION
public static final org.djunits.value.vdouble.scalar.Length DEFAULT_DETECTOR_ELEVATIONDefault elevation of a detector; if the lane is not at elevation 0; this value is probably far off.
-
-
Constructor Details
-
LaneDetector
public LaneDetector(String id, Lane lane, org.djunits.value.vdouble.scalar.Length longitudinalPosition, RelativePosition.Type positionType, PolyLine2d line, org.djunits.value.vdouble.scalar.Length elevation, DetectorType detectorType) throws NetworkException Create a detector on a lane at a position on that lane.- Parameters:
id- the id of the detector.lane- the lane for which this is a detector.longitudinalPosition- the position (between 0.0 and the length of the Lane) of the detector on the design line of the lane.positionType- RelativePosition.TYPE; the relative position type (e.g., FRONT, BACK) of the vehicle that triggers the detector.line- the line of the object, which provides its location and bounds as wellelevation- elevation of the detectordetectorType- detector type.- Throws:
NetworkException- when the position on the lane is out of bounds
-
LaneDetector
public LaneDetector(String id, Lane lane, org.djunits.value.vdouble.scalar.Length longitudinalPosition, RelativePosition.Type positionType, PolyLine2d line, DetectorType detectorType) throws NetworkException Create a detector on a lane at a position on that lane at elevationDetector.DEFAULT_DETECTOR_ELEVATION.- Parameters:
id- the id of the detector.lane- the lane for which this is a detector.longitudinalPosition- the position (between 0.0 and the length of the Lane) of the detector on the design line of the lane.positionType- RelativePosition.TYPE; the relative position type (e.g., FRONT, BACK) of the vehicle that triggers the detector.line- the contour of the object, which provides its location and bounds as welldetectorType- detector type.- Throws:
NetworkException- when the position on the lane is out of bounds
-
LaneDetector
public LaneDetector(String id, Lane lane, org.djunits.value.vdouble.scalar.Length longitudinalPosition, RelativePosition.Type positionType, DetectorType detectorType) throws NetworkException Create a new Detector on a lane at a position on that lane at elevationDetector.DEFAULT_DETECTOR_ELEVATIONand default geometry.- Parameters:
id- the id of the new Detectorlane- the lane on which the new Detector is positionedlongitudinalPosition- the position (between 0.0 and the length of the Lane) of the detector on the design line of the lanepositionType- RelativePosition.TYPE; the relative position type (e.g., FRONT, BACK) of the vehicle that triggers the detector.detectorType- detector type.- Throws:
NetworkException- when the position on the lane is out of bounds
-
-
Method Details
-
getType
- Specified by:
getTypein interfaceHierarchicallyTyped<DetectorType,Detector>
-
trigger
Trigger an action on the GTU. Normally this is the GTU that triggered the detector. The typical call therefore isdetector.trigger(this);.- Parameters:
gtu- the GTU for which to carry out the trigger action.
-
triggerResponse
Implementation of the response to a trigger of this detector by a GTU.- Parameters:
gtu- the lane based GTU that triggered this detector.
-
getPositionType
Returns the relative position type of the vehicle (e.g., FRONT, BACK) that triggers the detector.- Returns:
- the relative position type of the vehicle (e.g., FRONT, BACK) that triggers the detector.
-
isCompatible
Returns whether this Detector can detector GTUs of the given type.- Parameters:
gtuType- GTU type.- Returns:
- whether this Detector can detector GTUs of the given type.
-
hashCode
public int hashCode() -
equals
-
compareTo
- Specified by:
compareToin interfaceComparable<LaneDetector>
-
toString
- Overrides:
toStringin classAbstractLaneBasedObject
-