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.accelerometer;
17  
18  import com.irurueta.algebra.Matrix;
19  import com.irurueta.navigation.LockedException;
20  import com.irurueta.navigation.NotReadyException;
21  import com.irurueta.navigation.inertial.calibration.CalibrationException;
22  import com.irurueta.navigation.inertial.calibration.StandardDeviationBodyKinematics;
23  import com.irurueta.numerical.robust.PROMedSRobustEstimator;
24  import com.irurueta.numerical.robust.PROMedSRobustEstimatorListener;
25  import com.irurueta.numerical.robust.RobustEstimator;
26  import com.irurueta.numerical.robust.RobustEstimatorException;
27  import com.irurueta.numerical.robust.RobustEstimatorMethod;
28  import com.irurueta.units.Acceleration;
29  
30  import java.util.List;
31  
32  /**
33   * Robustly estimates accelerometer biases, cross couplings and scaling factors
34   * using a PROMedS algorithm to discard outliers.
35   * <p>
36   * To use this calibrator at least 10 measurements taken at a single position
37   * where gravity norm is known must be taken at 10 different unknown
38   * orientations and zero velocity when common z-axis is assumed, otherwise at
39   * least 13 measurements are required.
40   * <p>
41   * Measured specific force is assumed to follow the model shown below:
42   * <pre>
43   *     fmeas = ba + (I + Ma) * ftrue + w
44   * </pre>
45   * Where:
46   * - fmeas is the measured specific force. This is a 3x1 vector.
47   * - ba is accelerometer bias. Ideally, on a perfect accelerometer, this should be a
48   * 3x1 zero vector.
49   * - I is the 3x3 identity matrix.
50   * - Ma is the 3x3 matrix containing cross-couplings and scaling factors. Ideally, on
51   * a perfect accelerometer, this should be a 3x3 zero matrix.
52   * - ftrue is ground-truth specific force.
53   * - w is measurement noise.
54   */
55  public class PROMedSRobustKnownGravityNormAccelerometerCalibrator extends
56          RobustKnownGravityNormAccelerometerCalibrator {
57  
58      /**
59       * Default value to be used for stop threshold. Stop threshold can be used to
60       * avoid keeping the algorithm unnecessarily iterating in case that best
61       * estimated threshold using median of residuals is not small enough. Once a
62       * solution is found that generates a threshold below this value, the
63       * algorithm will stop.
64       * The stop threshold can be used to prevent the LMedS algorithm iterating
65       * too many times in cases where samples have a very similar accuracy.
66       * For instance, in cases where proportion of outliers is very small (close
67       * to 0%), and samples are very accurate (i.e. 1e-6), the algorithm would
68       * iterate for a long time trying to find the best solution when indeed
69       * there is no need to do that if a reasonable threshold has already been
70       * reached.
71       * Because of this behaviour the stop threshold can be set to a value much
72       * lower than the one typically used in RANSAC, and yet the algorithm could
73       * still produce even smaller thresholds in estimated results.
74       */
75      public static final double DEFAULT_STOP_THRESHOLD = 1e-4;
76  
77      /**
78       * Minimum allowed stop threshold value.
79       */
80      public static final double MIN_STOP_THRESHOLD = 0.0;
81  
82      /**
83       * Threshold to be used to keep the algorithm iterating in case that best
84       * estimated threshold using median of residuals is not small enough. Once
85       * a solution is found that generates a threshold below this value, the
86       * algorithm will stop.
87       * The stop threshold can be used to prevent the LMedS algorithm iterating
88       * too many times in cases where samples have a very similar accuracy.
89       * For instance, in cases where proportion of outliers is very small (close
90       * to 0%), and samples are very accurate (i.e. 1e-6), the algorithm would
91       * iterate for a long time trying to find the best solution when indeed
92       * there is no need to do that if a reasonable threshold has already been
93       * reached.
94       * Because of this behaviour the stop threshold can be set to a value much
95       * lower than the one typically used in RANSAC, and yet the algorithm could
96       * still produce even smaller thresholds in estimated results.
97       */
98      private double stopThreshold = DEFAULT_STOP_THRESHOLD;
99  
100     /**
101      * Quality scores corresponding to each provided sample.
102      * The larger the score value the better the quality of the sample.
103      */
104     private double[] qualityScores;
105 
106     /**
107      * Constructor.
108      */
109     public PROMedSRobustKnownGravityNormAccelerometerCalibrator() {
110         super();
111     }
112 
113     /**
114      * Constructor.
115      *
116      * @param listener listener to be notified of events such as when estimation
117      *                 starts, ends or its progress significantly changes.
118      */
119     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
120             final RobustKnownGravityNormAccelerometerCalibratorListener listener) {
121         super(listener);
122     }
123 
124     /**
125      * Constructor.
126      *
127      * @param measurements collection of body kinematics measurements with standard
128      *                     deviations taken at the same position with zero velocity
129      *                     and unknown different orientations.
130      */
131     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
132             final List<StandardDeviationBodyKinematics> measurements) {
133         super(measurements);
134     }
135 
136 
137     /**
138      * Constructor.
139      *
140      * @param commonAxisUsed indicates whether z-axis is assumed to be common for
141      *                       accelerometer and gyroscope.
142      */
143     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(final boolean commonAxisUsed) {
144         super(commonAxisUsed);
145     }
146 
147     /**
148      * Constructor.
149      *
150      * @param initialBias initial accelerometer bias to be used to find a solution.
151      *                    This must have length 3 and is expressed in meters per
152      *                    squared second (m/s^2).
153      * @throws IllegalArgumentException if provided bias array does not have length 3.
154      */
155     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(final double[] initialBias) {
156         super(initialBias);
157     }
158 
159     /**
160      * Constructor.
161      *
162      * @param initialBias initial bias to find a solution.
163      * @throws IllegalArgumentException if provided bias matrix is not 3x1.
164      */
165     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(final Matrix initialBias) {
166         super(initialBias);
167     }
168 
169     /**
170      * Constructor.
171      *
172      * @param initialBias initial bias to find a solution.
173      * @param initialMa   initial scale factors and cross coupling errors matrix.
174      * @throws IllegalArgumentException if either provided bias matrix is not 3x1 or
175      *                                  scaling and coupling error matrix is not 3x3.
176      */
177     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(final Matrix initialBias, final Matrix initialMa) {
178         super(initialBias, initialMa);
179     }
180 
181     /**
182      * Constructor.
183      *
184      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
185      *                               squared second (m/s^2).
186      * @throws IllegalArgumentException if provided gravity norm value is negative.
187      */
188     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(final Double groundTruthGravityNorm) {
189         super(groundTruthGravityNorm);
190     }
191 
192     /**
193      * Constructor.
194      *
195      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
196      *                               squared second (m/s^2).
197      * @param measurements           list of body kinematics measurements taken at a given position with
198      *                               different unknown orientations and containing the standard deviations
199      *                               of accelerometer and gyroscope measurements.
200      * @throws IllegalArgumentException if provided gravity norm value is negative.
201      */
202     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
203             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements) {
204         super(groundTruthGravityNorm, measurements);
205     }
206 
207     /**
208      * Constructor.
209      *
210      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
211      *                               squared second (m/s^2).
212      * @param measurements           list of body kinematics measurements taken at a given position with
213      *                               different unknown orientations and containing the standard deviations
214      *                               of accelerometer and gyroscope measurements.
215      * @param listener               listener to be notified of events such as when estimation
216      *                               starts, ends or its progress significantly changes.
217      * @throws IllegalArgumentException if provided gravity norm value is negative.
218      */
219     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
220             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
221             final RobustKnownGravityNormAccelerometerCalibratorListener listener) {
222         super(groundTruthGravityNorm, measurements, listener);
223     }
224 
225     /**
226      * Constructor.
227      *
228      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
229      *                               squared second (m/s^2).
230      * @param measurements           list of body kinematics measurements taken at a given position with
231      *                               different unknown orientations and containing the standard deviations
232      *                               of accelerometer and gyroscope measurements.
233      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
234      *                               accelerometer and gyroscope.
235      * @throws IllegalArgumentException if provided gravity norm value is negative.
236      */
237     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
238             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
239             final boolean commonAxisUsed) {
240         super(groundTruthGravityNorm, measurements, commonAxisUsed);
241     }
242 
243     /**
244      * Constructor.
245      *
246      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
247      *                               squared second (m/s^2).
248      * @param measurements           list of body kinematics measurements taken at a given position with
249      *                               different unknown orientations and containing the standard deviations
250      *                               of accelerometer and gyroscope measurements.
251      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
252      *                               accelerometer and gyroscope.
253      * @param listener               listener to be notified of events such as when estimation
254      *                               starts, ends or its progress significantly changes.
255      * @throws IllegalArgumentException if provided gravity norm value is negative.
256      */
257     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
258             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
259             final boolean commonAxisUsed, final RobustKnownGravityNormAccelerometerCalibratorListener listener) {
260         super(groundTruthGravityNorm, measurements, commonAxisUsed, listener);
261     }
262 
263     /**
264      * Constructor.
265      *
266      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
267      *                               squared second (m/s^2).
268      * @param measurements           collection of body kinematics measurements with standard
269      *                               deviations taken at the same position with zero velocity
270      *                               and unknown different orientations.
271      * @param initialBias            initial accelerometer bias to be used to find a solution.
272      *                               This must have length 3 and is expressed in meters per
273      *                               squared second (m/s^2).
274      * @throws IllegalArgumentException if provided bias array does not have length 3 or
275      *                                  if provided gravity norm value is negative.
276      */
277     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
278             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
279             final double[] initialBias) {
280         super(groundTruthGravityNorm, measurements, initialBias);
281     }
282 
283     /**
284      * Constructor.
285      *
286      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
287      *                               squared second (m/s^2).
288      * @param measurements           collection of body kinematics measurements with standard
289      *                               deviations taken at the same position with zero velocity
290      *                               and unknown different orientations.
291      * @param initialBias            initial accelerometer bias to be used to find a solution.
292      *                               This must have length 3 and is expressed in meters per
293      *                               squared second (m/s^2).
294      * @param listener               listener to handle events raised by this calibrator.
295      * @throws IllegalArgumentException if provided bias array does not have length 3 or
296      *                                  if provided gravity norm value is negative.
297      */
298     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
299             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
300             final double[] initialBias, final RobustKnownGravityNormAccelerometerCalibratorListener listener) {
301         super(groundTruthGravityNorm, measurements, initialBias, listener);
302     }
303 
304     /**
305      * Constructor.
306      *
307      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
308      *                               squared second (m/s^2).
309      * @param measurements           collection of body kinematics measurements with standard
310      *                               deviations taken at the same position with zero velocity
311      *                               and unknown different orientations.
312      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
313      *                               accelerometer and gyroscope.
314      * @param initialBias            initial accelerometer bias to be used to find a solution.
315      *                               This must have length 3 and is expressed in meters per
316      *                               squared second (m/s^2).
317      * @throws IllegalArgumentException if provided bias array does not have length 3 or
318      *                                  if provided gravity norm value is negative.
319      */
320     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
321             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
322             final boolean commonAxisUsed, final double[] initialBias) {
323         super(groundTruthGravityNorm, measurements, commonAxisUsed, initialBias);
324     }
325 
326     /**
327      * Constructor.
328      *
329      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
330      *                               squared second (m/s^2).
331      * @param measurements           collection of body kinematics measurements with standard
332      *                               deviations taken at the same position with zero velocity
333      *                               and unknown different orientations.
334      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
335      *                               accelerometer and gyroscope.
336      * @param initialBias            initial accelerometer bias to be used to find a solution.
337      *                               This must have length 3 and is expressed in meters per
338      *                               squared second (m/s^2).
339      * @param listener               listener to handle events raised by this calibrator.
340      * @throws IllegalArgumentException if provided bias array does not have length 3 or
341      *                                  if provided gravity norm value is negative.
342      */
343     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
344             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
345             final boolean commonAxisUsed, final double[] initialBias,
346             final RobustKnownGravityNormAccelerometerCalibratorListener listener) {
347         super(groundTruthGravityNorm, measurements, commonAxisUsed, initialBias, listener);
348     }
349 
350     /**
351      * Constructor.
352      *
353      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
354      *                               squared second (m/s^2).
355      * @param measurements           collection of body kinematics measurements with standard
356      *                               deviations taken at the same position with zero velocity
357      *                               and unknown different orientations.
358      * @param initialBias            initial bias to find a solution.
359      * @throws IllegalArgumentException if provided bias matrix is not 3x1 or
360      *                                  if provided gravity norm value is negative.
361      */
362     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
363             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
364             final Matrix initialBias) {
365         super(groundTruthGravityNorm, measurements, initialBias);
366     }
367 
368     /**
369      * Constructor.
370      *
371      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
372      *                               squared second (m/s^2).
373      * @param measurements           collection of body kinematics measurements with standard
374      *                               deviations taken at the same position with zero velocity
375      *                               and unknown different orientations.
376      * @param initialBias            initial bias to find a solution.
377      * @param listener               listener to handle events raised by this calibrator.
378      * @throws IllegalArgumentException if provided bias matrix is not 3x1 or
379      *                                  if provided gravity norm value is negative.
380      */
381     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
382             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
383             final Matrix initialBias, final RobustKnownGravityNormAccelerometerCalibratorListener listener) {
384         super(groundTruthGravityNorm, measurements, initialBias, listener);
385     }
386 
387     /**
388      * Constructor.
389      *
390      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
391      *                               squared second (m/s^2).
392      * @param measurements           collection of body kinematics measurements with standard
393      *                               deviations taken at the same position with zero velocity
394      *                               and unknown different orientations.
395      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
396      *                               accelerometer and gyroscope.
397      * @param initialBias            initial bias to find a solution.
398      * @throws IllegalArgumentException if provided bias matrix is not 3x1 or
399      *                                  if provided gravity norm value is negative.
400      */
401     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
402             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
403             final boolean commonAxisUsed, final Matrix initialBias) {
404         super(groundTruthGravityNorm, measurements, commonAxisUsed, initialBias);
405     }
406 
407     /**
408      * Constructor.
409      *
410      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
411      *                               squared second (m/s^2).
412      * @param measurements           collection of body kinematics measurements with standard
413      *                               deviations taken at the same position with zero velocity
414      *                               and unknown different orientations.
415      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
416      *                               accelerometer and gyroscope.
417      * @param initialBias            initial bias to find a solution.
418      * @param listener               listener to handle events raised by this calibrator.
419      * @throws IllegalArgumentException if provided bias matrix is not 3x1 or
420      *                                  if provided gravity norm value is negative.
421      */
422     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
423             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
424             final boolean commonAxisUsed, final Matrix initialBias,
425             final RobustKnownGravityNormAccelerometerCalibratorListener listener) {
426         super(groundTruthGravityNorm, measurements, commonAxisUsed, initialBias, listener);
427     }
428 
429     /**
430      * Constructor.
431      *
432      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
433      *                               squared second (m/s^2).
434      * @param measurements           collection of body kinematics measurements with standard
435      *                               deviations taken at the same position with zero velocity
436      *                               and unknown different orientations.
437      * @param initialBias            initial bias to find a solution.
438      * @param initialMa              initial scale factors and cross coupling errors matrix.
439      * @throws IllegalArgumentException if either provided bias matrix is not 3x1 or
440      *                                  scaling and coupling error matrix is not 3x3 or
441      *                                  if provided gravity norm value is negative.
442      */
443     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
444             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
445             final Matrix initialBias, final Matrix initialMa) {
446         super(groundTruthGravityNorm, measurements, initialBias, initialMa);
447     }
448 
449     /**
450      * Constructor.
451      *
452      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
453      *                               squared second (m/s^2).
454      * @param measurements           collection of body kinematics measurements with standard
455      *                               deviations taken at the same position with zero velocity
456      *                               and unknown different orientations.
457      * @param initialBias            initial bias to find a solution.
458      * @param initialMa              initial scale factors and cross coupling errors matrix.
459      * @param listener               listener to handle events raised by this calibrator.
460      * @throws IllegalArgumentException if either provided bias matrix is not 3x1 or
461      *                                  scaling and coupling error matrix is not 3x3 or
462      *                                  if provided gravity norm value is negative.
463      */
464     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
465             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
466             final Matrix initialBias, final Matrix initialMa,
467             final RobustKnownGravityNormAccelerometerCalibratorListener listener) {
468         super(groundTruthGravityNorm, measurements, initialBias, initialMa, listener);
469     }
470 
471     /**
472      * Constructor.
473      *
474      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
475      *                               squared second (m/s^2).
476      * @param measurements           collection of body kinematics measurements with standard
477      *                               deviations taken at the same position with zero velocity
478      *                               and unknown different orientations.
479      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
480      *                               accelerometer and gyroscope.
481      * @param initialBias            initial bias to find a solution.
482      * @param initialMa              initial scale factors and cross coupling errors matrix.
483      * @throws IllegalArgumentException if either provided bias matrix is not 3x1 or
484      *                                  scaling and coupling error matrix is not 3x3 or
485      *                                  if provided gravity norm value is negative.
486      */
487     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
488             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
489             final boolean commonAxisUsed, final Matrix initialBias, final Matrix initialMa) {
490         super(groundTruthGravityNorm, measurements, commonAxisUsed, initialBias, initialMa);
491     }
492 
493     /**
494      * Constructor.
495      *
496      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
497      *                               squared second (m/s^2).
498      * @param measurements           collection of body kinematics measurements with standard
499      *                               deviations taken at the same position with zero velocity
500      *                               and unknown different orientations.
501      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
502      *                               accelerometer and gyroscope.
503      * @param initialBias            initial bias to find a solution.
504      * @param initialMa              initial scale factors and cross coupling errors matrix.
505      * @param listener               listener to handle events raised by this calibrator.
506      * @throws IllegalArgumentException if either provided bias matrix is not 3x1 or
507      *                                  scaling and coupling error matrix is not 3x3 or
508      *                                  if provided gravity norm value is negative.
509      */
510     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
511             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
512             final boolean commonAxisUsed, final Matrix initialBias, final Matrix initialMa,
513             final RobustKnownGravityNormAccelerometerCalibratorListener listener) {
514         super(groundTruthGravityNorm, measurements, commonAxisUsed, initialBias, initialMa, listener);
515     }
516 
517     /**
518      * Constructor.
519      *
520      * @param groundTruthGravityNorm ground truth gravity norm.
521      * @throws IllegalArgumentException if provided gravity norm value is negative.
522      */
523     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(final Acceleration groundTruthGravityNorm) {
524         super(groundTruthGravityNorm);
525     }
526 
527     /**
528      * Constructor.
529      *
530      * @param groundTruthGravityNorm ground truth gravity norm.
531      * @param measurements           list of body kinematics measurements taken at a given position with
532      *                               different unknown orientations and containing the standard deviations
533      *                               of accelerometer and gyroscope measurements.
534      * @throws IllegalArgumentException if provided gravity norm value is negative.
535      */
536     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
537             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements) {
538         super(groundTruthGravityNorm, measurements);
539     }
540 
541     /**
542      * Constructor.
543      *
544      * @param groundTruthGravityNorm ground truth gravity norm.
545      * @param measurements           list of body kinematics measurements taken at a given position with
546      *                               different unknown orientations and containing the standard deviations
547      *                               of accelerometer and gyroscope measurements.
548      * @param listener               listener to be notified of events such as when estimation
549      *                               starts, ends or its progress significantly changes.
550      * @throws IllegalArgumentException if provided gravity norm value is negative.
551      */
552     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
553             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
554             final RobustKnownGravityNormAccelerometerCalibratorListener listener) {
555         super(groundTruthGravityNorm, measurements, listener);
556     }
557 
558     /**
559      * Constructor.
560      *
561      * @param groundTruthGravityNorm ground truth gravity norm.
562      * @param measurements           list of body kinematics measurements taken at a given position with
563      *                               different unknown orientations and containing the standard deviations
564      *                               of accelerometer and gyroscope measurements.
565      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
566      *                               accelerometer and gyroscope.
567      * @throws IllegalArgumentException if provided gravity norm value is negative.
568      */
569     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
570             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
571             final boolean commonAxisUsed) {
572         super(groundTruthGravityNorm, measurements, commonAxisUsed);
573     }
574 
575     /**
576      * Constructor.
577      *
578      * @param groundTruthGravityNorm ground truth gravity norm.
579      * @param measurements           list of body kinematics measurements taken at a given position with
580      *                               different unknown orientations and containing the standard deviations
581      *                               of accelerometer and gyroscope measurements.
582      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
583      *                               accelerometer and gyroscope.
584      * @param listener               listener to be notified of events such as when estimation
585      *                               starts, ends or its progress significantly changes.
586      * @throws IllegalArgumentException if provided gravity norm value is negative.
587      */
588     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
589             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
590             final boolean commonAxisUsed, final RobustKnownGravityNormAccelerometerCalibratorListener listener) {
591         super(groundTruthGravityNorm, measurements, commonAxisUsed, listener);
592     }
593 
594     /**
595      * Constructor.
596      *
597      * @param groundTruthGravityNorm ground truth gravity norm.
598      * @param measurements           collection of body kinematics measurements with standard
599      *                               deviations taken at the same position with zero velocity
600      *                               and unknown different orientations.
601      * @param initialBias            initial accelerometer bias to be used to find a solution.
602      *                               This must have length 3 and is expressed in meters per
603      *                               squared second (m/s^2).
604      * @throws IllegalArgumentException if provided bias array does not have length 3 or
605      *                                  if provided gravity norm value is negative.
606      */
607     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
608             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
609             final double[] initialBias) {
610         super(groundTruthGravityNorm, measurements, initialBias);
611     }
612 
613     /**
614      * Constructor.
615      *
616      * @param groundTruthGravityNorm ground truth gravity norm.
617      * @param measurements           collection of body kinematics measurements with standard
618      *                               deviations taken at the same position with zero velocity
619      *                               and unknown different orientations.
620      * @param initialBias            initial accelerometer bias to be used to find a solution.
621      *                               This must have length 3 and is expressed in meters per
622      *                               squared second (m/s^2).
623      * @param listener               listener to handle events raised by this calibrator.
624      * @throws IllegalArgumentException if provided bias array does not have length 3 or
625      *                                  if provided gravity norm value is negative.
626      */
627     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
628             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
629             final double[] initialBias, final RobustKnownGravityNormAccelerometerCalibratorListener listener) {
630         super(groundTruthGravityNorm, measurements, initialBias, listener);
631     }
632 
633     /**
634      * Constructor.
635      *
636      * @param groundTruthGravityNorm ground truth gravity norm.
637      * @param measurements           collection of body kinematics measurements with standard
638      *                               deviations taken at the same position with zero velocity
639      *                               and unknown different orientations.
640      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
641      *                               accelerometer and gyroscope.
642      * @param initialBias            initial accelerometer bias to be used to find a solution.
643      *                               This must have length 3 and is expressed in meters per
644      *                               squared second (m/s^2).
645      * @throws IllegalArgumentException if provided bias array does not have length 3 or
646      *                                  if provided gravity norm value is negative.
647      */
648     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
649             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
650             final boolean commonAxisUsed, final double[] initialBias) {
651         super(groundTruthGravityNorm, measurements, commonAxisUsed, initialBias);
652     }
653 
654     /**
655      * Constructor.
656      *
657      * @param groundTruthGravityNorm ground truth gravity norm.
658      * @param measurements           collection of body kinematics measurements with standard
659      *                               deviations taken at the same position with zero velocity
660      *                               and unknown different orientations.
661      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
662      *                               accelerometer and gyroscope.
663      * @param initialBias            initial accelerometer bias to be used to find a solution.
664      *                               This must have length 3 and is expressed in meters per
665      *                               squared second (m/s^2).
666      * @param listener               listener to handle events raised by this calibrator.
667      * @throws IllegalArgumentException if provided bias array does not have length 3 or
668      *                                  if provided gravity norm value is negative.
669      */
670     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
671             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
672             final boolean commonAxisUsed, final double[] initialBias,
673             final RobustKnownGravityNormAccelerometerCalibratorListener listener) {
674         super(groundTruthGravityNorm, measurements, commonAxisUsed, initialBias, listener);
675     }
676 
677     /**
678      * Constructor.
679      *
680      * @param groundTruthGravityNorm ground truth gravity norm.
681      * @param measurements           collection of body kinematics measurements with standard
682      *                               deviations taken at the same position with zero velocity
683      *                               and unknown different orientations.
684      * @param initialBias            initial bias to find a solution.
685      * @throws IllegalArgumentException if provided bias matrix is not 3x1 or
686      *                                  if provided gravity norm value is negative.
687      */
688     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
689             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
690             final Matrix initialBias) {
691         super(groundTruthGravityNorm, measurements, initialBias);
692     }
693 
694     /**
695      * Constructor.
696      *
697      * @param groundTruthGravityNorm ground truth gravity norm.
698      * @param measurements           collection of body kinematics measurements with standard
699      *                               deviations taken at the same position with zero velocity
700      *                               and unknown different orientations.
701      * @param initialBias            initial bias to find a solution.
702      * @param listener               listener to handle events raised by this calibrator.
703      * @throws IllegalArgumentException if provided bias matrix is not 3x1 or
704      *                                  if provided gravity norm value is negative.
705      */
706     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
707             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
708             final Matrix initialBias, final RobustKnownGravityNormAccelerometerCalibratorListener listener) {
709         super(groundTruthGravityNorm, measurements, initialBias, listener);
710     }
711 
712     /**
713      * Constructor.
714      *
715      * @param groundTruthGravityNorm ground truth gravity norm.
716      * @param measurements           collection of body kinematics measurements with standard
717      *                               deviations taken at the same position with zero velocity
718      *                               and unknown different orientations.
719      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
720      *                               accelerometer and gyroscope.
721      * @param initialBias            initial bias to find a solution.
722      * @throws IllegalArgumentException if provided bias matrix is not 3x1 or
723      *                                  if provided gravity norm value is negative.
724      */
725     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
726             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
727             final boolean commonAxisUsed, final Matrix initialBias) {
728         super(groundTruthGravityNorm, measurements, commonAxisUsed, initialBias);
729     }
730 
731     /**
732      * Constructor.
733      *
734      * @param groundTruthGravityNorm ground truth gravity norm.
735      * @param measurements           collection of body kinematics measurements with standard
736      *                               deviations taken at the same position with zero velocity
737      *                               and unknown different orientations.
738      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
739      *                               accelerometer and gyroscope.
740      * @param initialBias            initial bias to find a solution.
741      * @param listener               listener to handle events raised by this calibrator.
742      * @throws IllegalArgumentException if provided bias matrix is not 3x1 or
743      *                                  if provided gravity norm value is negative.
744      */
745     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
746             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
747             final boolean commonAxisUsed, final Matrix initialBias,
748             final RobustKnownGravityNormAccelerometerCalibratorListener listener) {
749         super(groundTruthGravityNorm, measurements, commonAxisUsed, initialBias, listener);
750     }
751 
752     /**
753      * Constructor.
754      *
755      * @param groundTruthGravityNorm ground truth gravity norm.
756      * @param measurements           collection of body kinematics measurements with standard
757      *                               deviations taken at the same position with zero velocity
758      *                               and unknown different orientations.
759      * @param initialBias            initial bias to find a solution.
760      * @param initialMa              initial scale factors and cross coupling errors matrix.
761      * @throws IllegalArgumentException if either provided bias matrix is not 3x1 or
762      *                                  scaling and coupling error matrix is not 3x3 or
763      *                                  if provided gravity norm value is negative.
764      */
765     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
766             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
767             final Matrix initialBias, final Matrix initialMa) {
768         super(groundTruthGravityNorm, measurements, initialBias, initialMa);
769     }
770 
771     /**
772      * Constructor.
773      *
774      * @param groundTruthGravityNorm ground truth gravity norm.
775      * @param measurements           collection of body kinematics measurements with standard
776      *                               deviations taken at the same position with zero velocity
777      *                               and unknown different orientations.
778      * @param initialBias            initial bias to find a solution.
779      * @param initialMa              initial scale factors and cross coupling errors matrix.
780      * @param listener               listener to handle events raised by this calibrator.
781      * @throws IllegalArgumentException if either provided bias matrix is not 3x1 or
782      *                                  scaling and coupling error matrix is not 3x3 or
783      *                                  if provided gravity norm value is negative.
784      */
785     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
786             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
787             final Matrix initialBias, final Matrix initialMa,
788             final RobustKnownGravityNormAccelerometerCalibratorListener listener) {
789         super(groundTruthGravityNorm, measurements, initialBias, initialMa, listener);
790     }
791 
792     /**
793      * Constructor.
794      *
795      * @param groundTruthGravityNorm ground truth gravity norm.
796      * @param measurements           collection of body kinematics measurements with standard
797      *                               deviations taken at the same position with zero velocity
798      *                               and unknown different orientations.
799      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
800      *                               accelerometer and gyroscope.
801      * @param initialBias            initial bias to find a solution.
802      * @param initialMa              initial scale factors and cross coupling errors matrix.
803      * @throws IllegalArgumentException if either provided bias matrix is not 3x1 or
804      *                                  scaling and coupling error matrix is not 3x3 or
805      *                                  if provided gravity norm value is negative.
806      */
807     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
808             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
809             final boolean commonAxisUsed, final Matrix initialBias, final Matrix initialMa) {
810         super(groundTruthGravityNorm, measurements, commonAxisUsed, initialBias, initialMa);
811     }
812 
813     /**
814      * Constructor.
815      *
816      * @param groundTruthGravityNorm ground truth gravity norm.
817      * @param measurements           collection of body kinematics measurements with standard
818      *                               deviations taken at the same position with zero velocity
819      *                               and unknown different orientations.
820      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
821      *                               accelerometer and gyroscope.
822      * @param initialBias            initial bias to find a solution.
823      * @param initialMa              initial scale factors and cross coupling errors matrix.
824      * @param listener               listener to handle events raised by this calibrator.
825      * @throws IllegalArgumentException if either provided bias matrix is not 3x1 or
826      *                                  scaling and coupling error matrix is not 3x3 or
827      *                                  if provided gravity norm value is negative.
828      */
829     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
830             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
831             final boolean commonAxisUsed, final Matrix initialBias, final Matrix initialMa,
832             final RobustKnownGravityNormAccelerometerCalibratorListener listener) {
833         super(groundTruthGravityNorm, measurements, commonAxisUsed, initialBias, initialMa, listener);
834     }
835 
836     /**
837      * Constructor.
838      *
839      * @param qualityScores          quality scores corresponding to each provided
840      *                               measurement. The larger the score value the better
841      *                               the quality of the sample.
842      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
843      *                               squared second (m/s^2).
844      * @param measurements           list of body kinematics measurements taken at a given position with
845      *                               different unknown orientations and containing the standard deviations
846      *                               of accelerometer and gyroscope measurements.
847      * @throws IllegalArgumentException if provided gravity norm value is negative or
848      *                                  if provided quality scores length is
849      *                                  smaller than 13 samples.
850      */
851     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
852             final double[] qualityScores, final Double groundTruthGravityNorm,
853             final List<StandardDeviationBodyKinematics> measurements) {
854         super(groundTruthGravityNorm, measurements);
855         internalSetQualityScores(qualityScores);
856     }
857 
858     /**
859      * Constructor.
860      *
861      * @param qualityScores          quality scores corresponding to each provided
862      *                               measurement. The larger the score value the better
863      *                               the quality of the sample.
864      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
865      *                               squared second (m/s^2).
866      * @param measurements           list of body kinematics measurements taken at a given position with
867      *                               different unknown orientations and containing the standard deviations
868      *                               of accelerometer and gyroscope measurements.
869      * @param listener               listener to be notified of events such as when estimation
870      *                               starts, ends or its progress significantly changes.
871      * @throws IllegalArgumentException if provided gravity norm value is negative or
872      *                                  if provided quality scores length is
873      *                                  smaller than 13 samples.
874      */
875     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
876             final double[] qualityScores, final Double groundTruthGravityNorm,
877             final List<StandardDeviationBodyKinematics> measurements,
878             final RobustKnownGravityNormAccelerometerCalibratorListener listener) {
879         super(groundTruthGravityNorm, measurements, listener);
880         internalSetQualityScores(qualityScores);
881     }
882 
883     /**
884      * Constructor.
885      *
886      * @param qualityScores          quality scores corresponding to each provided
887      *                               measurement. The larger the score value the better
888      *                               the quality of the sample.
889      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
890      *                               squared second (m/s^2).
891      * @param measurements           list of body kinematics measurements taken at a given position with
892      *                               different unknown orientations and containing the standard deviations
893      *                               of accelerometer and gyroscope measurements.
894      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
895      *                               accelerometer and gyroscope.
896      * @throws IllegalArgumentException if provided gravity norm value is negative or
897      *                                  if provided quality scores length is
898      *                                  smaller than 13 samples.
899      */
900     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
901             final double[] qualityScores, final Double groundTruthGravityNorm,
902             final List<StandardDeviationBodyKinematics> measurements, final boolean commonAxisUsed) {
903         super(groundTruthGravityNorm, measurements, commonAxisUsed);
904         internalSetQualityScores(qualityScores);
905     }
906 
907     /**
908      * Constructor.
909      *
910      * @param qualityScores          quality scores corresponding to each provided
911      *                               measurement. The larger the score value the better
912      *                               the quality of the sample.
913      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
914      *                               squared second (m/s^2).
915      * @param measurements           list of body kinematics measurements taken at a given position with
916      *                               different unknown orientations and containing the standard deviations
917      *                               of accelerometer and gyroscope measurements.
918      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
919      *                               accelerometer and gyroscope.
920      * @param listener               listener to be notified of events such as when estimation
921      *                               starts, ends or its progress significantly changes.
922      * @throws IllegalArgumentException if provided gravity norm value is negative or
923      *                                  if provided quality scores length is
924      *                                  smaller than 13 samples.
925      */
926     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
927             final double[] qualityScores, final Double groundTruthGravityNorm,
928             final List<StandardDeviationBodyKinematics> measurements, final boolean commonAxisUsed,
929             final RobustKnownGravityNormAccelerometerCalibratorListener listener) {
930         super(groundTruthGravityNorm, measurements, commonAxisUsed, listener);
931         internalSetQualityScores(qualityScores);
932     }
933 
934     /**
935      * Constructor.
936      *
937      * @param qualityScores          quality scores corresponding to each provided
938      *                               measurement. The larger the score value the better
939      *                               the quality of the sample.
940      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
941      *                               squared second (m/s^2).
942      * @param measurements           collection of body kinematics measurements with standard
943      *                               deviations taken at the same position with zero velocity
944      *                               and unknown different orientations.
945      * @param initialBias            initial accelerometer bias to be used to find a solution.
946      *                               This must have length 3 and is expressed in meters per
947      *                               squared second (m/s^2).
948      * @throws IllegalArgumentException if provided bias array does not have length 3 or
949      *                                  if provided gravity norm value is negative or
950      *                                  if provided quality scores length is
951      *                                  smaller than 13 samples.
952      */
953     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
954             final double[] qualityScores, final Double groundTruthGravityNorm,
955             final List<StandardDeviationBodyKinematics> measurements, final double[] initialBias) {
956         super(groundTruthGravityNorm, measurements, initialBias);
957         internalSetQualityScores(qualityScores);
958     }
959 
960     /**
961      * Constructor.
962      *
963      * @param qualityScores          quality scores corresponding to each provided
964      *                               measurement. The larger the score value the better
965      *                               the quality of the sample.
966      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
967      *                               squared second (m/s^2).
968      * @param measurements           collection of body kinematics measurements with standard
969      *                               deviations taken at the same position with zero velocity
970      *                               and unknown different orientations.
971      * @param initialBias            initial accelerometer bias to be used to find a solution.
972      *                               This must have length 3 and is expressed in meters per
973      *                               squared second (m/s^2).
974      * @param listener               listener to handle events raised by this calibrator.
975      * @throws IllegalArgumentException if provided bias array does not have length 3 or
976      *                                  if provided gravity norm value is negative or
977      *                                  if provided quality scores length is
978      *                                  smaller than 13 samples.
979      */
980     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
981             final double[] qualityScores, final Double groundTruthGravityNorm,
982             final List<StandardDeviationBodyKinematics> measurements, final double[] initialBias,
983             final RobustKnownGravityNormAccelerometerCalibratorListener listener) {
984         super(groundTruthGravityNorm, measurements, initialBias, listener);
985         internalSetQualityScores(qualityScores);
986     }
987 
988     /**
989      * Constructor.
990      *
991      * @param qualityScores          quality scores corresponding to each provided
992      *                               measurement. The larger the score value the better
993      *                               the quality of the sample.
994      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
995      *                               squared second (m/s^2).
996      * @param measurements           collection of body kinematics measurements with standard
997      *                               deviations taken at the same position with zero velocity
998      *                               and unknown different orientations.
999      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
1000      *                               accelerometer and gyroscope.
1001      * @param initialBias            initial accelerometer bias to be used to find a solution.
1002      *                               This must have length 3 and is expressed in meters per
1003      *                               squared second (m/s^2).
1004      * @throws IllegalArgumentException if provided bias array does not have length 3 or
1005      *                                  if provided gravity norm value is negative or
1006      *                                  if provided quality scores length is
1007      *                                  smaller than 13 samples.
1008      */
1009     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
1010             final double[] qualityScores, final Double groundTruthGravityNorm,
1011             final List<StandardDeviationBodyKinematics> measurements, final boolean commonAxisUsed,
1012             final double[] initialBias) {
1013         super(groundTruthGravityNorm, measurements, commonAxisUsed, initialBias);
1014         internalSetQualityScores(qualityScores);
1015     }
1016 
1017     /**
1018      * Constructor.
1019      *
1020      * @param qualityScores          quality scores corresponding to each provided
1021      *                               measurement. The larger the score value the better
1022      *                               the quality of the sample.
1023      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
1024      *                               squared second (m/s^2).
1025      * @param measurements           collection of body kinematics measurements with standard
1026      *                               deviations taken at the same position with zero velocity
1027      *                               and unknown different orientations.
1028      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
1029      *                               accelerometer and gyroscope.
1030      * @param initialBias            initial accelerometer bias to be used to find a solution.
1031      *                               This must have length 3 and is expressed in meters per
1032      *                               squared second (m/s^2).
1033      * @param listener               listener to handle events raised by this calibrator.
1034      * @throws IllegalArgumentException if provided bias array does not have length 3 or
1035      *                                  if provided gravity norm value is negative or
1036      *                                  if provided quality scores length is
1037      *                                  smaller than 13 samples.
1038      */
1039     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
1040             final double[] qualityScores, final Double groundTruthGravityNorm,
1041             final List<StandardDeviationBodyKinematics> measurements, final boolean commonAxisUsed,
1042             final double[] initialBias, final RobustKnownGravityNormAccelerometerCalibratorListener listener) {
1043         super(groundTruthGravityNorm, measurements, commonAxisUsed, initialBias, listener);
1044         internalSetQualityScores(qualityScores);
1045     }
1046 
1047     /**
1048      * Constructor.
1049      *
1050      * @param qualityScores          quality scores corresponding to each provided
1051      *                               measurement. The larger the score value the better
1052      *                               the quality of the sample.
1053      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
1054      *                               squared second (m/s^2).
1055      * @param measurements           collection of body kinematics measurements with standard
1056      *                               deviations taken at the same position with zero velocity
1057      *                               and unknown different orientations.
1058      * @param initialBias            initial bias to find a solution.
1059      * @throws IllegalArgumentException if provided bias array does not have length 3 or
1060      *                                  if provided gravity norm value is negative or
1061      *                                  if provided quality scores length is
1062      *                                  smaller than 13 samples.
1063      */
1064     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
1065             final double[] qualityScores, final Double groundTruthGravityNorm,
1066             final List<StandardDeviationBodyKinematics> measurements, final Matrix initialBias) {
1067         super(groundTruthGravityNorm, measurements, initialBias);
1068         internalSetQualityScores(qualityScores);
1069     }
1070 
1071     /**
1072      * Constructor.
1073      *
1074      * @param qualityScores          quality scores corresponding to each provided
1075      *                               measurement. The larger the score value the better
1076      *                               the quality of the sample.
1077      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
1078      *                               squared second (m/s^2).
1079      * @param measurements           collection of body kinematics measurements with standard
1080      *                               deviations taken at the same position with zero velocity
1081      *                               and unknown different orientations.
1082      * @param initialBias            initial bias to find a solution.
1083      * @param listener               listener to handle events raised by this calibrator.
1084      * @throws IllegalArgumentException if provided bias matrix is not 3x1 or
1085      *                                  if provided gravity norm value is negative or
1086      *                                  if provided quality scores length is
1087      *                                  smaller than 13 samples.
1088      */
1089     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
1090             final double[] qualityScores, final Double groundTruthGravityNorm,
1091             final List<StandardDeviationBodyKinematics> measurements, final Matrix initialBias,
1092             final RobustKnownGravityNormAccelerometerCalibratorListener listener) {
1093         super(groundTruthGravityNorm, measurements, initialBias, listener);
1094         internalSetQualityScores(qualityScores);
1095     }
1096 
1097     /**
1098      * Constructor.
1099      *
1100      * @param qualityScores          quality scores corresponding to each provided
1101      *                               measurement. The larger the score value the better
1102      *                               the quality of the sample.
1103      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
1104      *                               squared second (m/s^2).
1105      * @param measurements           collection of body kinematics measurements with standard
1106      *                               deviations taken at the same position with zero velocity
1107      *                               and unknown different orientations.
1108      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
1109      *                               accelerometer and gyroscope.
1110      * @param initialBias            initial bias to find a solution.
1111      * @throws IllegalArgumentException if provided bias matrix is not 3x1 or
1112      *                                  if provided gravity norm value is negative or
1113      *                                  if provided quality scores length is
1114      *                                  smaller than 13 samples.
1115      */
1116     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
1117             final double[] qualityScores, final Double groundTruthGravityNorm,
1118             final List<StandardDeviationBodyKinematics> measurements, final boolean commonAxisUsed,
1119             final Matrix initialBias) {
1120         super(groundTruthGravityNorm, measurements, commonAxisUsed, initialBias);
1121         internalSetQualityScores(qualityScores);
1122     }
1123 
1124     /**
1125      * Constructor.
1126      *
1127      * @param qualityScores          quality scores corresponding to each provided
1128      *                               measurement. The larger the score value the better
1129      *                               the quality of the sample.
1130      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
1131      *                               squared second (m/s^2).
1132      * @param measurements           collection of body kinematics measurements with standard
1133      *                               deviations taken at the same position with zero velocity
1134      *                               and unknown different orientations.
1135      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
1136      *                               accelerometer and gyroscope.
1137      * @param initialBias            initial bias to find a solution.
1138      * @param listener               listener to handle events raised by this calibrator.
1139      * @throws IllegalArgumentException if provided bias matrix is not 3x1 or
1140      *                                  if provided gravity norm value is negative or
1141      *                                  if provided quality scores length is
1142      *                                  smaller than 13 samples.
1143      */
1144     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
1145             final double[] qualityScores, final Double groundTruthGravityNorm,
1146             final List<StandardDeviationBodyKinematics> measurements, final boolean commonAxisUsed,
1147             final Matrix initialBias, final RobustKnownGravityNormAccelerometerCalibratorListener listener) {
1148         super(groundTruthGravityNorm, measurements, commonAxisUsed, initialBias, listener);
1149         internalSetQualityScores(qualityScores);
1150     }
1151 
1152     /**
1153      * Constructor.
1154      *
1155      * @param qualityScores          quality scores corresponding to each provided
1156      *                               measurement. The larger the score value the better
1157      *                               the quality of the sample.
1158      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
1159      *                               squared second (m/s^2).
1160      * @param measurements           collection of body kinematics measurements with standard
1161      *                               deviations taken at the same position with zero velocity
1162      *                               and unknown different orientations.
1163      * @param initialBias            initial bias to find a solution.
1164      * @param initialMa              initial scale factors and cross coupling errors matrix.
1165      * @throws IllegalArgumentException if either provided bias matrix is not 3x1 or
1166      *                                  scaling and coupling error matrix is not 3x3 or
1167      *                                  if provided gravity norm value is negative or
1168      *                                  if provided quality scores length is
1169      *                                  smaller than 13 samples.
1170      */
1171     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
1172             final double[] qualityScores, final Double groundTruthGravityNorm,
1173             final List<StandardDeviationBodyKinematics> measurements, final Matrix initialBias,
1174             final Matrix initialMa) {
1175         super(groundTruthGravityNorm, measurements, initialBias, initialMa);
1176         internalSetQualityScores(qualityScores);
1177     }
1178 
1179     /**
1180      * Constructor.
1181      *
1182      * @param qualityScores          quality scores corresponding to each provided
1183      *                               measurement. The larger the score value the better
1184      *                               the quality of the sample.
1185      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
1186      *                               squared second (m/s^2).
1187      * @param measurements           collection of body kinematics measurements with standard
1188      *                               deviations taken at the same position with zero velocity
1189      *                               and unknown different orientations.
1190      * @param initialBias            initial bias to find a solution.
1191      * @param initialMa              initial scale factors and cross coupling errors matrix.
1192      * @param listener               listener to handle events raised by this calibrator.
1193      * @throws IllegalArgumentException if either provided bias matrix is not 3x1 or
1194      *                                  scaling and coupling error matrix is not 3x3 or
1195      *                                  if provided gravity norm value is negative or
1196      *                                  if provided quality scores length is
1197      *                                  smaller than 13 samples.
1198      */
1199     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
1200             final double[] qualityScores, final Double groundTruthGravityNorm,
1201             final List<StandardDeviationBodyKinematics> measurements, final Matrix initialBias, final Matrix initialMa,
1202             final RobustKnownGravityNormAccelerometerCalibratorListener listener) {
1203         super(groundTruthGravityNorm, measurements, initialBias, initialMa, listener);
1204         internalSetQualityScores(qualityScores);
1205     }
1206 
1207     /**
1208      * Constructor.
1209      *
1210      * @param qualityScores          quality scores corresponding to each provided
1211      *                               measurement. The larger the score value the better
1212      *                               the quality of the sample.
1213      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
1214      *                               squared second (m/s^2).
1215      * @param measurements           collection of body kinematics measurements with standard
1216      *                               deviations taken at the same position with zero velocity
1217      *                               and unknown different orientations.
1218      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
1219      *                               accelerometer and gyroscope.
1220      * @param initialBias            initial bias to find a solution.
1221      * @param initialMa              initial scale factors and cross coupling errors matrix.
1222      * @throws IllegalArgumentException if either provided bias matrix is not 3x1 or
1223      *                                  scaling and coupling error matrix is not 3x3 or
1224      *                                  if provided gravity norm value is negative or
1225      *                                  if provided quality scores length is
1226      *                                  smaller than 13 samples.
1227      */
1228     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
1229             final double[] qualityScores, final Double groundTruthGravityNorm,
1230             final List<StandardDeviationBodyKinematics> measurements, final boolean commonAxisUsed,
1231             final Matrix initialBias, final Matrix initialMa) {
1232         super(groundTruthGravityNorm, measurements, commonAxisUsed, initialBias, initialMa);
1233         internalSetQualityScores(qualityScores);
1234     }
1235 
1236     /**
1237      * Constructor.
1238      *
1239      * @param qualityScores          quality scores corresponding to each provided
1240      *                               measurement. The larger the score value the better
1241      *                               the quality of the sample.
1242      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
1243      *                               squared second (m/s^2).
1244      * @param measurements           collection of body kinematics measurements with standard
1245      *                               deviations taken at the same position with zero velocity
1246      *                               and unknown different orientations.
1247      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
1248      *                               accelerometer and gyroscope.
1249      * @param initialBias            initial bias to find a solution.
1250      * @param initialMa              initial scale factors and cross coupling errors matrix.
1251      * @param listener               listener to handle events raised by this calibrator.
1252      * @throws IllegalArgumentException if either provided bias matrix is not 3x1 or
1253      *                                  scaling and coupling error matrix is not 3x3 or
1254      *                                  if provided gravity norm value is negative or
1255      *                                  if provided quality scores length is
1256      *                                  smaller than 13 samples.
1257      */
1258     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
1259             final double[] qualityScores, final Double groundTruthGravityNorm,
1260             final List<StandardDeviationBodyKinematics> measurements, final boolean commonAxisUsed,
1261             final Matrix initialBias, final Matrix initialMa,
1262             final RobustKnownGravityNormAccelerometerCalibratorListener listener) {
1263         super(groundTruthGravityNorm, measurements, commonAxisUsed, initialBias, initialMa, listener);
1264         internalSetQualityScores(qualityScores);
1265     }
1266 
1267     /**
1268      * Constructor.
1269      *
1270      * @param qualityScores          quality scores corresponding to each provided
1271      *                               measurement. The larger the score value the better
1272      *                               the quality of the sample.
1273      * @param groundTruthGravityNorm ground truth gravity norm.
1274      * @throws IllegalArgumentException if provided gravity norm value is negative or
1275      *                                  if provided quality scores length is smaller
1276      *                                  than 13 samples.
1277      */
1278     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
1279             final double[] qualityScores, final Acceleration groundTruthGravityNorm) {
1280         super(groundTruthGravityNorm);
1281         internalSetQualityScores(qualityScores);
1282     }
1283 
1284     /**
1285      * Constructor.
1286      *
1287      * @param qualityScores          quality scores corresponding to each provided
1288      *                               measurement. The larger the score value the better
1289      *                               the quality of the sample.
1290      * @param groundTruthGravityNorm ground truth gravity norm.
1291      * @param measurements           list of body kinematics measurements taken at a given position with
1292      *                               different unknown orientations and containing the standard deviations
1293      *                               of accelerometer and gyroscope measurements.
1294      * @throws IllegalArgumentException if provided gravity norm value is negative or
1295      *                                  if provided quality scores length is smaller
1296      *                                  than 13 samples.
1297      */
1298     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
1299             final double[] qualityScores, final Acceleration groundTruthGravityNorm,
1300             final List<StandardDeviationBodyKinematics> measurements) {
1301         super(groundTruthGravityNorm, measurements);
1302         internalSetQualityScores(qualityScores);
1303     }
1304 
1305     /**
1306      * Constructor.
1307      *
1308      * @param qualityScores          quality scores corresponding to each provided
1309      *                               measurement. The larger the score value the better
1310      *                               the quality of the sample.
1311      * @param groundTruthGravityNorm ground truth gravity norm.
1312      * @param measurements           list of body kinematics measurements taken at a given position with
1313      *                               different unknown orientations and containing the standard deviations
1314      *                               of accelerometer and gyroscope measurements.
1315      * @param listener               listener to be notified of events such as when estimation
1316      *                               starts, ends or its progress significantly changes.
1317      * @throws IllegalArgumentException if provided gravity norm value is negative or
1318      *                                  if provided quality scores length is smaller
1319      *                                  than 13 samples.
1320      */
1321     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
1322             final double[] qualityScores, final Acceleration groundTruthGravityNorm,
1323             final List<StandardDeviationBodyKinematics> measurements,
1324             final RobustKnownGravityNormAccelerometerCalibratorListener listener) {
1325         super(groundTruthGravityNorm, measurements, listener);
1326         internalSetQualityScores(qualityScores);
1327     }
1328 
1329     /**
1330      * Constructor.
1331      *
1332      * @param qualityScores          quality scores corresponding to each provided
1333      *                               measurement. The larger the score value the better
1334      *                               the quality of the sample.
1335      * @param groundTruthGravityNorm ground truth gravity norm.
1336      * @param measurements           list of body kinematics measurements taken at a given position with
1337      *                               different unknown orientations and containing the standard deviations
1338      *                               of accelerometer and gyroscope measurements.
1339      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
1340      *                               accelerometer and gyroscope.
1341      * @throws IllegalArgumentException if provided gravity norm value is negative or
1342      *                                  if provided quality scores length is smaller
1343      *                                  than 13 samples.
1344      */
1345     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
1346             final double[] qualityScores, final Acceleration groundTruthGravityNorm,
1347             final List<StandardDeviationBodyKinematics> measurements, final boolean commonAxisUsed) {
1348         super(groundTruthGravityNorm, measurements, commonAxisUsed);
1349         internalSetQualityScores(qualityScores);
1350     }
1351 
1352     /**
1353      * Constructor.
1354      *
1355      * @param qualityScores          quality scores corresponding to each provided
1356      *                               measurement. The larger the score value the better
1357      *                               the quality of the sample.
1358      * @param groundTruthGravityNorm ground truth gravity norm.
1359      * @param measurements           list of body kinematics measurements taken at a given position with
1360      *                               different unknown orientations and containing the standard deviations
1361      *                               of accelerometer and gyroscope measurements.
1362      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
1363      *                               accelerometer and gyroscope.
1364      * @param listener               listener to be notified of events such as when estimation
1365      *                               starts, ends or its progress significantly changes.
1366      * @throws IllegalArgumentException if provided gravity norm value is negative or
1367      *                                  if provided quality scores length is smaller
1368      *                                  than 13 samples.
1369      */
1370     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
1371             final double[] qualityScores, final Acceleration groundTruthGravityNorm,
1372             final List<StandardDeviationBodyKinematics> measurements, final boolean commonAxisUsed,
1373             final RobustKnownGravityNormAccelerometerCalibratorListener listener) {
1374         super(groundTruthGravityNorm, measurements, commonAxisUsed, listener);
1375         internalSetQualityScores(qualityScores);
1376     }
1377 
1378     /**
1379      * Constructor.
1380      *
1381      * @param qualityScores          quality scores corresponding to each provided
1382      *                               measurement. The larger the score value the better
1383      *                               the quality of the sample.
1384      * @param groundTruthGravityNorm ground truth gravity norm.
1385      * @param measurements           collection of body kinematics measurements with standard
1386      *                               deviations taken at the same position with zero velocity
1387      *                               and unknown different orientations.
1388      * @param initialBias            initial accelerometer bias to be used to find a solution.
1389      *                               This must have length 3 and is expressed in meters per
1390      *                               squared second (m/s^2).
1391      * @throws IllegalArgumentException if provided bias array does not have length 3 or
1392      *                                  if provided gravity norm value is negative or
1393      *                                  if provided quality scores length is smaller
1394      *                                  than 13 samples.
1395      */
1396     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
1397             final double[] qualityScores, final Acceleration groundTruthGravityNorm,
1398             final List<StandardDeviationBodyKinematics> measurements, final double[] initialBias) {
1399         super(groundTruthGravityNorm, measurements, initialBias);
1400         internalSetQualityScores(qualityScores);
1401     }
1402 
1403     /**
1404      * Constructor.
1405      *
1406      * @param qualityScores          quality scores corresponding to each provided
1407      *                               measurement. The larger the score value the better
1408      *                               the quality of the sample.
1409      * @param groundTruthGravityNorm ground truth gravity norm.
1410      * @param measurements           collection of body kinematics measurements with standard
1411      *                               deviations taken at the same position with zero velocity
1412      *                               and unknown different orientations.
1413      * @param initialBias            initial accelerometer bias to be used to find a solution.
1414      *                               This must have length 3 and is expressed in meters per
1415      *                               squared second (m/s^2).
1416      * @param listener               listener to handle events raised by this calibrator.
1417      * @throws IllegalArgumentException if provided bias array does not have length 3 or
1418      *                                  if provided gravity norm value is negative or
1419      *                                  if provided quality scores length is smaller
1420      *                                  than 13 samples.
1421      */
1422     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
1423             final double[] qualityScores, final Acceleration groundTruthGravityNorm,
1424             final List<StandardDeviationBodyKinematics> measurements, final double[] initialBias,
1425             final RobustKnownGravityNormAccelerometerCalibratorListener listener) {
1426         super(groundTruthGravityNorm, measurements, initialBias, listener);
1427         internalSetQualityScores(qualityScores);
1428     }
1429 
1430     /**
1431      * Constructor.
1432      *
1433      * @param qualityScores          quality scores corresponding to each provided
1434      *                               measurement. The larger the score value the better
1435      *                               the quality of the sample.
1436      * @param groundTruthGravityNorm ground truth gravity norm.
1437      * @param measurements           collection of body kinematics measurements with standard
1438      *                               deviations taken at the same position with zero velocity
1439      *                               and unknown different orientations.
1440      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
1441      *                               accelerometer and gyroscope.
1442      * @param initialBias            initial accelerometer bias to be used to find a solution.
1443      *                               This must have length 3 and is expressed in meters per
1444      *                               squared second (m/s^2).
1445      * @throws IllegalArgumentException if provided bias array does not have length 3 or
1446      *                                  if provided gravity norm value is negative or
1447      *                                  if provided quality scores length is smaller
1448      *                                  than 13 samples.
1449      */
1450     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
1451             final double[] qualityScores, final Acceleration groundTruthGravityNorm,
1452             final List<StandardDeviationBodyKinematics> measurements, final boolean commonAxisUsed,
1453             final double[] initialBias) {
1454         super(groundTruthGravityNorm, measurements, commonAxisUsed, initialBias);
1455         internalSetQualityScores(qualityScores);
1456     }
1457 
1458     /**
1459      * Constructor.
1460      *
1461      * @param qualityScores          quality scores corresponding to each provided
1462      *                               measurement. The larger the score value the better
1463      *                               the quality of the sample.
1464      * @param groundTruthGravityNorm ground truth gravity norm.
1465      * @param measurements           collection of body kinematics measurements with standard
1466      *                               deviations taken at the same position with zero velocity
1467      *                               and unknown different orientations.
1468      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
1469      *                               accelerometer and gyroscope.
1470      * @param initialBias            initial accelerometer bias to be used to find a solution.
1471      *                               This must have length 3 and is expressed in meters per
1472      *                               squared second (m/s^2).
1473      * @param listener               listener to handle events raised by this calibrator.
1474      * @throws IllegalArgumentException if provided bias array does not have length 3 or
1475      *                                  if provided gravity norm value is negative or
1476      *                                  if provided quality scores length is smaller
1477      *                                  than 13 samples.
1478      */
1479     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
1480             final double[] qualityScores, final Acceleration groundTruthGravityNorm,
1481             final List<StandardDeviationBodyKinematics> measurements, final boolean commonAxisUsed,
1482             final double[] initialBias, final RobustKnownGravityNormAccelerometerCalibratorListener listener) {
1483         super(groundTruthGravityNorm, measurements, commonAxisUsed, initialBias, listener);
1484         internalSetQualityScores(qualityScores);
1485     }
1486 
1487     /**
1488      * Constructor.
1489      *
1490      * @param qualityScores          quality scores corresponding to each provided
1491      *                               measurement. The larger the score value the better
1492      *                               the quality of the sample.
1493      * @param groundTruthGravityNorm ground truth gravity norm.
1494      * @param measurements           collection of body kinematics measurements with standard
1495      *                               deviations taken at the same position with zero velocity
1496      *                               and unknown different orientations.
1497      * @param initialBias            initial bias to find a solution.
1498      * @throws IllegalArgumentException if provided bias matrix is not 3x1 or
1499      *                                  if provided gravity norm value is negative or
1500      *                                  if provided quality scores length is smaller
1501      *                                  than 13 samples.
1502      */
1503     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
1504             final double[] qualityScores, final Acceleration groundTruthGravityNorm,
1505             final List<StandardDeviationBodyKinematics> measurements, final Matrix initialBias) {
1506         super(groundTruthGravityNorm, measurements, initialBias);
1507         internalSetQualityScores(qualityScores);
1508     }
1509 
1510     /**
1511      * Constructor.
1512      *
1513      * @param qualityScores          quality scores corresponding to each provided
1514      *                               measurement. The larger the score value the better
1515      *                               the quality of the sample.
1516      * @param groundTruthGravityNorm ground truth gravity norm.
1517      * @param measurements           collection of body kinematics measurements with standard
1518      *                               deviations taken at the same position with zero velocity
1519      *                               and unknown different orientations.
1520      * @param initialBias            initial bias to find a solution.
1521      * @param listener               listener to handle events raised by this calibrator.
1522      * @throws IllegalArgumentException if provided bias matrix is not 3x1 or
1523      *                                  if provided gravity norm value is negative or
1524      *                                  if provided quality scores length is smaller
1525      *                                  than 13 samples.
1526      */
1527     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
1528             final double[] qualityScores, final Acceleration groundTruthGravityNorm,
1529             final List<StandardDeviationBodyKinematics> measurements, final Matrix initialBias,
1530             final RobustKnownGravityNormAccelerometerCalibratorListener listener) {
1531         super(groundTruthGravityNorm, measurements, initialBias, listener);
1532         internalSetQualityScores(qualityScores);
1533     }
1534 
1535     /**
1536      * Constructor.
1537      *
1538      * @param qualityScores          quality scores corresponding to each provided
1539      *                               measurement. The larger the score value the better
1540      *                               the quality of the sample.
1541      * @param groundTruthGravityNorm ground truth gravity norm.
1542      * @param measurements           collection of body kinematics measurements with standard
1543      *                               deviations taken at the same position with zero velocity
1544      *                               and unknown different orientations.
1545      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
1546      *                               accelerometer and gyroscope.
1547      * @param initialBias            initial bias to find a solution.
1548      * @throws IllegalArgumentException if provided bias matrix is not 3x1 or
1549      *                                  if provided gravity norm value is negative or
1550      *                                  if provided quality scores length is smaller
1551      *                                  than 13 samples.
1552      */
1553     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
1554             final double[] qualityScores, final Acceleration groundTruthGravityNorm,
1555             final List<StandardDeviationBodyKinematics> measurements, final boolean commonAxisUsed,
1556             final Matrix initialBias) {
1557         super(groundTruthGravityNorm, measurements, commonAxisUsed, initialBias);
1558         internalSetQualityScores(qualityScores);
1559     }
1560 
1561     /**
1562      * Constructor.
1563      *
1564      * @param qualityScores          quality scores corresponding to each provided
1565      *                               measurement. The larger the score value the better
1566      *                               the quality of the sample.
1567      * @param groundTruthGravityNorm ground truth gravity norm.
1568      * @param measurements           collection of body kinematics measurements with standard
1569      *                               deviations taken at the same position with zero velocity
1570      *                               and unknown different orientations.
1571      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
1572      *                               accelerometer and gyroscope.
1573      * @param initialBias            initial bias to find a solution.
1574      * @param listener               listener to handle events raised by this calibrator.
1575      * @throws IllegalArgumentException if provided bias matrix is not 3x1 or
1576      *                                  if provided gravity norm value is negative or
1577      *                                  if provided quality scores length is smaller
1578      *                                  than 13 samples.
1579      */
1580     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
1581             final double[] qualityScores, final Acceleration groundTruthGravityNorm,
1582             final List<StandardDeviationBodyKinematics> measurements, final boolean commonAxisUsed,
1583             final Matrix initialBias, final RobustKnownGravityNormAccelerometerCalibratorListener listener) {
1584         super(groundTruthGravityNorm, measurements, commonAxisUsed, initialBias, listener);
1585         internalSetQualityScores(qualityScores);
1586     }
1587 
1588     /**
1589      * Constructor.
1590      *
1591      * @param qualityScores          quality scores corresponding to each provided
1592      *                               measurement. The larger the score value the better
1593      *                               the quality of the sample.
1594      * @param groundTruthGravityNorm ground truth gravity norm.
1595      * @param measurements           collection of body kinematics measurements with standard
1596      *                               deviations taken at the same position with zero velocity
1597      *                               and unknown different orientations.
1598      * @param initialBias            initial bias to find a solution.
1599      * @param initialMa              initial scale factors and cross coupling errors matrix.
1600      * @throws IllegalArgumentException if either provided bias matrix is not 3x1 or
1601      *                                  scaling and coupling error matrix is not 3x3 or
1602      *                                  if provided gravity norm value is negative or
1603      *                                  if provided quality scores length is smaller
1604      *                                  than 13 samples.
1605      */
1606     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
1607             final double[] qualityScores, final Acceleration groundTruthGravityNorm,
1608             final List<StandardDeviationBodyKinematics> measurements, final Matrix initialBias,
1609             final Matrix initialMa) {
1610         super(groundTruthGravityNorm, measurements, initialBias, initialMa);
1611         internalSetQualityScores(qualityScores);
1612     }
1613 
1614     /**
1615      * Constructor.
1616      *
1617      * @param qualityScores          quality scores corresponding to each provided
1618      *                               measurement. The larger the score value the better
1619      *                               the quality of the sample.
1620      * @param groundTruthGravityNorm ground truth gravity norm.
1621      * @param measurements           collection of body kinematics measurements with standard
1622      *                               deviations taken at the same position with zero velocity
1623      *                               and unknown different orientations.
1624      * @param initialBias            initial bias to find a solution.
1625      * @param initialMa              initial scale factors and cross coupling errors matrix.
1626      * @param listener               listener to handle events raised by this calibrator.
1627      * @throws IllegalArgumentException if either provided bias matrix is not 3x1 or
1628      *                                  scaling and coupling error matrix is not 3x3 or
1629      *                                  if provided gravity norm value is negative or
1630      *                                  if provided quality scores length is smaller
1631      *                                  than 13 samples.
1632      */
1633     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
1634             final double[] qualityScores, final Acceleration groundTruthGravityNorm,
1635             final List<StandardDeviationBodyKinematics> measurements, final Matrix initialBias, final Matrix initialMa,
1636             final RobustKnownGravityNormAccelerometerCalibratorListener listener) {
1637         super(groundTruthGravityNorm, measurements, initialBias, initialMa, listener);
1638         internalSetQualityScores(qualityScores);
1639     }
1640 
1641     /**
1642      * Constructor.
1643      *
1644      * @param qualityScores          quality scores corresponding to each provided
1645      *                               measurement. The larger the score value the better
1646      *                               the quality of the sample.
1647      * @param groundTruthGravityNorm ground truth gravity norm.
1648      * @param measurements           collection of body kinematics measurements with standard
1649      *                               deviations taken at the same position with zero velocity
1650      *                               and unknown different orientations.
1651      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
1652      *                               accelerometer and gyroscope.
1653      * @param initialBias            initial bias to find a solution.
1654      * @param initialMa              initial scale factors and cross coupling errors matrix.
1655      * @throws IllegalArgumentException if either provided bias matrix is not 3x1 or
1656      *                                  scaling and coupling error matrix is not 3x3 or
1657      *                                  if provided gravity norm value is negative or
1658      *                                  if provided quality scores length is smaller
1659      *                                  than 13 samples.
1660      */
1661     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
1662             final double[] qualityScores, final Acceleration groundTruthGravityNorm,
1663             final List<StandardDeviationBodyKinematics> measurements, final boolean commonAxisUsed,
1664             final Matrix initialBias, final Matrix initialMa) {
1665         super(groundTruthGravityNorm, measurements, commonAxisUsed, initialBias, initialMa);
1666         internalSetQualityScores(qualityScores);
1667     }
1668 
1669     /**
1670      * Constructor.
1671      *
1672      * @param qualityScores          quality scores corresponding to each provided
1673      *                               measurement. The larger the score value the better
1674      *                               the quality of the sample.
1675      * @param groundTruthGravityNorm ground truth gravity norm.
1676      * @param measurements           collection of body kinematics measurements with standard
1677      *                               deviations taken at the same position with zero velocity
1678      *                               and unknown different orientations.
1679      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
1680      *                               accelerometer and gyroscope.
1681      * @param initialBias            initial bias to find a solution.
1682      * @param initialMa              initial scale factors and cross coupling errors matrix.
1683      * @param listener               listener to handle events raised by this calibrator.
1684      * @throws IllegalArgumentException if either provided bias matrix is not 3x1 or
1685      *                                  scaling and coupling error matrix is not 3x3 or
1686      *                                  if provided gravity norm value is negative or
1687      *                                  if provided quality scores length is smaller
1688      *                                  than 13 samples.
1689      */
1690     public PROMedSRobustKnownGravityNormAccelerometerCalibrator(
1691             final double[] qualityScores, final Acceleration groundTruthGravityNorm,
1692             final List<StandardDeviationBodyKinematics> measurements, final boolean commonAxisUsed,
1693             final Matrix initialBias, final Matrix initialMa,
1694             final RobustKnownGravityNormAccelerometerCalibratorListener listener) {
1695         super(groundTruthGravityNorm, measurements, commonAxisUsed, initialBias, initialMa, listener);
1696         internalSetQualityScores(qualityScores);
1697     }
1698 
1699     /**
1700      * Returns threshold to be used to keep the algorithm iterating in case that
1701      * best estimated threshold using median of residuals is not small enough.
1702      * Once a solution is found that generates a threshold below this value, the
1703      * algorithm will stop.
1704      * The stop threshold can be used to prevent the LMedS algorithm to iterate
1705      * too many times in cases where samples have a very similar accuracy.
1706      * For instance, in cases where proportion of outliers is very small (close
1707      * to 0%), and samples are very accurate (i.e. 1e-6), the algorithm would
1708      * iterate for a long time trying to find the best solution when indeed
1709      * there is no need to do that if a reasonable threshold has already been
1710      * reached.
1711      * Because of this behaviour the stop threshold can be set to a value much
1712      * lower than the one typically used in RANSAC, and yet the algorithm could
1713      * still produce even smaller thresholds in estimated results.
1714      *
1715      * @return stop threshold to stop the algorithm prematurely when a certain
1716      * accuracy has been reached.
1717      */
1718     public double getStopThreshold() {
1719         return stopThreshold;
1720     }
1721 
1722     /**
1723      * Sets threshold to be used to keep the algorithm iterating in case that
1724      * best estimated threshold using median of residuals is not small enough.
1725      * Once a solution is found that generates a threshold below this value,
1726      * the algorithm will stop.
1727      * The stop threshold can be used to prevent the LMedS algorithm to iterate
1728      * too many times in cases where samples have a very similar accuracy.
1729      * For instance, in cases where proportion of outliers is very small (close
1730      * to 0%), and samples are very accurate (i.e. 1e-6), the algorithm would
1731      * iterate for a long time trying to find the best solution when indeed
1732      * there is no need to do that if a reasonable threshold has already been
1733      * reached.
1734      * Because of this behaviour the stop threshold can be set to a value much
1735      * lower than the one typically used in RANSAC, and yet the algorithm could
1736      * still produce even smaller thresholds in estimated results.
1737      *
1738      * @param stopThreshold stop threshold to stop the algorithm prematurely
1739      *                      when a certain accuracy has been reached.
1740      * @throws IllegalArgumentException if provided value is zero or negative.
1741      * @throws LockedException          if calibrator is currently running.
1742      */
1743     public void setStopThreshold(final double stopThreshold) throws LockedException {
1744         if (running) {
1745             throw new LockedException();
1746         }
1747         if (stopThreshold <= MIN_STOP_THRESHOLD) {
1748             throw new IllegalArgumentException();
1749         }
1750 
1751         this.stopThreshold = stopThreshold;
1752     }
1753 
1754     /**
1755      * Returns quality scores corresponding to each provided sample.
1756      * The larger the score value the better the quality of the sample.
1757      *
1758      * @return quality scores corresponding to each sample.
1759      */
1760     @Override
1761     public double[] getQualityScores() {
1762         return qualityScores;
1763     }
1764 
1765     /**
1766      * Sets quality scores corresponding to each provided sample.
1767      * The larger the score value the better the quality of the sample.
1768      *
1769      * @param qualityScores quality scores corresponding to each sample.
1770      * @throws IllegalArgumentException if provided quality scores length
1771      *                                  is smaller than minimum required samples
1772      *                                  (10 or 13).
1773      * @throws LockedException          if calibrator is currently running.
1774      */
1775     @Override
1776     public void setQualityScores(final double[] qualityScores) throws LockedException {
1777         if (running) {
1778             throw new LockedException();
1779         }
1780         internalSetQualityScores(qualityScores);
1781     }
1782 
1783     /**
1784      * Indicates whether solver is ready to find a solution.
1785      *
1786      * @return true if solver is ready, false otherwise.
1787      */
1788     @Override
1789     public boolean isReady() {
1790         return super.isReady() && qualityScores != null && qualityScores.length == measurements.size();
1791     }
1792 
1793     /**
1794      * Estimates accelerometer calibration parameters containing bias, scale factors
1795      * and cross-coupling errors.
1796      *
1797      * @throws LockedException      if calibrator is currently running.
1798      * @throws NotReadyException    if calibrator is not ready.
1799      * @throws CalibrationException if estimation fails for numerical reasons.
1800      */
1801     @Override
1802     public void calibrate() throws LockedException, NotReadyException, CalibrationException {
1803         if (running) {
1804             throw new LockedException();
1805         }
1806         if (!isReady()) {
1807             throw new NotReadyException();
1808         }
1809 
1810         final var innerEstimator = new PROMedSRobustEstimator<>(
1811                 new PROMedSRobustEstimatorListener<PreliminaryResult>() {
1812                     @Override
1813                     public double[] getQualityScores() {
1814                         return qualityScores;
1815                     }
1816 
1817                     @Override
1818                     public double getThreshold() {
1819                         return stopThreshold;
1820                     }
1821 
1822                     @Override
1823                     public int getTotalSamples() {
1824                         return measurements.size();
1825                     }
1826 
1827                     @Override
1828                     public int getSubsetSize() {
1829                         return preliminarySubsetSize;
1830                     }
1831 
1832                     @Override
1833                     public void estimatePreliminarSolutions(
1834                             final int[] samplesIndices, final List<PreliminaryResult> solutions) {
1835                         computePreliminarySolutions(samplesIndices, solutions);
1836                     }
1837 
1838                     @Override
1839                     public double computeResidual(final PreliminaryResult currentEstimation, final int i) {
1840                         return computeError(measurements.get(i), currentEstimation);
1841                     }
1842 
1843                     @Override
1844                     public boolean isReady() {
1845                         return PROMedSRobustKnownGravityNormAccelerometerCalibrator.this.isReady();
1846                     }
1847 
1848                     @Override
1849                     public void onEstimateStart(final RobustEstimator<PreliminaryResult> estimator) {
1850                         // no action needed
1851                     }
1852 
1853                     @Override
1854                     public void onEstimateEnd(final RobustEstimator<PreliminaryResult> estimator) {
1855                         // no action needed
1856                     }
1857 
1858                     @Override
1859                     public void onEstimateNextIteration(
1860                             final RobustEstimator<PreliminaryResult> estimator, final int iteration) {
1861                         if (listener != null) {
1862                             listener.onCalibrateNextIteration(
1863                                     PROMedSRobustKnownGravityNormAccelerometerCalibrator.this, iteration);
1864                         }
1865                     }
1866 
1867                     @Override
1868                     public void onEstimateProgressChange(
1869                             final RobustEstimator<PreliminaryResult> estimator, final float progress) {
1870                         if (listener != null) {
1871                             listener.onCalibrateProgressChange(
1872                                     PROMedSRobustKnownGravityNormAccelerometerCalibrator.this, progress);
1873                         }
1874                     }
1875                 });
1876 
1877         try {
1878             running = true;
1879 
1880             if (listener != null) {
1881                 listener.onCalibrateStart(this);
1882             }
1883 
1884             inliersData = null;
1885             innerEstimator.setUseInlierThresholds(true);
1886             innerEstimator.setConfidence(confidence);
1887             innerEstimator.setMaxIterations(maxIterations);
1888             innerEstimator.setProgressDelta(progressDelta);
1889             final var preliminaryResult = innerEstimator.estimate();
1890             inliersData = innerEstimator.getInliersData();
1891 
1892             attemptRefine(preliminaryResult);
1893 
1894             if (listener != null) {
1895                 listener.onCalibrateEnd(this);
1896             }
1897 
1898         } catch (final com.irurueta.numerical.LockedException e) {
1899             throw new LockedException(e);
1900         } catch (final com.irurueta.numerical.NotReadyException e) {
1901             throw new NotReadyException(e);
1902         } catch (final RobustEstimatorException e) {
1903             throw new CalibrationException(e);
1904         } finally {
1905             running = false;
1906         }
1907     }
1908 
1909     /**
1910      * Returns method being used for robust estimation.
1911      *
1912      * @return method being used for robust estimation.
1913      */
1914     @Override
1915     public RobustEstimatorMethod getMethod() {
1916         return RobustEstimatorMethod.PROMEDS;
1917     }
1918 
1919     /**
1920      * Indicates whether this calibrator requires quality scores for each
1921      * measurement or not.
1922      *
1923      * @return true if quality scores are required, false otherwise.
1924      */
1925     @Override
1926     public boolean isQualityScoresRequired() {
1927         return true;
1928     }
1929 
1930     /**
1931      * Sets quality scores corresponding to each provided sample.
1932      * This method is used internally and does not check whether instance is
1933      * locked or not.
1934      *
1935      * @param qualityScores quality scores to be set.
1936      * @throws IllegalArgumentException if provided quality scores length
1937      *                                  is smaller than the minimum required
1938      *                                  number of samples (10 or 13).
1939      */
1940     private void internalSetQualityScores(final double[] qualityScores) {
1941         if (qualityScores == null || qualityScores.length < getMinimumRequiredMeasurements()) {
1942             throw new IllegalArgumentException();
1943         }
1944 
1945         this.qualityScores = qualityScores;
1946     }
1947 }