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