Class AbstractSensor

    • Constructor Detail

      • AbstractSensor

        public AbstractSensor​(String id,
                              Lane lane,
                              Length longitudinalPosition,
                              RelativePosition.TYPE positionType,
                              OTSSimulatorInterface simulator,
                              OTSLine3D geometry,
                              Length elevation,
                              Compatible detectedGTUTypes)
                       throws NetworkException
        Create a sensor on a lane at a position on that lane.
        Parameters:
        id - String; the id of the sensor.
        lane - Lane; the lane for which this is a sensor.
        longitudinalPosition - Length; the position (between 0.0 and the length of the Lane) of the sensor on the design line of the lane.
        positionType - RelativePosition.TYPE; the relative position type (e.g., FRONT, BACK) of the vehicle that triggers the sensor.
        simulator - OTSSimulatorInterface; the simulator (needed to generate the animation).
        geometry - OTSLine3D; the geometry of the object, which provides its location and bounds as well
        elevation - Length; elevation of the sensor
        detectedGTUTypes - Compatible; The GTU types will trigger this sensor
        Throws:
        NetworkException - when the position on the lane is out of bounds
      • AbstractSensor

        public AbstractSensor​(String id,
                              Lane lane,
                              Length longitudinalPosition,
                              RelativePosition.TYPE positionType,
                              OTSSimulatorInterface simulator,
                              OTSLine3D geometry,
                              Compatible detectedGTUTypes)
                       throws NetworkException
        Create a sensor on a lane at a position on that lane at elevation Sensor.DEFAULT_SENSOR_ELEVATION.
        Parameters:
        id - String; the id of the sensor.
        lane - Lane; the lane for which this is a sensor.
        longitudinalPosition - Length; the position (between 0.0 and the length of the Lane) of the sensor on the design line of the lane.
        positionType - RelativePosition.TYPE; the relative position type (e.g., FRONT, BACK) of the vehicle that triggers the sensor.
        simulator - OTSSimulatorInterface; the simulator (needed to generate the animation).
        geometry - OTSLine3D; the geometry of the object, which provides its location and bounds as well
        detectedGTUTypes - Compatible; The GTU types will trigger this sensor
        Throws:
        NetworkException - when the position on the lane is out of bounds
      • AbstractSensor

        public AbstractSensor​(String id,
                              Lane lane,
                              Length longitudinalPosition,
                              RelativePosition.TYPE positionType,
                              OTSSimulatorInterface simulator,
                              Compatible detectedGTUTypes)
                       throws NetworkException
        Create a new AbstractSensor on a lane at a position on that lane at elevation Sensor.DEFAULT_SENSOR_ELEVATION and default geometry.
        Parameters:
        id - String; the id of the new AbstractSensor
        lane - Lane; the lane on which the new AbstractSensor is positioned
        longitudinalPosition - Length; the position (between 0.0 and the length of the Lane) of the sensor on the design line of the lane
        positionType - RelativePosition.TYPE; the relative position type (e.g., FRONT, BACK) of the vehicle that triggers the sensor.
        simulator - OTSSimulatorInterface; the simulator (needed to generate the animation).
        detectedGTUTypes - Compatible; The GTU types will trigger this sensor
        Throws:
        NetworkException - when the position on the lane is out of bounds
    • Method Detail

      • makeGeometry

        protected static OTSLine3D makeGeometry​(Lane lane,
                                                Length longitudinalPosition,
                                                double relativeWidth)
                                         throws NetworkException
        Make a geometry perpendicular to the center line of the lane with a length of 90% of the width of the lane.
        Parameters:
        lane - Lane; the lane for which to make a perpendicular geometry
        longitudinalPosition - Length; the position on the lane
        relativeWidth - double; lane width to use
        Returns:
        an OTSLine3D that describes the line
        Throws:
        NetworkException - in case the sensor point on the center line of the lane cannot be found
      • trigger

        public final void trigger​(LaneBasedGTU gtu)
        Trigger an action on the GTU. Normally this is the GTU that triggered the sensor. The typical call therefore is sensor.trigger(this);.
        Specified by:
        trigger in interface SingleSensor
        Parameters:
        gtu - LaneBasedGTU; the GTU for which to carry out the trigger action.
      • triggerResponse

        protected abstract void triggerResponse​(LaneBasedGTU gtu)
        Implementation of the response to a trigger of this sensor by a GTU.
        Parameters:
        gtu - LaneBasedGTU; the lane based GTU that triggered this sensor.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • getDetectedGTUTypes

        public final Compatible getDetectedGTUTypes()
        Retrieve the object that decides if a particular GTU type is detected when passing in a particular direction.
        Returns:
        Compatible; the object that decides if a particular GTU type is detected when passing in a particular direction