1 /*
2 * Copyright (C) 2020 Alberto Irurueta Carro (alberto@irurueta.com)
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package com.irurueta.navigation.inertial.calibration.noise;
17
18 import com.irurueta.navigation.inertial.calibration.GyroscopeNoiseRootPsdSource;
19 import com.irurueta.navigation.inertial.calibration.TimeIntervalEstimator;
20 import com.irurueta.units.AngularSpeed;
21 import com.irurueta.units.AngularSpeedConverter;
22 import com.irurueta.units.AngularSpeedUnit;
23
24 /**
25 * Estimates measurement noise variances and PSD's (Power Spectral Density)
26 * along with angular speed average value for a windowed amount of samples.
27 * This estimator must be used when the body where the gyroscope is attached to
28 * keeps a constant angular speed while capturing data (i.e. when body is static has
29 * a constant overall angular speed due to Earth rotation).
30 * To compute PSD's, this estimator assumes that gyroscope samples are
31 * obtained at a constant provided rate equal to {@link #getTimeInterval()} seconds.
32 * If not available, gyroscope sampling rate average can be estimated using
33 * {@link TimeIntervalEstimator}.
34 * Notice that if there are less than {@link #getWindowSize()} processed
35 * samples in the window, this estimator will assume that the remaining ones
36 * until the window is completed have zero values.
37 * This estimator does NOT require the knowledge of current location and body
38 * orientation.
39 * This implementation of noise estimator will use the following units:
40 * - radians per second (rad/s) for angular speed, average or standard deviation values.
41 * - (rad^2/s^2) fr angular speed variances.
42 * - (rad^2/s) for gyroscope PSD (Power Spectral Density).
43 * - (rad * s^-0.5) for gyroscope root PSD (Power Spectral Density).
44 */
45 public class WindowedAngularSpeedMeasurementNoiseEstimator extends
46 WindowedMeasurementNoiseEstimator<AngularSpeedUnit, AngularSpeed, WindowedAngularSpeedMeasurementNoiseEstimator,
47 WindowedAngularSpeedMeasurementNoiseEstimatorListener> implements GyroscopeNoiseRootPsdSource {
48
49 /**
50 * Constructor.
51 */
52 public WindowedAngularSpeedMeasurementNoiseEstimator() {
53 super();
54 }
55
56 /**
57 * Constructor.
58 *
59 * @param listener listener to handle events raised by this estimator.
60 */
61 public WindowedAngularSpeedMeasurementNoiseEstimator(
62 final WindowedAngularSpeedMeasurementNoiseEstimatorListener listener) {
63 super(listener);
64 }
65
66 /**
67 * Gets default unit for a measurement.
68 *
69 * @return default unit for a measurement.
70 */
71 @Override
72 protected AngularSpeedUnit getDefaultUnit() {
73 return AngularSpeedUnit.RADIANS_PER_SECOND;
74 }
75
76 /**
77 * Creates a measurement with provided value and unit.
78 *
79 * @param value value to be set.
80 * @param unit unit to be set.
81 * @return created measurement.
82 */
83 @Override
84 protected AngularSpeed createMeasurement(final double value, final AngularSpeedUnit unit) {
85 return new AngularSpeed(value, unit);
86 }
87
88 /**
89 * Converts provided measurement into default unit.
90 *
91 * @param value measurement to be converted.
92 * @return converted value.
93 */
94 @Override
95 protected double convertToDefaultUnit(final AngularSpeed value) {
96 return AngularSpeedConverter.convert(value.getValue().doubleValue(), value.getUnit(), getDefaultUnit());
97 }
98
99 /**
100 * Gets gyroscope base noise level root PSD (Power Spectral Density)
101 * expressed in (rad * s^-0.5)
102 *
103 * @return gyroscope base noise level root PSD.
104 */
105 @Override
106 public double getGyroscopeBaseNoiseLevelRootPsd() {
107 return getRootPsd();
108 }
109 }