IntervalDetector

abstract class IntervalDetector<I : IntervalDetector<I, S, U, M, T, D, L>, S : SensorCollector, U : Enum<*>, M : Measurement<U>, T : Triad<U, M>, D : TriadStaticIntervalDetector<U, M, T, D, L>, L : TriadStaticIntervalDetectorListener<U, M, T, D>>(val context: Context, val sensorDelay: SensorDelay, var initializationStartedListener: IntervalDetector.OnInitializationStartedListener<I>? = null, var initializationCompletedListener: IntervalDetector.OnInitializationCompletedListener<I>? = null, var errorListener: IntervalDetector.OnErrorListener<I>? = null, var staticIntervalDetectedListener: IntervalDetector.OnStaticIntervalDetectedListener<I>? = null, var dynamicIntervalDetectedListener: IntervalDetector.OnDynamicIntervalDetectedListener<I>? = null, var resetListener: IntervalDetector.OnResetListener<I>? = null, var accuracyChangedListener: SensorCollector.OnAccuracyChangedListener? = null)

Base class for interval detectors. Interval detectors detect static or motion intervals of measurements captured by different sensors (accelerometer, gyroscope or magnetometer), which typically indicate whether the device is moving or not. When detector is tarted, initialization occurs to determine the noise level of the sensor while keeping device static. Once the detector is initialized, then static or dynamic intervals can be detected. This detector uses accumulated average values during static intervals, and windowed averages as "instantaneous" values during dynamic intervals. Length of windows, as well as thresholds to determine when changes between static and dynamic intervals occur can be easily configured.

Parameters

I

an implementation of IntervalDetector

S

an implementation of SensorCollector

U

type of unit.

M

a type of measurement.

T

a triad type.

D

a detector type.

L

a listener type.

Inheritors

Constructors

Link copied to clipboard
constructor(context: Context, sensorDelay: SensorDelay, initializationStartedListener: IntervalDetector.OnInitializationStartedListener<I>? = null, initializationCompletedListener: IntervalDetector.OnInitializationCompletedListener<I>? = null, errorListener: IntervalDetector.OnErrorListener<I>? = null, staticIntervalDetectedListener: IntervalDetector.OnStaticIntervalDetectedListener<I>? = null, dynamicIntervalDetectedListener: IntervalDetector.OnDynamicIntervalDetectedListener<I>? = null, resetListener: IntervalDetector.OnResetListener<I>? = null, accuracyChangedListener: SensorCollector.OnAccuracyChangedListener? = null)

Types

Link copied to clipboard
fun interface OnDynamicIntervalDetectedListener<T : IntervalDetector<T, *, *, *, *, *, *>>

Interface to notify when a dynamic interval is detected. Accumulated average measurements and standard deviations through the complete previous static or initialization interval are provided, along with the windowed average and standard deviation of measurements at the time the new dynamic interval is detected (where the detector ends a previous static interval or initialization stage).

Link copied to clipboard
fun interface OnErrorListener<T : IntervalDetector<T, *, *, *, *, *, *>>

Interface to notify when an error occurs.

Link copied to clipboard
fun interface OnInitializationCompletedListener<T : IntervalDetector<T, *, *, *, *, *, *>>

Interface to notify when detector completes its initialization.

Link copied to clipboard
fun interface OnInitializationStartedListener<T : IntervalDetector<T, *, *, *, *, *, *>>

Interface to notify when detector starts initialization.

Link copied to clipboard
fun interface OnResetListener<T : IntervalDetector<T, *, *, *, *, *, *>>

Interface to notify when detector is reset (occurs when starting after stopping the detector).

Link copied to clipboard
fun interface OnStaticIntervalDetectedListener<T : IntervalDetector<T, *, *, *, *, *, *>>

Interface to notify when a new static interval is detected. Instantaneous average measurements and standard deviation within the averaging window are provided at the time the new static interval is detected (and consequently detector ends a previous dynamic interval or its initialization stage).

Properties

Link copied to clipboard

Gets average sensor measurements triad accumulated during last static period. This value is updated when switching from a static period to a dynamic one or after initialization completes.

Link copied to clipboard

Gets average x-coordinate of sensor measurements accumulated during last static period expressed in meters per squared second (m/s^2) for accelerometer, radians per second (rad/s) for gyroscope or Teslas (T) for magnetometer. This value is updated when switching from a static period to a dynamic one, or after initialization completes.

Link copied to clipboard

Gets average x-coordinate of sensor measurements accumulated during last static period. This value is updated when switching from a static period to a dynamic one, or after initialization completes.

Link copied to clipboard

Gets average y-coordinate of sensor measurements accumulated during last static period expressed in meters per squared second (m/s^2) for accelerometer, radians per second (rad/s) for gyroscope or Teslas (T) for magnetometer. This value is updated when switching from a static period to a dynamic one, or after initialization completes.

Link copied to clipboard

Gets average y-coordinate of sensor measurements accumulated during last static period. This value is updated when switching from a static period to a dynamic one, or after initialization completes.

Link copied to clipboard

Gets average z-coordinate of sensor measurements accumulated during last static period expressed in meters per squared second (m/s^2) for accelerometer, radians per second (rad/s) for gyroscope or Teslas (T) for magnetometer. This value is updated when switching from a static period to a dynamic one, or after initialization completes.

Link copied to clipboard

Gets average z-coordinate of sensor measurements accumulated during last static period. This value is updated when switching from a static period to a dynamic one, or after initialization completes.

Link copied to clipboard

Gets standard deviation of sensor measurements accumulated during last static period. This value is updated when switching from a static period to a dynamic one or after completing initialization.

Link copied to clipboard

Gets standard deviation of x-coordinate of sensor measurements accumulated during last static period expressed in meters per squared second (m/s^2) for accelerometer, radians per second (rad/s) for gyroscope or Teslas (T) for magnetometer. This value is updated when switching from a static period to a dynamic one or after completing initialization.

Link copied to clipboard

Gets standard deviation of x-coordinate of sensor measurements accumulated during last static period. This value is updated when switching from a static period to a dynamic one or after completing initialization.

Link copied to clipboard

Gets standard deviation of y-coordinate of sensor measurements accumulated during last static period expressed in meters per squared second (m/s^2) for accelerometer, radians per second (rad/s) for gyroscope or Teslas (T) for magnetometer. This value is updated when switching from a static period to a dynamic one or after completing initialization.

Link copied to clipboard

Gets standard deviation of y-coordinate of sensor measurements accumulated during last static period. This value is updated when switching from a static period to a dynamic one or after completing initialization.

Link copied to clipboard

Gets standard deviation of z-coordinate of sensor measurements accumulated during last static period expressed in meters per squared second (m/s^2) for accelerometer, radians per second (rad/s) for gyroscope or Teslas (T) for magnetometer. This value is updated when switching from a static period to a dynamic one or after completing initialization.

Link copied to clipboard

Gets standard deviation of z-coordinate of sensor measurements accumulated during last static period. This value is updated when switching from a static period to a dynamic one or after completing initialization.

Link copied to clipboard

listener to notify when sensor accuracy changes.

Link copied to clipboard

Gets average time interval between sensor samples expressed in seconds (s). This is only available once detector completes initialization.

Link copied to clipboard

Gets average time interval between sensor samples. This is only available once detector completes initialization.

Link copied to clipboard

Gets sensor measurement base noise level that has been detected during initialization expressed in meters per squared second (m/s^2) for accelerometer, radians per second (rad/s) for gyroscope and Teslas (T) for magnetometer. This is only available once detector completes initialization.

Link copied to clipboard

Gets or sets overall absolute threshold to determine whether there has been excessive motion during the whole initialization phase. Failure will be detected if estimated base noise level exceeds this threshold when initialization completes. This threshold is expressed in meters per squared second (m/s^2) for accelerometer, radians per second (rad/s) for gyroscope and Teslas (T) for magnetometer.

Gets or sets overall absolute threshold to determine whether there has been excessive motion during the whole initialization phase. Failure will be detected if estimated base noise level exceeds this threshold when initialization completes.

Link copied to clipboard

Gets sensor measurement base noise level that has been detected during initialization. This is only available once detector completes initialization.

Link copied to clipboard

Gets measurement base noise level PSD (Power Spectral Density) expressed in (m^2 * s^-3) for accelerometer, (rad^2/s) for gyroscope or (T^2 * s) for magnetometer.. This is only available once detector completes initialization.

Link copied to clipboard

Gets measurement base noise level root PSD (Power Spectral Density) expressed in (m * s^-1.5) for accelerometer, (rad * s^-0.5) for gyroscope or (T * s^0.5) for magnetometer. This is only available once detector completes initialization.

Link copied to clipboard

Android context.

Link copied to clipboard

listener to notify when a new dynamic interval is detected.

Link copied to clipboard

listener to notify errors such as sudden motion during initialization or sensor unreliability.

Link copied to clipboard

listener to notify when this detector completes initialization after being started.

Link copied to clipboard

listener to notify when this detector starts initialization after being started.

Link copied to clipboard

Gets or sets number of samples to be processed initially while keeping the sensor static in order to find the base noise level when device is static.

Link copied to clipboard

Gets windowed average of sensor measurements for each processed triad. This value is updated for each processed sample containing an average value for the samples within the window.

Link copied to clipboard

Gets windowed average x-coordinate of sensor measurements for each processed triad expressed in meters per squared second (m/s^2) for accelerometer, radians per second (rad/s) for gyroscope or Teslas (T) for magnetometer. This value is updated for each processed sample containing an average value for the sample within the window.

Link copied to clipboard

Gets windowed average x-coordinate of sensor measurements for each processed triad. This value is updated for each processed sample containing an average value for the sample within the window.

Link copied to clipboard

Gets windowed average y-coordinate of sensor measurements for each processed triad expressed in meters per squared second (m/s^2) for accelerometer, radians per second (rad/s) for gyroscope or Teslas (T) for magnetometer. This value is updated for each processed sample containing an average value for the sample within the window.

Link copied to clipboard

Gets windowed average y-coordinate of sensor measurements for each processed triad. This value is updated for each processed sample containing an average value for the sample within the window.

Link copied to clipboard

Gets windowed average z-coordinate of sensor measurements for each processed triad expressed in meters per squared second (m/s^2) for accelerometer, radians per second (rad/s) for gyroscope or Teslas (T) for magnetometer. This value is updated for each processed sample containing an average value for the sample within the window.

Link copied to clipboard

Gets windowed average z-coordinate of sensor measurements for each processed triad. This value is updated for each processed sample containing an average value for the sample within the window.

Link copied to clipboard

Gets or sets factor to determine that a sudden movement has occurred during initialization if instantaneous noise level exceeds accumulated noise level by this factor amount. This factor is unit-less.

Link copied to clipboard

Gets windowed standard deviation of sensor measurements for each processed triad. This value is updated for each processed sample containing measured standard deviation for the samples within the window.

Link copied to clipboard

Gets windowed standard deviation of x-coordinate of sensor measurements for each processed triad expressed in meters per squared second (m/s^2) for accelerometer, radians per second (rad/s) for gyroscope or Teslas (T) for magnetometer. This value is updated for each processed sample containing measured standard deviation for the samples within the window.

Link copied to clipboard

Gets windowed standard deviation of x-coordinate of sensor measurements for each processed triad. This value is updated for each processed sample containing measured standard deviation for the samples within the window.

Link copied to clipboard

Gets windowed standard deviation of y-coordinate of sensor measurements for each processed triad expressed in meters per squared second (m/s^2) for accelerometer, radians per second (rad/s) for gyroscope or Teslas (T) for magnetometer. This value is updated for each processed sample containing measured standard deviation for the samples within the window.

Link copied to clipboard

Gets windowed standard deviation of y-coordinate of sensor measurements for each processed triad. This value is updated for each processed sample containing measured standard deviation for the samples within the window.

Link copied to clipboard

Gets windowed standard deviation of z-coordinate of sensor measurements for each processed triad expressed in meters per squared second (m/s^2) for accelerometer, radians per second (rad/s) for gyroscope or Teslas (T) for magnetometer. This value is updated for each processed sample containing measured standard deviation for the samples within the window.

Link copied to clipboard

Gets windowed standard deviation of z-coordinate of sensor measurements for each processed triad. This value is updated for each processed sample containing measured standard deviation for the samples within the window.

Link copied to clipboard

Number of measurements that have been processed.

Link copied to clipboard

listener to notify when a reset occurs.

Link copied to clipboard

Indicates whether this detector is already running.

Link copied to clipboard

Gets sensor being used to obtain measurements, or null if not available. This can be used to obtain additional information about the sensor.

Link copied to clipboard

Delay of sensor between samples.

Link copied to clipboard

listener to notify when a new static interval is detected.

Link copied to clipboard

Gets status of interval detector. Initially the interval detector will be idle. Once it starts, it will start the initialization phase, and once initialization is complete, it will switch between static or dynamic interval until detector is stopped or an error occurs.

Link copied to clipboard

Gets estimated threshold to determine static/dynamic period changes expressed in meters per squared second (m/s^2) for accelerometer, radians per second (rad/s) for gyroscope or Teslas (T) for magnetometer. This is only available once detector completes initialization.

Link copied to clipboard

Gets estimated threshold to determine static/dynamic period changes. This is only available once detector completes initialization.

Link copied to clipboard

Gets or sets factor to be applied to detected base noise level in order to determine threshold for static/dynamic period changes. This factor is unit-less.

Link copied to clipboard

Gets estimated standard deviation of time interval between measurements expressed in seconds (s). This is only available once detector completes initialization.

Link copied to clipboard

Gets estimated standard deviation of time interval between measurements. This is only available once detector completes initialization.

Link copied to clipboard

Gets estimated variance of time interval between measurements expressed in squared seconds (s^2). This is only available once detector completes initialization.

Link copied to clipboard

Gets or sets length of number of samples to keep within the window being processed to determine instantaneous sensor noise level. Window size must always be larger than allowed minimum value, which is 2 and must have an odd value.

Functions

Link copied to clipboard

Gets average sensor measurements triad accumulated during last static period. This value is updated when switching from a static period to a dynamic one or after initialization completes.

Link copied to clipboard

Gets average x-coordinate of sensor measurements accumulated during last static period. This value is updated when switching from a static period to a dynamic one, or after initialization completes.

Link copied to clipboard

Gets average y-coordinate of sensor measurements accumulated during last static period. This value is updated when switching from a static period to a dynamic one, or after initialization completes.

Link copied to clipboard

Gets average z-coordinate of sensor measurements accumulated during last static period. This value is updated when switching from a static period to a dynamic one, or after initialization completes.

Link copied to clipboard

Gets standard deviation of sensor measurements accumulated during last static period. This value is updated when switching from a static period to a dynamic one or after completing initialization.

Link copied to clipboard

Gets standard deviation of x-coordinate of sensor measurements accumulated during last static period. This value is updated when switching from a static period to a dynamic one or after completing initialization.

Link copied to clipboard

Gets standard deviation of y-coordinate of sensor measurements accumulated during last static period. This value is updated when switching from a static period to a dynamic one or after completing initialization.

Link copied to clipboard

Gets standard deviation of z-coordinate of sensor measurements accumulated during last static period. This value is updated when switching from a static period to a dynamic one or after completing initialization.

Link copied to clipboard

Gets average time interval between measurements. This is only available once detector completes initialization.

Gets overall absolute threshold to determine whether there has been excessive motion during the whole initialization phase. Failure will be detected if estimated base noise level exceeds this threshold when initialization completes.

Link copied to clipboard

Gets sensor measurement base noise level that has been detected during initialization. This is only available once detector completes initialization.

Link copied to clipboard

Gets windowed average of sensor measurements for each processed triad. This value is updated for each processed sample containing an average value for the samples within the window.

Link copied to clipboard

Gets windowed average x-coordinate of sensor measurements for each processed triad. This value is updated for each processed sample containing an average value for the sample within the window.

Link copied to clipboard

Gets windowed average y-coordinate of sensor measurements for each processed triad. This value is updated for each processed sample containing an average value for the sample within the window.

Link copied to clipboard

Gets windowed average z-coordinate of sensor measurements for each processed triad. This value is updated for each processed sample containing an average value for the sample within the window.

Link copied to clipboard

Gets windowed standard deviation of measurements for each processed triad. This value is updated for each processed sample containing measured standard deviation for the samples within the window.

Link copied to clipboard

Gets windowed standard deviation of x-coordinate of sensor measurements for each processed triad. This value is updated for each processed sample containing measured standard deviation for the samples within the window.

Link copied to clipboard

Gets windowed standard deviation of y-coordinate of sensor measurements for each processed triad. This value is updated for each processed sample containing measured standard deviation for the samples within the window.

Link copied to clipboard

Gets windowed standard deviation of z-coordinate of sensor measurements for each processed triad. This value is updated for each processed sample containing measured standard deviation for the samples within the window.

Link copied to clipboard

Gets estimated threshold to determine static/dynamic period changes. This is only available once detector completes initialization.

Link copied to clipboard

Gets estimated standard deviation of time interval between measurements. This is only available once detector completes initialization.

Link copied to clipboard
fun start()

Starts collection of sensor measurements.

Link copied to clipboard
fun stop()

Stops collection of sensor measurements.