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