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.MagneticFluxDensityTriad;
19  import com.irurueta.navigation.inertial.calibration.TimeIntervalEstimator;
20  import com.irurueta.units.MagneticFluxDensity;
21  import com.irurueta.units.MagneticFluxDensityConverter;
22  import com.irurueta.units.MagneticFluxDensityUnit;
23  
24  /**
25   * Estimates accumulated magnetometer noise variances and PSD's (Power Spectral Densities)
26   * along with their average values.
27   * This estimator must be used when the body where the magnetometer is attached
28   * remains static on the same position and orientation with zero velocity while
29   * capturing data.
30   * To compute PSD's, this estimator assumes that measurement samples are obtained
31   * 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   * This estimator does NOT require the knowledge of current location and body
35   * orientation.
36   * Because body location and orientation is not known, estimated average values
37   * cannot be used to determine biases. Only norm of noise estimations
38   * (variance or standard deviation) can be safely used.
39   * This implementation of noise estimator will use the following units:
40   * - Teslas (T) for magnetic flux density, average or standard deviation values.
41   * - squared Teslas (T^2) for magnetic flux density variances.
42   * - (T^2 * s) for magnetometer PSD (Power Spectral Density).
43   * - (T * s^0.5) for magnetometer root PSD (Power Spectral Density).
44   */
45  public class AccumulatedMagneticFluxDensityTriadNoiseEstimator extends
46          AccumulatedTriadNoiseEstimator<MagneticFluxDensityUnit, MagneticFluxDensity, MagneticFluxDensityTriad,
47                  AccumulatedMagneticFluxDensityTriadNoiseEstimator,
48                  AccumulatedMagneticFluxDensityTriadNoiseEstimatorListener> {
49  
50      /**
51       * Constructor.
52       */
53      public AccumulatedMagneticFluxDensityTriadNoiseEstimator() {
54          super();
55      }
56  
57      /**
58       * Constructor.
59       *
60       * @param listener listener to handle events raised by this estimator.
61       */
62      public AccumulatedMagneticFluxDensityTriadNoiseEstimator(
63              final AccumulatedMagneticFluxDensityTriadNoiseEstimatorListener listener) {
64          super(listener);
65      }
66  
67      /**
68       * Creates a triad with provided values and unit.
69       *
70       * @param valueX x coordinate value.
71       * @param valueY y coordinate value.
72       * @param valueZ z coordinate value.
73       * @param unit   unit.
74       * @return created triad.
75       */
76      @Override
77      protected MagneticFluxDensityTriad createTriad(
78              final double valueX, final double valueY, final double valueZ, final MagneticFluxDensityUnit unit) {
79          return new MagneticFluxDensityTriad(unit, valueX, valueY, valueZ);
80      }
81  
82      /**
83       * Gets default unit for a measurement.
84       *
85       * @return default unit for a measurement.
86       */
87      @Override
88      protected MagneticFluxDensityUnit getDefaultUnit() {
89          return MagneticFluxDensityUnit.TESLA;
90      }
91  
92      /**
93       * Creates a measurement with provided value and unit.
94       *
95       * @param value value to be set.
96       * @param unit  unit to be set.
97       * @return created measurement.
98       */
99      @Override
100     protected MagneticFluxDensity createMeasurement(final double value, final MagneticFluxDensityUnit unit) {
101         return new MagneticFluxDensity(value, unit);
102     }
103 
104     /**
105      * Converts provided value and unit into default unit.
106      *
107      * @param value measurement value to be converted.
108      * @param unit  unit of measurement value to be converted.
109      * @return converted value.
110      */
111     @Override
112     protected double convertToDefaultUnit(final double value, final MagneticFluxDensityUnit unit) {
113         return MagneticFluxDensityConverter.convert(value, unit, getDefaultUnit());
114     }
115 }