View Javadoc
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.AngularSpeedTriad;
19  import com.irurueta.navigation.inertial.calibration.GyroscopeNoiseRootPsdSource;
20  import com.irurueta.navigation.inertial.calibration.TimeIntervalEstimator;
21  import com.irurueta.units.AngularSpeed;
22  import com.irurueta.units.AngularSpeedUnit;
23  
24  /**
25   * Estimates angular speed noise variances and PSD's (Power Spectral Densities)
26   * along with the gyroscope average values for a windowed amount of samples.
27   * This estimator must be used when the body where the gyroscope is attached
28   * remains static on the same position with zero velocity while capturing data.
29   * To compute PSD's, this estimator assumes that gyroscope samples are
30   * obtained at a constant provided rate equal to {@link #getTimeInterval()} seconds.
31   * If not available, gyroscope sampling rate average can be estimated using
32   * {@link TimeIntervalEstimator}.
33   * This estimator does NOT require the knowledge of current location and body
34   * orientation.
35   * Because body location and orientation is not known, estimated average values
36   * cannot be used to determine biases. Only norm of noise estimations can be
37   * safely used as an indication of variation of overall rotation rate (which is
38   * indicated by norm of estimated average).
39   * Notice that if there are less than {@link #getWindowSize()} processed
40   * samples in the window, this estimator will assume that the remaining ones
41   * until the window is completed have zero values.
42   * This implementation of noise estimator will use the following units:
43   * - radians per second (rad/s) for angular speed, average or standard deviation values.
44   * - (rad^2/s^2) fr angular speed variances.
45   * - (rad^2/s) for gyroscope PSD (Power Spectral Density).
46   * - (rad * s^-0.5) for gyroscope root PSD (Power Spectral Density).
47   */
48  public class WindowedAngularSpeedTriadNoiseEstimator extends
49          WindowedTriadNoiseEstimator<AngularSpeedUnit, AngularSpeed, AngularSpeedTriad,
50                  WindowedAngularSpeedTriadNoiseEstimator, WindowedAngularSpeedTriadNoiseEstimatorListener>
51          implements GyroscopeNoiseRootPsdSource {
52  
53      /**
54       * Constructor.
55       */
56      public WindowedAngularSpeedTriadNoiseEstimator() {
57          super();
58      }
59  
60      /**
61       * Constructor.
62       *
63       * @param listener listener to handle events raised by this estimator.
64       */
65      public WindowedAngularSpeedTriadNoiseEstimator(final WindowedAngularSpeedTriadNoiseEstimatorListener listener) {
66          super(listener);
67      }
68  
69      /**
70       * Creates a copy of a triad.
71       *
72       * @param input triad to be copied.
73       * @return copy of a triad.
74       */
75      @Override
76      protected AngularSpeedTriad copyTriad(final AngularSpeedTriad input) {
77          return new AngularSpeedTriad(input);
78      }
79  
80      /**
81       * Creates a triad with provided values and unit.
82       *
83       * @param valueX x coordinate value.
84       * @param valueY y coordinate value.
85       * @param valueZ z coordinate value.
86       * @param unit   unit.
87       * @return created triad.
88       */
89      @Override
90      protected AngularSpeedTriad createTriad(
91              final double valueX, final double valueY, final double valueZ, final AngularSpeedUnit unit) {
92          return new AngularSpeedTriad(unit, valueX, valueY, valueZ);
93      }
94  
95      /**
96       * Creates a triad with provided values.
97       *
98       * @param valueX x coordinate value.
99       * @param valueY y coordinate value.
100      * @param valueZ z coordinate value.
101      * @return created triad.
102      */
103     @Override
104     protected AngularSpeedTriad createTriad(
105             final AngularSpeed valueX, final AngularSpeed valueY, final AngularSpeed valueZ) {
106         return new AngularSpeedTriad(valueX, valueY, valueZ);
107     }
108 
109     /**
110      * Gets default unit for a measurement.
111      *
112      * @return default unit for a measurement.
113      */
114     @Override
115     protected AngularSpeedUnit getDefaultUnit() {
116         return AngularSpeedUnit.RADIANS_PER_SECOND;
117     }
118 
119     /**
120      * Creates a measurement with provided value and unit.
121      *
122      * @param value value to be set.
123      * @param unit  unit to be set.
124      * @return created measurement.
125      */
126     @Override
127     protected AngularSpeed createMeasurement(final double value, final AngularSpeedUnit unit) {
128         return new AngularSpeed(value, unit);
129     }
130 
131     /**
132      * Gets gyroscope base noise level root PSD (Power Spectral Density)
133      * expressed in (rad * s^-0.5)
134      *
135      * @return gyroscope base noise level root PSD.
136      */
137     @Override
138     public double getGyroscopeBaseNoiseLevelRootPsd() {
139         return getNoiseRootPsdNorm();
140     }
141 }