Class WindowedMeasurementNoiseEstimator<U extends Enum<?>,M extends com.irurueta.units.Measurement<U>,E extends WindowedMeasurementNoiseEstimator<U,M,E,L>,L extends WindowedMeasurementNoiseEstimatorListener<U,M,E>>
java.lang.Object
com.irurueta.navigation.inertial.calibration.noise.WindowedMeasurementNoiseEstimator<U,M,E,L>
- Type Parameters:
U
- a measurement unit type.M
- a measurement type.E
- an estimator type.L
- a listener type.
- Direct Known Subclasses:
WindowedAccelerationMeasurementNoiseEstimator
,WindowedAngularSpeedMeasurementNoiseEstimator
,WindowedMagneticFluxDensityMeasurementNoiseEstimator
public abstract class WindowedMeasurementNoiseEstimator<U extends Enum<?>,M extends com.irurueta.units.Measurement<U>,E extends WindowedMeasurementNoiseEstimator<U,M,E,L>,L extends WindowedMeasurementNoiseEstimatorListener<U,M,E>>
extends Object
Base class to estimate measurement noise variances and PSD's (Power Spectral Densities)
along with average values for a windowed amount of samples.
Implementations of this estimator may use norms of measurement triads to estimate noise
levels.
To compute PSD's, this estimator assumes that measurement samples are obtained
at a constant provided rate equal to
getTimeInterval()
seconds.
If not available, accelerometer sampling rate average can be estimated using
TimeIntervalEstimator
.
Notice that if there are less than getWindowSize()
processed
samples in the window, this estimator will assume that the remaining ones
until the window is completed have zero values.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate double
Contains estimated average of measurement expressed in its default unit (m/s^2 for acceleration, rad/s for angular speed or T for magnetic flux density).static final double
Default time interval between accelerometer samples expressed in seconds (s).static final int
Number of samples to keep within the window by default.private int
Indicates position of first element in window.private int
Indicates position of last element in window.private L
Listener to handle events raised by this estimator.static final int
Minimum allowed window size.private int
Number of added measurement samples.private int
Number of processed measurement samples.private boolean
Indicates whether estimator is running or not.private double
Time interval expressed in seconds (s) between consecutive measurements.private double
Contains estimated variance of measurement expressed in its default squared unit (m^2/s^4 for acceleration, rad^2/s^2 for angular speed or T^2 for magnetic flux density).private double[]
Keeps the window of measurements expressed in their default units.private int
Length of number of samples to keep within the window being processed. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Constructor.protected
WindowedMeasurementNoiseEstimator
(L listener) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addMeasurement
(double value) Adds a measurement value expressed in its default unit (m/s^2 for acceleration, rad/s for angular speed or T for magnetic flux density).void
addMeasurement
(M value) Adds a measurement.void
addMeasurementAndProcess
(double value) Adds a measurement value expressed in its default unit (m/s^2 for acceleration, rad/s for angular speed or T for magnetic flux density) and processes current window.void
addMeasurementAndProcess
(M value) Adds a measurement and processes current window.protected abstract double
convertToDefaultUnit
(M value) Converts provided measurement into default unit.protected abstract M
createMeasurement
(double value, U unit) Creates a measurement with provided value and unit.double
getAvg()
Gets estimated average of measurement expressed in its default unit (m/s^2 for acceleration, rad/s for angular speed or T for magnetic flux density).Gets estimated average of measurement within current window.void
getAvgAsMeasurement
(M result) Gets estimated average of measurement within current window.protected abstract U
Gets default unit for a measurement.Gets first provided measurement within the window.boolean
getFirstWindowedMeasurement
(M result) Gets first provided measurement within the window.Gets first provided measurement value expressed in its default units.Gets last provided measurement within the window.boolean
getLastWindowedMeasurement
(M result) Gets last provided measurement within the window.Gets las provided measurement value expressed in its default units.Gets listener to handle events raised by this estimator.int
Gets number of samples that have been added so far.int
Gets number of samples that have been processed so far.int
Gets number of currently windowed samples.double
getPsd()
Gets measurement noise PSD (Power Spectral Density) expressed in (m^2 * s^-3) for accelerometer, (rad^2/s) for gyroscope or (T^2 * s) for magnetometer.double
Gets measurement noise 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.double
Gets estimated standard deviation of measurement within current window and expressed in its default unit (m/s^2 for acceleration, rad/s for angular speed or T for magnetic flux density).Gets estimated standard deviation of measurement within current window.void
getStandardDeviationAsMeasurement
(M result) Gets estimated standard deviation of measurement within current window.double
Gets time interval between accelerometer triad samples expressed in seconds (s).com.irurueta.units.Time
Gets time interval between accelerometer triad samples.void
getTimeIntervalAsTime
(com.irurueta.units.Time result) Gets time interval between accelerometer triad samples.double
Gets estimated variance of measurement within current window expressed in its default squared unit (m^2/s^4 for acceleration, rad^2/s^2 for angular speed or T^2 for magnetic flux density).int
Gets length of number of samples to keep within the window being processed.private void
internalAdd
(double value, boolean process) Internally adds a measurement value and processes current window if indicated.boolean
Indicates whether estimator is currently running or not.boolean
Indicates whether window of samples is filled or not.private void
Processes current windowed samples.boolean
reset()
Resets current estimator.void
setListener
(L listener) Sets listener to handle events raised by this estimator.void
setTimeInterval
(double timeInterval) Sets time interval between accelerometer triad samples expressed in seconds (s).void
setTimeInterval
(com.irurueta.units.Time timeInterval) Sets time interval between accelerometer triad samples.void
setWindowSize
(int windowSize) Sets length of number of samples to keep within the window being processed.
-
Field Details
-
DEFAULT_WINDOW_SIZE
public static final int DEFAULT_WINDOW_SIZENumber of samples to keep within the window by default. For an accelerometer generating 100 samples/second, this is equivalent to 1 second. For an accelerometer generating 50 samples/second, this is equivalent to 2 seconds.- See Also:
-
MIN_WINDOW_SIZE
public static final int MIN_WINDOW_SIZEMinimum allowed window size.- See Also:
-
DEFAULT_TIME_INTERVAL_SECONDS
public static final double DEFAULT_TIME_INTERVAL_SECONDSDefault time interval between accelerometer samples expressed in seconds (s).- See Also:
-
windowSize
private int windowSizeLength of number of samples to keep within the window being processed. Window size must always be larger than allowed minimum value and must have and odd value. -
timeInterval
private double timeIntervalTime interval expressed in seconds (s) between consecutive measurements. -
windowedMeasurements
private double[] windowedMeasurementsKeeps the window of measurements expressed in their default units. (m/s^2 for acceleration, rad/s for angular speed or T for magnetic flux density). -
listener
Listener to handle events raised by this estimator. -
avg
private double avgContains estimated average of measurement expressed in its default unit (m/s^2 for acceleration, rad/s for angular speed or T for magnetic flux density). -
variance
private double varianceContains estimated variance of measurement expressed in its default squared unit (m^2/s^4 for acceleration, rad^2/s^2 for angular speed or T^2 for magnetic flux density). -
firstCursor
private int firstCursorIndicates position of first element in window. -
lastCursor
private int lastCursorIndicates position of last element in window. -
numberOfProcessedSamples
private int numberOfProcessedSamplesNumber of processed measurement samples. -
numberOfAddedSamples
private int numberOfAddedSamplesNumber of added measurement samples. -
running
private boolean runningIndicates whether estimator is running or not.
-
-
Constructor Details
-
WindowedMeasurementNoiseEstimator
protected WindowedMeasurementNoiseEstimator()Constructor. -
WindowedMeasurementNoiseEstimator
Constructor.- Parameters:
listener
- listener to handle events raised by this estimator.
-
-
Method Details
-
getWindowSize
public int getWindowSize()Gets length of number of samples to keep within the window being processed. Window size must always be larger than allowed minimum value and must have and odd value.- 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. Window size must always be larger than allowed minimum value and must have an odd value.- Parameters:
windowSize
- length of number of samples to keep within the window.- Throws:
IllegalArgumentException
- if provided value is not valid.com.irurueta.navigation.LockedException
- if estimator is currently running.
-
getTimeInterval
public double getTimeInterval()Gets time interval between accelerometer triad samples expressed in seconds (s).- Returns:
- time interval between accelerometer triad samples.
-
setTimeInterval
public void setTimeInterval(double timeInterval) throws com.irurueta.navigation.LockedException Sets time interval between accelerometer triad samples expressed in seconds (s).- Parameters:
timeInterval
- time interval between accelerometer triad samples.- Throws:
IllegalArgumentException
- if provided value is negative.com.irurueta.navigation.LockedException
- if estimator is currently running.
-
getTimeIntervalAsTime
public com.irurueta.units.Time getTimeIntervalAsTime()Gets time interval between accelerometer triad samples.- Returns:
- time interval between accelerometer triad samples.
-
getTimeIntervalAsTime
public void getTimeIntervalAsTime(com.irurueta.units.Time result) Gets time interval between accelerometer triad 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 accelerometer triad samples.- Parameters:
timeInterval
- time interval between accelerometer triad samples.- Throws:
com.irurueta.navigation.LockedException
- if estimator is currently running.
-
getListener
Gets listener to handle events raised by this estimator.- Returns:
- listener to handle events raised by this estimator.
-
setListener
Sets listener to handle events raised by this estimator.- Parameters:
listener
- listener to handle events raised by this estimator.- Throws:
com.irurueta.navigation.LockedException
- if this estimator is running.
-
getFirstWindowedMeasurementValue
Gets first provided measurement value expressed in its default units. (m/s^2 for acceleration, rad/s for angular speed or T for magnetic flux density).- Returns:
- first provided measurement value or null if not available.
-
getLastWindowedMeasurementValue
Gets las provided measurement value expressed in its default units. (m/s^2 for acceleration, rad/s for angular speed or T for magnetic flux density).- Returns:
- last provided measurement value or null if not available.
-
getFirstWindowedMeasurement
Gets first provided measurement within the window.- Returns:
- first provided measurement within the window or null if not available.
-
getFirstWindowedMeasurement
Gets first provided measurement within the window.- Parameters:
result
- instance where first provided measurement will be stored.- Returns:
- true if result was updated, false if first measurement is not available.
-
getLastWindowedMeasurement
Gets last provided measurement within the window.- Returns:
- last provided measurement within the window or null if not available.
-
getLastWindowedMeasurement
Gets last provided measurement within the window.- Parameters:
result
- instance where last provided measurement will be stored.- Returns:
- true if result was updated, false if last measurement is not available.
-
getAvg
public double getAvg()Gets estimated average of measurement expressed in its default unit (m/s^2 for acceleration, rad/s for angular speed or T for magnetic flux density).- Returns:
- average of measurement in current window.
-
getAvgAsMeasurement
Gets estimated average of measurement within current window.- Returns:
- average of measurement in current window
-
getAvgAsMeasurement
Gets estimated average of measurement within current window.- Parameters:
result
- instance where average of measurement will be stored.
-
getVariance
public double getVariance()Gets estimated variance of measurement within current window expressed in its default squared unit (m^2/s^4 for acceleration, rad^2/s^2 for angular speed or T^2 for magnetic flux density).- Returns:
- estimated variance of measurement within current window.
-
getStandardDeviation
public double getStandardDeviation()Gets estimated standard deviation of measurement within current window and expressed in its default unit (m/s^2 for acceleration, rad/s for angular speed or T for magnetic flux density).- Returns:
- estimated standard of measurement.
-
getStandardDeviationAsMeasurement
Gets estimated standard deviation of measurement within current window.- Returns:
- estimated standard deviation of measurement.
-
getStandardDeviationAsMeasurement
Gets estimated standard deviation of measurement within current window.- Parameters:
result
- instance where estimated standard deviation of measurement will be stored.
-
getPsd
public double getPsd()Gets measurement noise PSD (Power Spectral Density) expressed in (m^2 * s^-3) for accelerometer, (rad^2/s) for gyroscope or (T^2 * s) for magnetometer.- Returns:
- measurement noise PSD.
-
getRootPsd
public double getRootPsd()Gets measurement noise 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.- Returns:
- measurement noise root PSD.
-
getNumberOfProcessedSamples
public int getNumberOfProcessedSamples()Gets number of samples that have been processed so far.- Returns:
- number of samples that have been processed so far.
-
getNumberOfAddedSamples
public int getNumberOfAddedSamples()Gets number of samples that have been added so far.- Returns:
- number of samples that have been added so far.
-
getNumberOfSamplesInWindow
public int getNumberOfSamplesInWindow()Gets number of currently windowed samples.- Returns:
- number of samples within the window.
-
isWindowFilled
public boolean isWindowFilled()Indicates whether window of samples is filled or not.- Returns:
- true if window is filled, false otherwise.
-
isRunning
public boolean isRunning()Indicates whether estimator is currently running or not.- Returns:
- true if estimator is running, false otherwise.
-
addMeasurementAndProcess
public void addMeasurementAndProcess(double value) throws com.irurueta.navigation.LockedException Adds a measurement value expressed in its default unit (m/s^2 for acceleration, rad/s for angular speed or T for magnetic flux density) and processes current window. Notice that if there are less thangetWindowSize()
processed samples in the window, the remaining ones are considered to be zero when average values and standard deviation is estimated.- Parameters:
value
- value to be added.- Throws:
com.irurueta.navigation.LockedException
- if estimator is currently running.
-
addMeasurementAndProcess
Adds a measurement and processes current window. Notice that if there are less thangetWindowSize()
processed samples in the window, the remaining ones are considered to be zero when average values and standard deviation is estimated.- Parameters:
value
- value to be added.- Throws:
com.irurueta.navigation.LockedException
- if estimator is currently running.
-
addMeasurement
public void addMeasurement(double value) throws com.irurueta.navigation.LockedException Adds a measurement value expressed in its default unit (m/s^2 for acceleration, rad/s for angular speed or T for magnetic flux density). Notice that if there are less thangetWindowSize()
processed samples in the window, the remaining ones are considered to be zero when average values and standard deviation is estimated.- Parameters:
value
- value to be added.- Throws:
com.irurueta.navigation.LockedException
- if estimator is currently running.
-
addMeasurement
Adds a measurement. Notice that if there are less thangetWindowSize()
processed samples in the window, the remaining ones are considered to be zero when average values and standard deviation is estimated.- Parameters:
value
- value to be added.- Throws:
com.irurueta.navigation.LockedException
- if estimator is currently running
-
reset
public boolean reset() throws com.irurueta.navigation.LockedExceptionResets current estimator.- Returns:
- true if estimator was successfully reset, false if no reset was needed.
- Throws:
com.irurueta.navigation.LockedException
- if estimator is currently running.
-
getDefaultUnit
Gets default unit for a measurement.- Returns:
- default unit for a measurement.
-
createMeasurement
Creates a measurement with provided value and unit.- Parameters:
value
- value to be set.unit
- unit to be set.- Returns:
- created measurement.
-
convertToDefaultUnit
Converts provided measurement into default unit.- Parameters:
value
- measurement to be converted.- Returns:
- converted value.
-
internalAdd
private void internalAdd(double value, boolean process) throws com.irurueta.navigation.LockedException Internally adds a measurement value and processes current window if indicated.- Parameters:
value
- measurement value to be added.process
- true if window of samples must also be processed, false otherwise.- Throws:
com.irurueta.navigation.LockedException
- if estimator is currently running.
-
processWindow
private void processWindow()Processes current windowed samples.
-