Class MeasurementsGenerator<T,G extends MeasurementsGenerator<T,G,L,I>,L extends MeasurementsGeneratorListener<T,G,L,I>,I>

java.lang.Object
com.irurueta.navigation.inertial.calibration.generators.MeasurementsGenerator<T,G,L,I>
Type Parameters:
T - type of measurement to be generated.
G - type of generator.
L - type of listener.
I - type of input data to be processed.
All Implemented Interfaces:
AccelerometerNoiseRootPsdSource
Direct Known Subclasses:
AccelerometerMeasurementsGenerator, GyroscopeMeasurementsGenerator, MagnetometerMeasurementsGenerator

public abstract class MeasurementsGenerator<T,G extends MeasurementsGenerator<T,G,L,I>,L extends MeasurementsGeneratorListener<T,G,L,I>,I> extends Object implements AccelerometerNoiseRootPsdSource
Base class to generate measurements for the calibration of accelerometers, gyroscopes or magnetometers after detection of static/dynamic intervals.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Default maximum number of samples allowed in dynamic intervals.
    static final int
    Default minimum number of samples required in a static interval to be taken into account.
    protected L
    Listener to handle generated events.
    private int
    Maximum number of samples allowed in dynamic intervals.
    private int
    Minimum number of samples required in a static interval to be taken into account.
    private int
    Number of samples that have been processed in a dynamic period so far.
    private int
    Number of samples that have been processed in a static period so far.
    private boolean
    Indicates whether generator is running or not.
    private boolean
    Indicates whether dynamic interval must be skipped.
    private boolean
    Indicates whether static interval must be skipped.
    Static/dynamic interval detector using accelerometer samples.
    protected final AccelerationTriad
    An acceleration triad.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Constructor.
    protected
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    Check processed samples so far before processing a new one.
    protected abstract void
    Gets corresponding acceleration triad from provided input sample.
    double
    Gets accelerometer base noise level that has been detected during initialization expressed in meters per squared second (m/s^2).
    com.irurueta.units.Acceleration
    Gets accelerometer base noise level that has been detected during initialization.
    void
    getAccelerometerBaseNoiseLevelAsMeasurement(com.irurueta.units.Acceleration result)
    Gets accelerometer base noise level that has been detected during initialization.
    double
    Gets accelerometer base noise level PSD (Power Spectral Density) expressed in (m^2 * s^-3).
    double
    Gets accelerometer base noise level root PSD (Power Spectral Density) expressed in (m * s^-1.5).
    double
    Gets overall absolute threshold to determine whether there has been excessive motion during the whole initialization phase.
    com.irurueta.units.Acceleration
    Gets overall absolute threshold to determine whether there has been excessive motion during the whole initialization phase.
    void
    getBaseNoiseLevelAbsoluteThresholdAsMeasurement(com.irurueta.units.Acceleration result)
    Gets overall absolute threshold to determine whether there has been excessive motion during the whole initialization phase.
    int
    Gets number of samples to be processed initially while keeping the sensor static in order to find the base noise level when device is static.
    double
    Gets factor to determine that a sudden movement has occurred during initialization if instantaneous noise level exceeds accumulated noise level by this factor amount.
    Gets listener to handle generated events.
    int
    Gets maximum number of samples allowed in dynamic intervals.
    int
    Gets minimum number of samples required in a static interval to be taken into account.
    int
    Gets number of samples that have been processed in a dynamic period so far.
    int
    Gets number of samples that have been processed in a static period so far.
    Gets internal status of this generator.
    double
    Gets threshold to determine static/dynamic period changes expressed in meters per squared second (m/s^2).
    com.irurueta.units.Acceleration
    Gets threshold to determine static/dynamic period changes.
    void
    getThresholdAsMeasurement(com.irurueta.units.Acceleration result)
    Gets threshold to determine static/dynamic period changes.
    double
    Gets factor to be applied to detected base noise level in order to determine threshold for static/dynamic period changes.
    double
    Gets time interval between input samples expressed in seconds (s).
    com.irurueta.units.Time
    Gets time interval between input samples.
    void
    getTimeIntervalAsTime(com.irurueta.units.Time result)
    Gets time interval between input samples.
    int
    Gets length of number of samples to keep within the window being processed to determine instantaneous accelerometer noise level.
    protected abstract void
    Handles a dynamic-to-static interval change.
    protected abstract void
    Handles an initialization completion.
    protected abstract void
    Handles an error during initialization.
    protected abstract void
    handleStaticToDynamicChange(double accumulatedAvgX, double accumulatedAvgY, double accumulatedAvgZ, double accumulatedStdX, double accumulatedStdY, double accumulatedStdZ)
    Handles a static-to-dynamic interval change.
    boolean
    Indicates whether last dynamic interval must be skipped.
    boolean
    Indicates whether generator is running or not.
    boolean
    Indicates whether last static interval must be skipped.
    protected abstract void
    postProcess(I sample)
    Post process provided input sample.
    boolean
    process(I sample)
    Processes a sample of data.
    void
    Resets this generator.
    void
    setBaseNoiseLevelAbsoluteThreshold(double baseNoiseLevelAbsoluteThreshold)
    Sets overall absolute threshold to determine whether there has been excessive motion during the whole initialization phase.
    void
    setBaseNoiseLevelAbsoluteThreshold(com.irurueta.units.Acceleration baseNoiseLevelAbsoluteThreshold)
    Sets overall absolute threshold to determine whether there has been excessive motion during the whole initialization phase.
    void
    setInitialStaticSamples(int initialStaticSamples)
    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.
    void
    setInstantaneousNoiseLevelFactor(double instantaneousNoiseLevelFactor)
    Sets factor to determine that a sudden movement has occurred during initialization if instantaneous noise level exceeds accumulated noise level by this factor amount.
    void
    setListener(L listener)
    Sets listener to handle generated events.
    void
    setMaxDynamicSamples(int maxDynamicSamples)
    Sets maximum number of samples allowed in dynamic intervals.
    void
    setMinStaticSamples(int minStaticSamples)
    Sets minimum number of samples required in a static interval to be taken into account.
    void
    setThresholdFactor(double thresholdFactor)
    Sets factor to be applied to detected base noise level in order to determine threshold for static/dynamic period changes.
    void
    setTimeInterval(double timeInterval)
    Sets time interval between input samples expressed in seconds (s).
    void
    setTimeInterval(com.irurueta.units.Time timeInterval)
    Sets time interval between input samples.
    private void
    Setups listener for static interval detector.
    void
    setWindowSize(int windowSize)
    Sets length of number of samples to keep within the window being processed to determine instantaneous accelerometer noise level.
    protected void
    Updates counters of processed samples.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DEFAULT_MIN_STATIC_SAMPLES

      public static final int DEFAULT_MIN_STATIC_SAMPLES
      Default minimum number of samples required in a static interval to be taken into account. Smaller static intervals will be discarded.
      See Also:
    • DEFAULT_MAX_DYNAMIC_SAMPLES

      public static final int DEFAULT_MAX_DYNAMIC_SAMPLES
      Default maximum number of samples allowed in dynamic intervals. Larger dynamic intervals will be discarded.
      See Also:
    • listener

      protected L extends MeasurementsGeneratorListener<T,G,L,I> listener
      Listener to handle generated events.
    • triad

      protected final AccelerationTriad triad
      An acceleration triad. This is reused for memory efficiency.
    • staticIntervalDetector

      protected final AccelerationTriadStaticIntervalDetector staticIntervalDetector
      Static/dynamic interval detector using accelerometer samples.
    • running

      private boolean running
      Indicates whether generator is running or not.
    • minStaticSamples

      private int minStaticSamples
      Minimum number of samples required in a static interval to be taken into account. Smaller static intervals will be discarded.
    • maxDynamicSamples

      private int maxDynamicSamples
      Maximum number of samples allowed in dynamic intervals. Larger dynamic intervals will be discarded.
    • processedStaticSamples

      private int processedStaticSamples
      Number of samples that have been processed in a static period so far.
    • processedDynamicSamples

      private int processedDynamicSamples
      Number of samples that have been processed in a dynamic period so far.
    • skipStaticInterval

      private boolean skipStaticInterval
      Indicates whether static interval must be skipped.
    • skipDynamicInterval

      private boolean skipDynamicInterval
      Indicates whether dynamic interval must be skipped.
  • Constructor Details

    • MeasurementsGenerator

      protected MeasurementsGenerator()
      Constructor.
    • MeasurementsGenerator

      protected MeasurementsGenerator(L listener)
      Constructor.
      Parameters:
      listener - listener to handle events raised by this generator.
  • Method Details

    • getTimeInterval

      public double getTimeInterval()
      Gets time interval between input samples expressed in seconds (s).
      Returns:
      time interval between input samples.
    • setTimeInterval

      public void setTimeInterval(double timeInterval) throws com.irurueta.navigation.LockedException
      Sets time interval between input samples expressed in seconds (s).
      Parameters:
      timeInterval - time interval between input samples.
      Throws:
      IllegalArgumentException - if provided value is negative.
      com.irurueta.navigation.LockedException - if generator is currently running.
    • getTimeIntervalAsTime

      public com.irurueta.units.Time getTimeIntervalAsTime()
      Gets time interval between input samples.
      Returns:
      time interval between input samples.
    • getTimeIntervalAsTime

      public void getTimeIntervalAsTime(com.irurueta.units.Time result)
      Gets time interval between input samples.
      Parameters:
      result - instance where time interval will be stored.
    • setTimeInterval

      public void setTimeInterval(com.irurueta.units.Time timeInterval) throws com.irurueta.navigation.LockedException
      Sets time interval between input samples.
      Parameters:
      timeInterval - time interval between input samples.
      Throws:
      IllegalArgumentException - if provided value is negative.
      com.irurueta.navigation.LockedException - if estimator is currently running.
    • getMinStaticSamples

      public int getMinStaticSamples()
      Gets minimum number of samples required in a static interval to be taken into account. Smaller static intervals will be discarded.
      Returns:
      minimum number of samples required in a static interval to be taken into account.
    • setMinStaticSamples

      public void setMinStaticSamples(int minStaticSamples) throws com.irurueta.navigation.LockedException
      Sets minimum number of samples required in a static interval to be taken into account. Smaller static intervals will be discarded.
      Parameters:
      minStaticSamples - minimum number of samples required in a static interval to be taken into account.
      Throws:
      com.irurueta.navigation.LockedException - if generator is busy.
      IllegalArgumentException - if provided value is less than 2.
    • getMaxDynamicSamples

      public int getMaxDynamicSamples()
      Gets maximum number of samples allowed in dynamic intervals.
      Returns:
      maximum number of samples allowed in dynamic intervals.
    • setMaxDynamicSamples

      public void setMaxDynamicSamples(int maxDynamicSamples) throws com.irurueta.navigation.LockedException
      Sets maximum number of samples allowed in dynamic intervals.
      Parameters:
      maxDynamicSamples - maximum number of samples allowed in dynamic intervals.
      Throws:
      com.irurueta.navigation.LockedException - if generator is busy.
      IllegalArgumentException - if provided value is less than 2.
    • getListener

      public L getListener()
      Gets listener to handle generated events.
      Returns:
      listener to handle generated events.
    • setListener

      public void setListener(L listener) throws com.irurueta.navigation.LockedException
      Sets listener to handle generated events.
      Parameters:
      listener - listener to handle generated events.
      Throws:
      com.irurueta.navigation.LockedException - if generator is busy.
    • getWindowSize

      public int getWindowSize()
      Gets length of number of samples to keep within the window being processed to determine instantaneous accelerometer noise level.
      Returns:
      length of number of samples to keep within the window.
    • setWindowSize

      public void setWindowSize(int windowSize) throws com.irurueta.navigation.LockedException
      Sets length of number of samples to keep within the window being processed to determine instantaneous accelerometer noise level. Window size must always be larger than allowed minimum value, which is 2 and must have an odd value.
      Parameters:
      windowSize - length of number of samples to keep within the window.
      Throws:
      com.irurueta.navigation.LockedException - if detector is busy processing a previous sample.
      IllegalArgumentException - if provided value is not valid.
    • getInitialStaticSamples

      public int getInitialStaticSamples()
      Gets number of samples to be processed initially while keeping the sensor static in order to find the base noise level when device is static.
      Returns:
      number of samples to be processed initially.
    • setInitialStaticSamples

      public void setInitialStaticSamples(int initialStaticSamples) throws com.irurueta.navigation.LockedException
      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.
      Parameters:
      initialStaticSamples - number of samples to be processed initially.
      Throws:
      com.irurueta.navigation.LockedException - if detector is busy.
      IllegalArgumentException - if provided value is less than TriadStaticIntervalDetector.MINIMUM_INITIAL_STATIC_SAMPLES
    • getThresholdFactor

      public double getThresholdFactor()
      Gets factor to be applied to detected base noise level in order to determine threshold for static/dynamic period changes. This factor is unit-less.
      Returns:
      factor to be applied to detected base noise level.
    • setThresholdFactor

      public void setThresholdFactor(double thresholdFactor) throws com.irurueta.navigation.LockedException
      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.
      Parameters:
      thresholdFactor - factor to be applied to detected base noise level.
      Throws:
      com.irurueta.navigation.LockedException - if detector is busy.
      IllegalArgumentException - if provided value is zero or negative.
    • getInstantaneousNoiseLevelFactor

      public double getInstantaneousNoiseLevelFactor()
      Gets 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.
      Returns:
      factor to determine that a sudden movement has occurred.
    • setInstantaneousNoiseLevelFactor

      public void setInstantaneousNoiseLevelFactor(double instantaneousNoiseLevelFactor) throws com.irurueta.navigation.LockedException
      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.
      Parameters:
      instantaneousNoiseLevelFactor - factor to determine that a sudden movement has occurred during initialization.
      Throws:
      com.irurueta.navigation.LockedException - if detector is busy.
      IllegalArgumentException - if provided value is zero or negative.
    • getBaseNoiseLevelAbsoluteThreshold

      public double getBaseNoiseLevelAbsoluteThreshold()
      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. This threshold is expressed in meters per squared second (m/s^2).
      Returns:
      overall absolute threshold to determine whether there has been excessive motion.
    • setBaseNoiseLevelAbsoluteThreshold

      public void setBaseNoiseLevelAbsoluteThreshold(double baseNoiseLevelAbsoluteThreshold) throws com.irurueta.navigation.LockedException
      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).
      Parameters:
      baseNoiseLevelAbsoluteThreshold - overall absolute threshold to determine whether there has been excessive motion.
      Throws:
      com.irurueta.navigation.LockedException - if detector is busy.
      IllegalArgumentException - if provided value is zero or negative.
    • getBaseNoiseLevelAbsoluteThresholdAsMeasurement

      public com.irurueta.units.Acceleration getBaseNoiseLevelAbsoluteThresholdAsMeasurement()
      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.
      Returns:
      overall absolute threshold to determine whether there has been excessive motion.
    • getBaseNoiseLevelAbsoluteThresholdAsMeasurement

      public void getBaseNoiseLevelAbsoluteThresholdAsMeasurement(com.irurueta.units.Acceleration result)
      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.
      Parameters:
      result - instance where result will be stored.
    • setBaseNoiseLevelAbsoluteThreshold

      public void setBaseNoiseLevelAbsoluteThreshold(com.irurueta.units.Acceleration baseNoiseLevelAbsoluteThreshold) throws com.irurueta.navigation.LockedException
      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.
      Parameters:
      baseNoiseLevelAbsoluteThreshold - overall absolute threshold to determine whether there has been excessive motion.
      Throws:
      com.irurueta.navigation.LockedException - if detector is busy.
      IllegalArgumentException - if provided value is zero or negative.
    • getStatus

      Gets internal status of this generator.
      Returns:
      internal status of this generator.
    • getAccelerometerBaseNoiseLevel

      public double getAccelerometerBaseNoiseLevel()
      Gets accelerometer base noise level that has been detected during initialization expressed in meters per squared second (m/s^2). This is equal to the standard deviation of the accelerometer measurements during initialization phase.
      Returns:
      accelerometer base noise level.
    • getAccelerometerBaseNoiseLevelAsMeasurement

      public com.irurueta.units.Acceleration getAccelerometerBaseNoiseLevelAsMeasurement()
      Gets accelerometer base noise level that has been detected during initialization. This is equal to the standard deviation of the accelerometer measurements during initialization phase.
      Returns:
      measurement base noise level.
    • getAccelerometerBaseNoiseLevelAsMeasurement

      public void getAccelerometerBaseNoiseLevelAsMeasurement(com.irurueta.units.Acceleration result)
      Gets accelerometer base noise level that has been detected during initialization. This is equal to the standard deviation of the accelerometer measurements during initialization phase.
      Parameters:
      result - instance where result will be stored.
    • getAccelerometerBaseNoiseLevelPsd

      public double getAccelerometerBaseNoiseLevelPsd()
      Gets accelerometer base noise level PSD (Power Spectral Density) expressed in (m^2 * s^-3).
      Returns:
      accelerometer base noise level PSD.
    • getAccelerometerBaseNoiseLevelRootPsd

      public double getAccelerometerBaseNoiseLevelRootPsd()
      Gets accelerometer base noise level root PSD (Power Spectral Density) expressed in (m * s^-1.5).
      Specified by:
      getAccelerometerBaseNoiseLevelRootPsd in interface AccelerometerNoiseRootPsdSource
      Returns:
      accelerometer base noise level root PSD.
    • getThreshold

      public double getThreshold()
      Gets threshold to determine static/dynamic period changes expressed in meters per squared second (m/s^2).
      Returns:
      threshold to determine static/dynamic period changes.
    • getThresholdAsMeasurement

      public com.irurueta.units.Acceleration getThresholdAsMeasurement()
      Gets threshold to determine static/dynamic period changes.
      Returns:
      threshold to determine static/dynamic period changes.
    • getThresholdAsMeasurement

      public void getThresholdAsMeasurement(com.irurueta.units.Acceleration result)
      Gets threshold to determine static/dynamic period changes.
      Parameters:
      result - instance where result will be stored.
    • getProcessedStaticSamples

      public int getProcessedStaticSamples()
      Gets number of samples that have been processed in a static period so far.
      Returns:
      number of samples that have been processed in a static period so far.
    • getProcessedDynamicSamples

      public int getProcessedDynamicSamples()
      Gets number of samples that have been processed in a dynamic period so far.
      Returns:
      number of samples that have been processed in a dynamic period so far.
    • isStaticIntervalSkipped

      public boolean isStaticIntervalSkipped()
      Indicates whether last static interval must be skipped.
      Returns:
      true if last static interval must be skipped.
    • isDynamicIntervalSkipped

      public boolean isDynamicIntervalSkipped()
      Indicates whether last dynamic interval must be skipped.
      Returns:
      true if last dynamic interval must be skipped.
    • isRunning

      public boolean isRunning()
      Indicates whether generator is running or not.
      Returns:
      true if generator is running, false otherwise.
    • process

      public boolean process(I sample) throws com.irurueta.navigation.LockedException
      Processes a sample of data.
      Parameters:
      sample - sample of data to be processed.
      Returns:
      true if provided samples has been processed, false if provided triad has been skipped because generator previously failed. If generator previously failed, it will need to be reset before processing additional samples.
      Throws:
      com.irurueta.navigation.LockedException - if generator is busy processing a previous sample.
    • reset

      public void reset() throws com.irurueta.navigation.LockedException
      Resets this generator.
      Throws:
      com.irurueta.navigation.LockedException - if generator is busy.
    • postProcess

      protected abstract void postProcess(I sample) throws com.irurueta.navigation.LockedException
      Post process provided input sample.
      Parameters:
      sample - an input sample.
      Throws:
      com.irurueta.navigation.LockedException - if generator is busy.
    • getAccelerationTriadFromInputSample

      protected abstract void getAccelerationTriadFromInputSample(I sample)
      Gets corresponding acceleration triad from provided input sample. This method must store the result into triad.
      Parameters:
      sample - input sample.
    • handleStaticToDynamicChange

      protected abstract void handleStaticToDynamicChange(double accumulatedAvgX, double accumulatedAvgY, double accumulatedAvgZ, double accumulatedStdX, double accumulatedStdY, double accumulatedStdZ)
      Handles a static-to-dynamic interval change.
      Parameters:
      accumulatedAvgX - average x-coordinate of measurements during last static period expressed in meters per squared second (m/s^2).
      accumulatedAvgY - average y-coordinate of specific force during last static period expressed in meters per squared second (m/s^2).
      accumulatedAvgZ - average z-coordinate of specific force during last static period expressed in meters per squared second (m/s^2).
      accumulatedStdX - standard deviation of x-coordinate of measurements during last static period expressed in meters per squared second (m/s^2).
      accumulatedStdY - standard deviation of y-coordinate of measurements during last static period expressed in meters per squared second (m/s^2).
      accumulatedStdZ - standard deviation of z-coordinate of measurements during last static period expressed in meters per squared second (m/s^2).
    • handleDynamicToStaticChange

      protected abstract void handleDynamicToStaticChange()
      Handles a dynamic-to-static interval change.
    • handleInitializationCompleted

      protected abstract void handleInitializationCompleted()
      Handles an initialization completion.
    • handleInitializationFailed

      protected abstract void handleInitializationFailed()
      Handles an error during initialization.
    • checkProcessedSamples

      protected void checkProcessedSamples()
      Check processed samples so far before processing a new one.
    • updateCounters

      protected void updateCounters()
      Updates counters of processed samples.
    • setupListener

      private void setupListener() throws com.irurueta.navigation.LockedException
      Setups listener for static interval detector.
      Throws:
      com.irurueta.navigation.LockedException - if static interval detector is busy.