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.AccelerationTriad;
19  import com.irurueta.navigation.inertial.calibration.AccelerometerNoiseRootPsdSource;
20  import com.irurueta.navigation.inertial.calibration.TimeIntervalEstimator;
21  import com.irurueta.units.Acceleration;
22  import com.irurueta.units.AccelerationConverter;
23  import com.irurueta.units.AccelerationUnit;
24  
25  /**
26   * Estimates accumulated acceleration 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 accelerometer is attached
29   * remains static on the same position with zero velocity while 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, accelerometer 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 estimator does NOT require the knowledge of current location and body
40   * orientation.
41   * This implementation of noise estimator will use the following units:
42   * - meters per squared second (m/s^2) for acceleration, average or standard deviation values.
43   * - (m^2/s^4) for acceleration variances.
44   * - (m^2 * s^-3) for accelerometer PSD (Power Spectral Density).
45   * - (m * s^-1.5) for accelerometer root PSD (Power Spectral Density).
46   */
47  public class AccumulatedAccelerationTriadNoiseEstimator extends
48          AccumulatedTriadNoiseEstimator<AccelerationUnit, Acceleration, AccelerationTriad,
49                  AccumulatedAccelerationTriadNoiseEstimator, AccumulatedAccelerationTriadNoiseEstimatorListener>
50          implements AccelerometerNoiseRootPsdSource {
51  
52      /**
53       * Constructor.
54       */
55      public AccumulatedAccelerationTriadNoiseEstimator() {
56          super();
57      }
58  
59      /**
60       * Constructor.
61       *
62       * @param listener listener to handle events raised by this estimator.
63       */
64      public AccumulatedAccelerationTriadNoiseEstimator(
65              final AccumulatedAccelerationTriadNoiseEstimatorListener listener) {
66          super(listener);
67      }
68  
69      /**
70       * Creates a triad with provided values and unit.
71       *
72       * @param valueX x coordinate value.
73       * @param valueY y coordinate value.
74       * @param valueZ z coordinate value.
75       * @param unit   unit.
76       * @return created triad.
77       */
78      @Override
79      protected AccelerationTriad createTriad(
80              final double valueX, final double valueY, final double valueZ, final AccelerationUnit unit) {
81          return new AccelerationTriad(unit, valueX, valueY, valueZ);
82      }
83  
84      /**
85       * Gets default unit for a measurement.
86       *
87       * @return default unit for a measurement.
88       */
89      @Override
90      protected AccelerationUnit getDefaultUnit() {
91          return AccelerationUnit.METERS_PER_SQUARED_SECOND;
92      }
93  
94      /**
95       * Creates a measurement with provided value and unit.
96       *
97       * @param value value to be set.
98       * @param unit  unit to be set.
99       * @return created measurement.
100      */
101     @Override
102     protected Acceleration createMeasurement(final double value, final AccelerationUnit unit) {
103         return new Acceleration(value, unit);
104     }
105 
106     /**
107      * Converts provided value and unit into default unit.
108      *
109      * @param value measurement value to be converted.
110      * @param unit  unit of measurement value to be converted.
111      * @return converted value.
112      */
113     @Override
114     protected double convertToDefaultUnit(final double value, final AccelerationUnit unit) {
115         return AccelerationConverter.convert(value, unit, getDefaultUnit());
116     }
117 
118     /**
119      * Gets accelerometer base noise level root PSD (Power Spectral Density)
120      * expressed in (m * s^-1.5).
121      *
122      * @return accelerometer base noise level root PSD.
123      */
124     @Override
125     public double getAccelerometerBaseNoiseLevelRootPsd() {
126         return getNoiseRootPsdNorm();
127     }
128 }