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 accumulated angular speed noise variances and PSD's (Power Spectral Densities)
26 * along with their average values.
27 * Norms of angular speed triads can be used to estimate noise levels.
28 * This estimator must be used when the body where the gyroscope is attached to
29 * keeps a constant angular speed while capturing data (i.e. when body is static has
30 * a constant overall angular speed due to Earth rotation).
31 * To compute PSD's, this estimator assumes that measurement samples are obtained
32 * at a constant provided rate equal to {@link #getTimeInterval()} seconds.
33 * If not available, gyroscope sampling rate average can be estimated using
34 * {@link TimeIntervalEstimator}.
35 * This estimator does NOT require the knowledge of current location and body
36 * orientation.
37 * This implementation of noise estimator will use the following units:
38 * - radians per second (rad/s) for angular speed, average or standard deviation values.
39 * - (rad^2/s^2) fr angular speed variances.
40 * - (rad^2/s) for gyroscope PSD (Power Spectral Density).
41 * - (rad * s^-0.5) for gyroscope root PSD (Power Spectral Density).
42 */
43 public class AccumulatedAngularSpeedMeasurementNoiseEstimator extends
44 AccumulatedMeasurementNoiseEstimator<AngularSpeedUnit, AngularSpeed,
45 AccumulatedAngularSpeedMeasurementNoiseEstimator,
46 AccumulatedAngularSpeedMeasurementNoiseEstimatorListener> implements GyroscopeNoiseRootPsdSource {
47
48 /**
49 * Constructor.
50 */
51 public AccumulatedAngularSpeedMeasurementNoiseEstimator() {
52 super();
53 }
54
55 /**
56 * Constructor.
57 *
58 * @param listener listener to handle events raised by this estimator.
59 */
60 public AccumulatedAngularSpeedMeasurementNoiseEstimator(
61 final AccumulatedAngularSpeedMeasurementNoiseEstimatorListener listener) {
62 super(listener);
63 }
64
65 /**
66 * Gets default unit for a measurement.
67 *
68 * @return default unit for a measurement.
69 */
70 @Override
71 protected AngularSpeedUnit getDefaultUnit() {
72 return AngularSpeedUnit.RADIANS_PER_SECOND;
73 }
74
75 /**
76 * Creates a measurement with provided value and unit.
77 *
78 * @param value value to be set.
79 * @param unit unit to be set.
80 * @return created measurement.
81 */
82 @Override
83 protected AngularSpeed createMeasurement(final double value, final AngularSpeedUnit unit) {
84 return new AngularSpeed(value, unit);
85 }
86
87 /**
88 * Converts provided measurement into default unit.
89 *
90 * @param value measurement to be converted.
91 * @return converted value.
92 */
93 @Override
94 protected double convertToDefaultUnit(final AngularSpeed value) {
95 return AngularSpeedConverter.convert(value.getValue().doubleValue(), value.getUnit(), getDefaultUnit());
96 }
97
98 /**
99 * Gets gyroscope base noise level root PSD (Power Spectral Density)
100 * expressed in (rad * s^-0.5)
101 *
102 * @return gyroscope base noise level root PSD.
103 */
104 @Override
105 public double getGyroscopeBaseNoiseLevelRootPsd() {
106 return getRootPsd();
107 }
108 }