All Implemented Interfaces:
Comparable<LaneDetector>, nl.tudelft.simulation.dsol.animation.Locatable, Identifiable, EventProducer, OtsShape, HierarchicallyTyped<DetectorType,Detector>, Detector, LocatedObject, LaneBasedObject

public class LoopDetector extends LaneDetector
Detector, measuring a dynamic set of measurements typical for single- or dual-loop detectors. A subsidiary detector is placed at a position downstream based on the detector length, that triggers when the rear leaves the detector.

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 Details

  • Constructor Details

    • LoopDetector

      public LoopDetector(String id, Lane lane, org.djunits.value.vdouble.scalar.Length longitudinalPosition, DetectorType detectorType) throws NetworkException
      Constructor for regular Dutch dual-loop detectors measuring flow and mean speed aggregated over 60s.
      Parameters:
      id - detector id
      lane - lane
      longitudinalPosition - position
      detectorType - detector type.
      Throws:
      NetworkException - on network exception
    • LoopDetector

      public LoopDetector(String id, LanePosition position, org.djunits.value.vdouble.scalar.Length length, DetectorType detectorType, org.djunits.value.vdouble.scalar.Duration firstAggregation, org.djunits.value.vdouble.scalar.Duration aggregation, LoopDetector.LoopDetectorMeasurement<?,?>... measurements) throws NetworkException
      Constructor.
      Parameters:
      id - detector id
      position - lane position
      length - length
      firstAggregation - time of first aggregation
      aggregation - aggregation period
      measurements - measurements to obtain
      detectorType - detector type.
      Throws:
      NetworkException - on network exception
      IllegalArgumentException - when aggregation times are negative
  • Method Details

    • specificDataFor

      public void specificDataFor(GtuType... gtuTypes)
      Store data specific to GTU type.
      Parameters:
      gtuTypes - GTU type
    • getLength

      public org.djunits.value.vdouble.scalar.Length getLength()
      Description copied from interface: LaneBasedObject
      Returns the length of the object. The default value is zero.
      Returns:
      length of the object
    • triggerResponse

      protected void triggerResponse(LaneBasedGtu gtu)
      Description copied from class: LaneDetector
      Implementation of the response to a trigger of this detector by a GTU.
      Specified by:
      triggerResponse in class LaneDetector
      Parameters:
      gtu - the lane based GTU that triggered this detector.
    • hasLastValue

      public boolean hasLastValue()
      Returns whether the detector has aggregated data available.
      Returns:
      whether the detector has aggregated data available
    • getLastFlow

      public org.djunits.value.vdouble.scalar.Frequency getLastFlow()
      Returns the last flow.
      Returns:
      last flow
    • getLastValue

      public <A> A getLastValue(LoopDetector.LoopDetectorMeasurement<?,A> detectorMeasurement)
      Returns the last value of the detector measurement.
      Type Parameters:
      A - aggregate value type of the detector measurement
      Parameters:
      detectorMeasurement - detector measurement
      Returns:
      last value of the detector measurement
    • getPeriodicData

      public <T> List<T> getPeriodicData(LoopDetector.LoopDetectorMeasurement<?,T> measurement)
      Return aggregated data for the measurement for all GTU types.
      Type Parameters:
      T - measurement value type, use null to obtain flow data which is measured by default
      Parameters:
      measurement - measurement
      Returns:
      aggregated data for the measurement for all GTU types
      Throws:
      IllegalArgumentException - when the measurement is not periodic
    • getPeriodicData

      public <T> List<T> getPeriodicData(LoopDetector.LoopDetectorMeasurement<?,T> measurement, GtuType gtuType)
      Return aggregated data for the measurement and GTU type.
      Type Parameters:
      T - measurement value type, use null to obtain flow data which is measured by default
      Parameters:
      measurement - measurement
      gtuType - GTU type
      Returns:
      aggregated data for the measurement and GTU type
      Throws:
      IllegalArgumentException - when there is no data for the GTU type, or the measurement is not periodic
    • getNonPeriodicData

      public <T> T getNonPeriodicData(LoopDetector.LoopDetectorMeasurement<?,T> measurement)
      Return non-periodic data for the measurement for all GTU types.
      Type Parameters:
      T - measurement value type
      Parameters:
      measurement - measurement
      Returns:
      non-periodic data for the measurement for all GTU types
      Throws:
      IllegalArgumentException - when the measurement is not non-periodic
    • getNonPeriodicData

      public <T> T getNonPeriodicData(LoopDetector.LoopDetectorMeasurement<?,T> measurement, GtuType gtuType)
      Return non-periodic data for the measurement and GTU type.
      Type Parameters:
      T - measurement value type
      Parameters:
      measurement - measurement
      gtuType - GTU type
      Returns:
      non-periodic data for the measurement and GTU type
      Throws:
      IllegalArgumentException - when there is no data for the GTU type, or the measurement is not non-periodic
    • asTablePositions

      public static Table asTablePositions(RoadNetwork network)
      Returns a Table with loop detector positions.
      Parameters:
      network - network from which all detectors are found.
      Returns:
      with loop detector positions.
    • asTablePeriodicData

      public static Table asTablePeriodicData(RoadNetwork network, GtuType... gtuTypes)
      Returns a Table with all periodic data, such as flow and speed per minute.
      Parameters:
      network - network from which all detectors are found.
      gtuTypes - GTU types to include. When left empty, data for all is exported without GTU type column. To include data for all GTU types among data for specific GTU types, include null value.
      Returns:
      with all periodic data, such as flow and speed per minute.
    • asTableNonPeriodicData

      public static Table asTableNonPeriodicData(RoadNetwork network, GtuType... gtuTypes)
      Returns a Table with all non-periodic data, such as vehicle passage times or platoon counts.
      Parameters:
      network - network from which all detectors are found.
      gtuTypes - GTU types to include. When left empty, data for all is exported without GTU type column. To include data for all GTU types among data for specific GTU types, include null value.
      Returns:
      with all non-periodic data, such as vehicle passage times or platoon counts.