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
FieldsModifier and TypeFieldDescriptionstatic final intDefault maximum number of samples allowed in dynamic intervals.static final intDefault minimum number of samples required in a static interval to be taken into account.protected LListener to handle generated events.private intMaximum number of samples allowed in dynamic intervals.private intMinimum number of samples required in a static interval to be taken into account.private intNumber of samples that have been processed in a dynamic period so far.private intNumber of samples that have been processed in a static period so far.private booleanIndicates whether generator is running or not.private booleanIndicates whether dynamic interval must be skipped.private booleanIndicates whether static interval must be skipped.protected final AccelerationTriadStaticIntervalDetectorStatic/dynamic interval detector using accelerometer samples.protected final AccelerationTriadAn acceleration triad. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructor.protectedMeasurementsGenerator(L listener) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidCheck processed samples so far before processing a new one.protected abstract voidgetAccelerationTriadFromInputSample(I sample) Gets corresponding acceleration triad from provided input sample.doubleGets accelerometer base noise level that has been detected during initialization expressed in meters per squared second (m/s^2).com.irurueta.units.AccelerationGets accelerometer base noise level that has been detected during initialization.voidgetAccelerometerBaseNoiseLevelAsMeasurement(com.irurueta.units.Acceleration result) Gets accelerometer base noise level that has been detected during initialization.doubleGets accelerometer base noise level PSD (Power Spectral Density) expressed in (m^2 * s^-3).doubleGets accelerometer base noise level root PSD (Power Spectral Density) expressed in (m * s^-1.5).doubleGets overall absolute threshold to determine whether there has been excessive motion during the whole initialization phase.com.irurueta.units.AccelerationGets overall absolute threshold to determine whether there has been excessive motion during the whole initialization phase.voidgetBaseNoiseLevelAbsoluteThresholdAsMeasurement(com.irurueta.units.Acceleration result) Gets overall absolute threshold to determine whether there has been excessive motion during the whole initialization phase.intGets number of samples to be processed initially while keeping the sensor static in order to find the base noise level when device is static.doubleGets 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.intGets maximum number of samples allowed in dynamic intervals.intGets minimum number of samples required in a static interval to be taken into account.intGets number of samples that have been processed in a dynamic period so far.intGets number of samples that have been processed in a static period so far.Gets internal status of this generator.doubleGets threshold to determine static/dynamic period changes expressed in meters per squared second (m/s^2).com.irurueta.units.AccelerationGets threshold to determine static/dynamic period changes.voidgetThresholdAsMeasurement(com.irurueta.units.Acceleration result) Gets threshold to determine static/dynamic period changes.doubleGets factor to be applied to detected base noise level in order to determine threshold for static/dynamic period changes.doubleGets time interval between input samples expressed in seconds (s).com.irurueta.units.TimeGets time interval between input samples.voidgetTimeIntervalAsTime(com.irurueta.units.Time result) Gets time interval between input samples.intGets length of number of samples to keep within the window being processed to determine instantaneous accelerometer noise level.protected abstract voidHandles a dynamic-to-static interval change.protected abstract voidHandles an initialization completion.protected abstract voidHandles an error during initialization.protected abstract voidhandleStaticToDynamicChange(double accumulatedAvgX, double accumulatedAvgY, double accumulatedAvgZ, double accumulatedStdX, double accumulatedStdY, double accumulatedStdZ) Handles a static-to-dynamic interval change.booleanIndicates whether last dynamic interval must be skipped.booleanIndicates whether generator is running or not.booleanIndicates whether last static interval must be skipped.protected abstract voidpostProcess(I sample) Post process provided input sample.booleanProcesses a sample of data.voidreset()Resets this generator.voidsetBaseNoiseLevelAbsoluteThreshold(double baseNoiseLevelAbsoluteThreshold) Sets overall absolute threshold to determine whether there has been excessive motion during the whole initialization phase.voidsetBaseNoiseLevelAbsoluteThreshold(com.irurueta.units.Acceleration baseNoiseLevelAbsoluteThreshold) Sets overall absolute threshold to determine whether there has been excessive motion during the whole initialization phase.voidsetInitialStaticSamples(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.voidsetInstantaneousNoiseLevelFactor(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.voidsetListener(L listener) Sets listener to handle generated events.voidsetMaxDynamicSamples(int maxDynamicSamples) Sets maximum number of samples allowed in dynamic intervals.voidsetMinStaticSamples(int minStaticSamples) Sets minimum number of samples required in a static interval to be taken into account.voidsetThresholdFactor(double thresholdFactor) Sets factor to be applied to detected base noise level in order to determine threshold for static/dynamic period changes.voidsetTimeInterval(double timeInterval) Sets time interval between input samples expressed in seconds (s).voidsetTimeInterval(com.irurueta.units.Time timeInterval) Sets time interval between input samples.private voidSetups listener for static interval detector.voidsetWindowSize(int windowSize) Sets length of number of samples to keep within the window being processed to determine instantaneous accelerometer noise level.protected voidUpdates counters of processed samples.
-
Field Details
-
DEFAULT_MIN_STATIC_SAMPLES
public static final int DEFAULT_MIN_STATIC_SAMPLESDefault 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_SAMPLESDefault maximum number of samples allowed in dynamic intervals. Larger dynamic intervals will be discarded.- See Also:
-
listener
Listener to handle generated events. -
triad
An acceleration triad. This is reused for memory efficiency. -
staticIntervalDetector
Static/dynamic interval detector using accelerometer samples. -
running
private boolean runningIndicates whether generator is running or not. -
minStaticSamples
private int minStaticSamplesMinimum number of samples required in a static interval to be taken into account. Smaller static intervals will be discarded. -
maxDynamicSamples
private int maxDynamicSamplesMaximum number of samples allowed in dynamic intervals. Larger dynamic intervals will be discarded. -
processedStaticSamples
private int processedStaticSamplesNumber of samples that have been processed in a static period so far. -
processedDynamicSamples
private int processedDynamicSamplesNumber of samples that have been processed in a dynamic period so far. -
skipStaticInterval
private boolean skipStaticIntervalIndicates whether static interval must be skipped. -
skipDynamicInterval
private boolean skipDynamicIntervalIndicates whether dynamic interval must be skipped.
-
-
Constructor Details
-
MeasurementsGenerator
protected MeasurementsGenerator()Constructor. -
MeasurementsGenerator
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
Gets listener to handle generated events.- Returns:
- listener to handle generated events.
-
setListener
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 thanTriadStaticIntervalDetector.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:
getAccelerometerBaseNoiseLevelRootPsdin interfaceAccelerometerNoiseRootPsdSource- 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
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.LockedExceptionResets this generator.- Throws:
com.irurueta.navigation.LockedException- if generator is busy.
-
postProcess
Post process provided input sample.- Parameters:
sample- an input sample.- Throws:
com.irurueta.navigation.LockedException- if generator is busy.
-
getAccelerationTriadFromInputSample
Gets corresponding acceleration triad from provided input sample. This method must store the result intotriad.- 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.LockedExceptionSetups listener for static interval detector.- Throws:
com.irurueta.navigation.LockedException- if static interval detector is busy.
-