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