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.AngularSpeedConverter;
23  import com.irurueta.units.AngularSpeedUnit;
24  
25  /**
26   * Estimates accumulated angular speed noise variances and PSD's (Power Spectral Densities)
27   * along with their average values.
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   * Because body location and orientation is not known, estimated average values
38   * cannot be used to determine biases. Only norm of noise estimations
39   * (variance or standard deviation) can be safely used.
40   * This implementation of noise estimator will use the following units:
41   * - radians per second (rad/s) for angular speed, average or standard deviation values.
42   * - (rad^2/s^2) fr angular speed variances.
43   * - (rad^2/s) for gyroscope PSD (Power Spectral Density).
44   * - (rad * s^-0.5) for gyroscope root PSD (Power Spectral Density).
45   */
46  public class AccumulatedAngularSpeedTriadNoiseEstimator extends
47          AccumulatedTriadNoiseEstimator<AngularSpeedUnit, AngularSpeed, AngularSpeedTriad,
48                  AccumulatedAngularSpeedTriadNoiseEstimator, AccumulatedAngularSpeedTriadNoiseEstimatorListener>
49          implements GyroscopeNoiseRootPsdSource {
50  
51      /**
52       * Constructor.
53       */
54      public AccumulatedAngularSpeedTriadNoiseEstimator() {
55          super();
56      }
57  
58      /**
59       * Constructor.
60       *
61       * @param listener listener to handle events raised by this estimator.
62       */
63      public AccumulatedAngularSpeedTriadNoiseEstimator(
64              final AccumulatedAngularSpeedTriadNoiseEstimatorListener listener) {
65          super(listener);
66      }
67  
68      /**
69       * Creates a triad with provided values and unit.
70       *
71       * @param valueX x coordinate value.
72       * @param valueY y coordinate value.
73       * @param valueZ z coordinate value.
74       * @param unit   unit.
75       * @return created triad.
76       */
77      @Override
78      protected AngularSpeedTriad createTriad(
79              final double valueX, final double valueY, final double valueZ, final AngularSpeedUnit unit) {
80          return new AngularSpeedTriad(unit, valueX, valueY, valueZ);
81      }
82  
83      /**
84       * Gets default unit for a measurement.
85       *
86       * @return default unit for a measurement.
87       */
88      @Override
89      protected AngularSpeedUnit getDefaultUnit() {
90          return AngularSpeedUnit.RADIANS_PER_SECOND;
91      }
92  
93      /**
94       * Creates a measurement with provided value and unit.
95       *
96       * @param value value to be set.
97       * @param unit  unit to be set.
98       * @return created measurement.
99       */
100     @Override
101     protected AngularSpeed createMeasurement(final double value, final AngularSpeedUnit unit) {
102         return new AngularSpeed(value, unit);
103     }
104 
105     /**
106      * Converts provided value and unit into default unit.
107      *
108      * @param value measurement value to be converted.
109      * @param unit  unit of measurement value to be converted.
110      * @return converted value.
111      */
112     @Override
113     protected double convertToDefaultUnit(final double value, final AngularSpeedUnit unit) {
114         return AngularSpeedConverter.convert(value, unit, getDefaultUnit());
115     }
116 
117     /**
118      * Gets gyroscope base noise level root PSD (Power Spectral Density)
119      * expressed in (rad * s^-0.5)
120      *
121      * @return gyroscope base noise level root PSD.
122      */
123     @Override
124     public double getGyroscopeBaseNoiseLevelRootPsd() {
125         return getNoiseRootPsdNorm();
126     }
127 }