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