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