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.AccelerationUnit;
23
24 /**
25 * Estimates accelerometer noise variances and PSD's (Power Spectral Densities)
26 * along with the accelerometer average values for a windowed amount of samples.
27 * This estimator must be used when the body where the accelerometer is attached
28 * remains static on the same position with zero velocity while capturing data.
29 * To compute PSD's, this estimator assumes that accelerometer samples are
30 * obtained at a constant provided rate equal to {@link #getTimeInterval()} seconds.
31 * If not available, accelerometer 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 * (variance or standard deviation) safely used.
38 * Notice that if there are less than {@link #getWindowSize()} processed
39 * samples in the window, this estimator will assume that the remaining ones
40 * until the window is completed have zero values.
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 WindowedAccelerationTriadNoiseEstimator extends
48 WindowedTriadNoiseEstimator<AccelerationUnit, Acceleration, AccelerationTriad,
49 WindowedAccelerationTriadNoiseEstimator, WindowedAccelerationTriadNoiseEstimatorListener>
50 implements AccelerometerNoiseRootPsdSource {
51
52 /**
53 * Constructor.
54 */
55 public WindowedAccelerationTriadNoiseEstimator() {
56 super();
57 }
58
59 /**
60 * Constructor.
61 *
62 * @param listener listener to handle events raised by this estimator.
63 */
64 public WindowedAccelerationTriadNoiseEstimator(final WindowedAccelerationTriadNoiseEstimatorListener listener) {
65 super(listener);
66 }
67
68 /**
69 * Creates a copy of a triad.
70 *
71 * @param input triad to be copied.
72 * @return copy of a triad.
73 */
74 @Override
75 protected AccelerationTriad copyTriad(final AccelerationTriad input) {
76 return new AccelerationTriad(input);
77 }
78
79 /**
80 * Creates a triad with provided values and unit.
81 *
82 * @param valueX x coordinate value.
83 * @param valueY y coordinate value.
84 * @param valueZ z coordinate value.
85 * @param unit unit.
86 * @return created triad.
87 */
88 @Override
89 protected AccelerationTriad createTriad(
90 final double valueX, final double valueY, final double valueZ, final AccelerationUnit unit) {
91 return new AccelerationTriad(unit, valueX, valueY, valueZ);
92 }
93
94 /**
95 * Creates a triad with provided values.
96 *
97 * @param valueX x coordinate value.
98 * @param valueY y coordinate value.
99 * @param valueZ z coordinate value.
100 * @return created triad.
101 */
102 @Override
103 protected AccelerationTriad createTriad(
104 final Acceleration valueX, final Acceleration valueY, final Acceleration valueZ) {
105 return new AccelerationTriad(valueX, valueY, valueZ);
106 }
107
108 /**
109 * Gets default unit for a measurement.
110 *
111 * @return default unit for a measurement.
112 */
113 @Override
114 protected AccelerationUnit getDefaultUnit() {
115 return AccelerationUnit.METERS_PER_SQUARED_SECOND;
116 }
117
118 /**
119 * Creates a measurement with provided value and unit.
120 *
121 * @param value value to be set.
122 * @param unit unit to be set.
123 * @return created measurement.
124 */
125 @Override
126 protected Acceleration createMeasurement(final double value, final AccelerationUnit unit) {
127 return new Acceleration(value, unit);
128 }
129
130 /**
131 * Gets accelerometer base noise level root PSD (Power Spectral Density)
132 * expressed in (m * s^-1.5).
133 *
134 * @return accelerometer base noise level root PSD.
135 */
136 @Override
137 public double getAccelerometerBaseNoiseLevelRootPsd() {
138 return getNoiseRootPsdNorm();
139 }
140 }