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 cross couplings and scaling factors using
33   * PROSAC algorithm.
34   * <p>
35   * To use this calibrator at least 7 measurements with known magnetic field norm at
36   * an unknown position and instant must be taken at 7 different unknown orientations
37   * when common z-axis is assumed, otherwise at least 10
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 PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator extends
59          RobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator {
60  
61  
62      /**
63       * Constant defining default threshold to determine whether samples are inliers or not.
64       */
65      public static final double DEFAULT_THRESHOLD = 1e-9;
66  
67      /**
68       * Minimum value that can be set as threshold.
69       * Threshold must be strictly greater than 0.0.
70       */
71      public static final double MIN_THRESHOLD = 0.0;
72  
73      /**
74       * Indicates that by default inliers will only be computed but not kept.
75       */
76      public static final boolean DEFAULT_COMPUTE_AND_KEEP_INLIERS = false;
77  
78      /**
79       * Indicates that by default residuals will only be computed but not kept.
80       */
81      public static final boolean DEFAULT_COMPUTE_AND_KEEP_RESIDUALS = false;
82  
83      /**
84       * Threshold to determine whether samples are inliers or not when testing possible solutions.
85       * The threshold refers to the amount of error on distance between estimated position and
86       * distances provided for each sample.
87       */
88      private double threshold = DEFAULT_THRESHOLD;
89  
90      /**
91       * Indicates whether inliers must be computed and kept.
92       */
93      private boolean computeAndKeepInliers = DEFAULT_COMPUTE_AND_KEEP_INLIERS;
94  
95      /**
96       * Indicates whether residuals must be computed and kept.
97       */
98      private boolean computeAndKeepResiduals = DEFAULT_COMPUTE_AND_KEEP_RESIDUALS;
99  
100     /**
101      * Quality scores corresponding to each provided sample.
102      * The larger the score value the better the quality of the sample.
103      */
104     private double[] qualityScores;
105 
106     /**
107      * Constructor.
108      */
109     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator() {
110         super();
111     }
112 
113     /**
114      * Constructor.
115      *
116      * @param listener listener to handle events raised by this calibrator.
117      */
118     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
119             final RobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibratorListener 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 PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
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 PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(final boolean commonAxisUsed) {
144         super(commonAxisUsed);
145     }
146 
147     /**
148      * Constructor.
149      *
150      * @param hardIron known hard-iron.
151      * @throws IllegalArgumentException if provided hard-iron array does
152      *                                  not have length 3.
153      */
154     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(final double[] hardIron) {
155         super(hardIron);
156     }
157 
158     /**
159      * Constructor.
160      *
161      * @param hardIron known hard-iron.
162      * @throws IllegalArgumentException if provided hard-iron matrix is not
163      *                                  3x1.
164      */
165     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(final Matrix hardIron) {
166         super(hardIron);
167     }
168 
169     /**
170      * Constructor.
171      *
172      * @param hardIron  known hard-iron.
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 PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
180             final Matrix hardIron, final Matrix initialMm) {
181         super(hardIron, 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 PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
195             final List<StandardDeviationBodyMagneticFluxDensity> measurements,
196             final RobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibratorListener 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 PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
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 PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
229             final List<StandardDeviationBodyMagneticFluxDensity> measurements, final boolean commonAxisUsed,
230             final RobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibratorListener 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 hardIron     known hard-iron.
243      * @throws IllegalArgumentException if provided hard-iron array does
244      *                                  not have length 3.
245      */
246     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
247             final List<StandardDeviationBodyMagneticFluxDensity> measurements, final double[] hardIron) {
248         super(measurements, hardIron);
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 hardIron     known hard-iron.
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 PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
265             final List<StandardDeviationBodyMagneticFluxDensity> measurements, final double[] hardIron,
266             final RobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibratorListener listener) {
267         super(measurements, hardIron, 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 hardIron       known hard-iron.
281      * @throws IllegalArgumentException if provided hard-iron array does
282      *                                  not have length 3.
283      */
284     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
285             final List<StandardDeviationBodyMagneticFluxDensity> measurements, final boolean commonAxisUsed,
286             final double[] hardIron) {
287         super(measurements, commonAxisUsed, hardIron);
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 hardIron       known hard-iron.
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 PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
306             final List<StandardDeviationBodyMagneticFluxDensity> measurements, final boolean commonAxisUsed,
307             final double[] hardIron,
308             final RobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibratorListener listener) {
309         super(measurements, commonAxisUsed, hardIron, 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 hardIron     known hard-iron.
321      * @throws IllegalArgumentException if provided hard-iron matrix is not
322      *                                  3x1.
323      */
324     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
325             final List<StandardDeviationBodyMagneticFluxDensity> measurements, final Matrix hardIron) {
326         super(measurements, hardIron);
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 hardIron     known 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 PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
343             final List<StandardDeviationBodyMagneticFluxDensity> measurements, final Matrix hardIron,
344             final RobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibratorListener listener) {
345         super(measurements, hardIron, 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 hardIron       known hard-iron.
359      * @throws IllegalArgumentException if provided hard-iron matrix is not
360      *                                  3x1.
361      */
362     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
363             final List<StandardDeviationBodyMagneticFluxDensity> measurements, final boolean commonAxisUsed,
364             final Matrix hardIron) {
365         super(measurements, commonAxisUsed, hardIron);
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 hardIron       known hard-iron.
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 PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
384             final List<StandardDeviationBodyMagneticFluxDensity> measurements, final boolean commonAxisUsed,
385             final Matrix hardIron,
386             final RobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibratorListener listener) {
387         super(measurements, commonAxisUsed, hardIron, 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 hardIron     known hard-iron.
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 PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
406             final List<StandardDeviationBodyMagneticFluxDensity> measurements, final Matrix hardIron,
407             final Matrix initialMm) {
408         super(measurements, hardIron, 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 hardIron     known hard-iron.
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 PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
428             final List<StandardDeviationBodyMagneticFluxDensity> measurements, final Matrix hardIron,
429             final Matrix initialMm,
430             final RobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibratorListener listener) {
431         super(measurements, hardIron, initialMm, listener);
432     }
433 
434     /**
435      * Constructor.
436      *
437      * @param measurements   collection of body magnetic flux density
438      *                       measurements with standard deviation of
439      *                       magnetometer measurements taken at the same
440      *                       position with zero velocity and unknown different
441      *                       orientations.
442      * @param commonAxisUsed indicates whether z-axis is assumed to be common
443      *                       for the accelerometer, gyroscope and magnetometer.
444      * @param hardIron       known hard-iron.
445      * @param initialMm      initial soft-iron matrix containing scale factors
446      *                       and cross coupling errors.
447      * @throws IllegalArgumentException if provided hard-iron matrix is not
448      *                                  3x1 or if soft-iron matrix is not
449      *                                  3x3.
450      */
451     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
452             final List<StandardDeviationBodyMagneticFluxDensity> measurements, final boolean commonAxisUsed,
453             final Matrix hardIron, final Matrix initialMm) {
454         super(measurements, commonAxisUsed, hardIron, initialMm);
455     }
456 
457     /**
458      * Constructor.
459      *
460      * @param measurements   collection of body magnetic flux density
461      *                       measurements with standard deviation of
462      *                       magnetometer measurements taken at the same
463      *                       position with zero velocity and unknown different
464      *                       orientations.
465      * @param commonAxisUsed indicates whether z-axis is assumed to be common
466      *                       for the accelerometer, gyroscope and magnetometer.
467      * @param hardIron       known hard-iron.
468      * @param initialMm      initial soft-iron matrix containing scale factors
469      *                       and cross coupling errors.
470      * @param listener       listener to handle events raised by this calibrator.
471      * @throws IllegalArgumentException if provided hard-iron matrix is not
472      *                                  3x1 or if soft-iron matrix is not
473      *                                  3x3.
474      */
475     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
476             final List<StandardDeviationBodyMagneticFluxDensity> measurements, final boolean commonAxisUsed,
477             final Matrix hardIron, final Matrix initialMm,
478             final RobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibratorListener listener) {
479         super(measurements, commonAxisUsed, hardIron, initialMm, listener);
480     }
481 
482     /**
483      * Constructor.
484      *
485      * @param groundTruthMagneticFluxDensityNorm ground truth magnetic flux density norm expressed in Teslas (T).
486      * @throws IllegalArgumentException if provided magnetic flux norm value is negative.
487      */
488     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
489             final Double groundTruthMagneticFluxDensityNorm) {
490         super(groundTruthMagneticFluxDensityNorm);
491     }
492 
493     /**
494      * Constructor.
495      *
496      * @param groundTruthMagneticFluxDensityNorm ground truth magnetic flux density norm expressed in Teslas (T).
497      * @param listener                           listener to handle events raised by this calibrator.
498      * @throws IllegalArgumentException if provided magnetic flux norm value is negative.
499      */
500     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
501             final Double groundTruthMagneticFluxDensityNorm,
502             final RobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibratorListener listener) {
503         super(groundTruthMagneticFluxDensityNorm, listener);
504     }
505 
506     /**
507      * Constructor.
508      *
509      * @param groundTruthMagneticFluxDensityNorm ground truth magnetic flux density norm expressed in Teslas (T).
510      * @param measurements                       collection of body magnetic flux density
511      *                                           measurements with standard deviation of
512      *                                           magnetometer measurements taken at the same
513      *                                           position with zero velocity and unknown different
514      *                                           orientations.
515      * @throws IllegalArgumentException if provided magnetic flux norm value is negative.
516      */
517     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
518             final Double groundTruthMagneticFluxDensityNorm,
519             final List<StandardDeviationBodyMagneticFluxDensity> measurements) {
520         super(groundTruthMagneticFluxDensityNorm, measurements);
521     }
522 
523     /**
524      * Constructor.
525      *
526      * @param groundTruthMagneticFluxDensityNorm ground truth magnetic flux density norm expressed in Teslas (T).
527      * @param commonAxisUsed                     indicates whether z-axis is assumed to be common
528      *                                           for the accelerometer, gyroscope and magnetometer.
529      * @throws IllegalArgumentException if provided magnetic flux norm value is negative.
530      */
531     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
532             final Double groundTruthMagneticFluxDensityNorm, final boolean commonAxisUsed) {
533         super(groundTruthMagneticFluxDensityNorm, commonAxisUsed);
534     }
535 
536     /**
537      * Constructor.
538      *
539      * @param groundTruthMagneticFluxDensityNorm ground truth magnetic flux density norm expressed in Teslas (T).
540      * @param hardIron                           known hard-iron.
541      * @throws IllegalArgumentException if provided magnetic flux norm value is
542      *                                  negative, or if provided hard-iron array does
543      *                                  not have length 3.
544      */
545     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
546             final Double groundTruthMagneticFluxDensityNorm, final double[] hardIron) {
547         super(groundTruthMagneticFluxDensityNorm, hardIron);
548     }
549 
550     /**
551      * Constructor.
552      *
553      * @param groundTruthMagneticFluxDensityNorm ground truth magnetic flux density norm expressed in Teslas (T).
554      * @param hardIron                           known hard-iron.
555      * @throws IllegalArgumentException if provided magnetic flux norm value is
556      *                                  negative, or if provided hard-iron matrix is not
557      *                                  3x1.
558      */
559     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
560             final Double groundTruthMagneticFluxDensityNorm, final Matrix hardIron) {
561         super(groundTruthMagneticFluxDensityNorm, hardIron);
562     }
563 
564     /**
565      * Constructor.
566      *
567      * @param groundTruthMagneticFluxDensityNorm ground truth magnetic flux density norm expressed in Teslas (T).
568      * @param hardIron                           known hard-iron.
569      * @param initialMm                          initial soft-iron matrix containing scale factors
570      *                                           and cross coupling errors.
571      * @throws IllegalArgumentException if provided magnetic flux norm value is
572      *                                  negative, or if provided hard-iron matrix is not
573      *                                  3x1 or if soft-iron matrix is not
574      *                                  3x3.
575      */
576     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
577             final Double groundTruthMagneticFluxDensityNorm, final Matrix hardIron, final Matrix initialMm) {
578         super(groundTruthMagneticFluxDensityNorm, hardIron, initialMm);
579     }
580 
581     /**
582      * Constructor.
583      *
584      * @param groundTruthMagneticFluxDensityNorm ground truth magnetic flux density norm expressed in Teslas (T).
585      * @param measurements                       collection of body magnetic flux density
586      *                                           measurements with standard deviation of
587      *                                           magnetometer measurements taken at the same
588      *                                           position with zero velocity and unknown different
589      *                                           orientations.
590      * @param listener                           listener to handle events raised by this calibrator.
591      * @throws IllegalArgumentException if provided magnetic flux norm value is negative.
592      */
593     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
594             final Double groundTruthMagneticFluxDensityNorm,
595             final List<StandardDeviationBodyMagneticFluxDensity> measurements,
596             final RobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibratorListener listener) {
597         super(groundTruthMagneticFluxDensityNorm, measurements, listener);
598     }
599 
600     /**
601      * Constructor.
602      *
603      * @param groundTruthMagneticFluxDensityNorm ground truth magnetic flux density norm expressed in Teslas (T).
604      * @param measurements                       collection of body magnetic flux density
605      *                                           measurements with standard deviation of
606      *                                           magnetometer measurements taken at the same
607      *                                           position with zero velocity and unknown different
608      *                                           orientations.
609      * @param commonAxisUsed                     indicates whether z-axis is assumed to be common
610      *                                           for the accelerometer, gyroscope and magnetometer.
611      * @throws IllegalArgumentException if provided magnetic flux norm value is negative.
612      */
613     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
614             final Double groundTruthMagneticFluxDensityNorm,
615             final List<StandardDeviationBodyMagneticFluxDensity> measurements, final boolean commonAxisUsed) {
616         super(groundTruthMagneticFluxDensityNorm, measurements, commonAxisUsed);
617     }
618 
619     /**
620      * Constructor.
621      *
622      * @param groundTruthMagneticFluxDensityNorm ground truth magnetic flux density norm expressed in Teslas (T).
623      * @param measurements                       collection of body magnetic flux density
624      *                                           measurements with standard deviation of
625      *                                           magnetometer measurements taken at the same
626      *                                           position with zero velocity and unknown different
627      *                                           orientations.
628      * @param commonAxisUsed                     indicates whether z-axis is assumed to be common
629      *                                           for the accelerometer, gyroscope and magnetometer.
630      * @param listener                           listener to handle events raised by this calibrator.
631      * @throws IllegalArgumentException if provided magnetic flux norm value is negative.
632      */
633     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
634             final Double groundTruthMagneticFluxDensityNorm,
635             final List<StandardDeviationBodyMagneticFluxDensity> measurements, final boolean commonAxisUsed,
636             final RobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibratorListener listener) {
637         super(groundTruthMagneticFluxDensityNorm, measurements, commonAxisUsed, listener);
638     }
639 
640     /**
641      * Constructor.
642      *
643      * @param groundTruthMagneticFluxDensityNorm ground truth magnetic flux density norm expressed in Teslas (T).
644      * @param measurements                       collection of body magnetic flux density
645      *                                           measurements with standard deviation of
646      *                                           magnetometer measurements taken at the same
647      *                                           position with zero velocity and unknown different
648      *                                           orientations.
649      * @param hardIron                           known hard-iron.
650      * @throws IllegalArgumentException if provided magnetic flux norm value is negative,
651      *                                  or if provided hard-iron array does not have length 3.
652      */
653     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
654             final Double groundTruthMagneticFluxDensityNorm,
655             final List<StandardDeviationBodyMagneticFluxDensity> measurements, final double[] hardIron) {
656         super(groundTruthMagneticFluxDensityNorm, measurements, hardIron);
657     }
658 
659     /**
660      * Constructor.
661      *
662      * @param groundTruthMagneticFluxDensityNorm ground truth magnetic flux density norm expressed in Teslas (T).
663      * @param measurements                       collection of body magnetic flux density
664      *                                           measurements with standard deviation of
665      *                                           magnetometer measurements taken at the same
666      *                                           position with zero velocity and unknown different
667      *                                           orientations.
668      * @param hardIron                           known hard-iron.
669      * @param listener                           listener to handle events raised by this calibrator.
670      * @throws IllegalArgumentException if provided magnetic flux norm value is negative,
671      *                                  or if provided hard-iron array does not have length 3.
672      */
673     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
674             final Double groundTruthMagneticFluxDensityNorm,
675             final List<StandardDeviationBodyMagneticFluxDensity> measurements, final double[] hardIron,
676             final RobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibratorListener listener) {
677         super(groundTruthMagneticFluxDensityNorm, measurements, hardIron, listener);
678     }
679 
680     /**
681      * Constructor.
682      *
683      * @param groundTruthMagneticFluxDensityNorm ground truth magnetic flux density norm expressed in Teslas (T).
684      * @param measurements                       collection of body magnetic flux density
685      *                                           measurements with standard deviation of
686      *                                           magnetometer measurements taken at the same
687      *                                           position with zero velocity and unknown different
688      *                                           orientations.
689      * @param commonAxisUsed                     indicates whether z-axis is assumed to be common
690      *                                           for the accelerometer, gyroscope and magnetometer.
691      * @param hardIron                           known hard-iron.
692      * @throws IllegalArgumentException if provided magnetic flux norm value is negative,
693      *                                  or if provided hard-iron array does not have length 3.
694      */
695     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
696             final Double groundTruthMagneticFluxDensityNorm,
697             final List<StandardDeviationBodyMagneticFluxDensity> measurements, final boolean commonAxisUsed,
698             final double[] hardIron) {
699         super(groundTruthMagneticFluxDensityNorm, measurements, commonAxisUsed, hardIron);
700     }
701 
702     /**
703      * Constructor.
704      *
705      * @param groundTruthMagneticFluxDensityNorm ground truth magnetic flux density norm expressed in Teslas (T).
706      * @param measurements                       collection of body magnetic flux density
707      *                                           measurements with standard deviation of
708      *                                           magnetometer measurements taken at the same
709      *                                           position with zero velocity and unknown different
710      *                                           orientations.
711      * @param commonAxisUsed                     indicates whether z-axis is assumed to be common
712      *                                           for the accelerometer, gyroscope and magnetometer.
713      * @param hardIron                           known hard-iron.
714      * @param listener                           listener to handle events raised by this calibrator.
715      * @throws IllegalArgumentException if provided magnetic flux norm value is negative,
716      *                                  or if provided hard-iron array does not have length 3.
717      */
718     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
719             final Double groundTruthMagneticFluxDensityNorm,
720             final List<StandardDeviationBodyMagneticFluxDensity> measurements, final boolean commonAxisUsed,
721             final double[] hardIron,
722             final RobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibratorListener listener) {
723         super(groundTruthMagneticFluxDensityNorm, measurements, commonAxisUsed, hardIron, listener);
724     }
725 
726     /**
727      * Constructor.
728      *
729      * @param groundTruthMagneticFluxDensityNorm ground truth magnetic flux density norm expressed in Teslas (T).
730      * @param measurements                       collection of body magnetic flux density
731      *                                           measurements with standard deviation of
732      *                                           magnetometer measurements taken at the same
733      *                                           position with zero velocity and unknown different
734      *                                           orientations.
735      * @param hardIron                           known hard-iron.
736      * @throws IllegalArgumentException if provided magnetic flux norm value is negative,
737      *                                  or if provided hard-iron matrix is not 3x1.
738      */
739     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
740             final Double groundTruthMagneticFluxDensityNorm,
741             final List<StandardDeviationBodyMagneticFluxDensity> measurements, final Matrix hardIron) {
742         super(groundTruthMagneticFluxDensityNorm, measurements, hardIron);
743     }
744 
745     /**
746      * Constructor.
747      *
748      * @param groundTruthMagneticFluxDensityNorm ground truth magnetic flux density norm expressed in Teslas (T).
749      * @param measurements                       collection of body magnetic flux density
750      *                                           measurements with standard deviation of
751      *                                           magnetometer measurements taken at the same
752      *                                           position with zero velocity and unknown different
753      *                                           orientations.
754      * @param hardIron                           known hard-iron.
755      * @param listener                           listener to handle events raised by this calibrator.
756      * @throws IllegalArgumentException if provided magnetic flux norm value is negative,
757      *                                  or if provided hard-iron matrix is not 3x1.
758      */
759     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
760             final Double groundTruthMagneticFluxDensityNorm,
761             final List<StandardDeviationBodyMagneticFluxDensity> measurements, final Matrix hardIron,
762             final RobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibratorListener listener) {
763         super(groundTruthMagneticFluxDensityNorm, measurements, hardIron, listener);
764     }
765 
766     /**
767      * Constructor.
768      *
769      * @param groundTruthMagneticFluxDensityNorm ground truth magnetic flux density norm expressed in Teslas (T).
770      * @param measurements                       collection of body magnetic flux density
771      *                                           measurements with standard deviation of
772      *                                           magnetometer measurements taken at the same
773      *                                           position with zero velocity and unknown different
774      *                                           orientations.
775      * @param commonAxisUsed                     indicates whether z-axis is assumed to be common
776      *                                           for the accelerometer, gyroscope and magnetometer.
777      * @param hardIron                           known hard-iron.
778      * @throws IllegalArgumentException if provided magnetic flux norm value is negative,
779      *                                  or if provided hard-iron matrix is not 3x1.
780      */
781     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
782             final Double groundTruthMagneticFluxDensityNorm,
783             final List<StandardDeviationBodyMagneticFluxDensity> measurements, final boolean commonAxisUsed,
784             final Matrix hardIron) {
785         super(groundTruthMagneticFluxDensityNorm, measurements, commonAxisUsed, hardIron);
786     }
787 
788     /**
789      * Constructor.
790      *
791      * @param groundTruthMagneticFluxDensityNorm ground truth magnetic flux density norm expressed in Teslas (T).
792      * @param measurements                       collection of body magnetic flux density
793      *                                           measurements with standard deviation of
794      *                                           magnetometer measurements taken at the same
795      *                                           position with zero velocity and unknown different
796      *                                           orientations.
797      * @param commonAxisUsed                     indicates whether z-axis is assumed to be common
798      *                                           for the accelerometer, gyroscope and magnetometer.
799      * @param hardIron                           known hard-iron.
800      * @param listener                           listener to handle events raised by this calibrator.
801      * @throws IllegalArgumentException if provided magnetic flux norm value is negative,
802      *                                  or if provided hard-iron matrix is not 3x1.
803      */
804     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
805             final Double groundTruthMagneticFluxDensityNorm,
806             final List<StandardDeviationBodyMagneticFluxDensity> measurements, final boolean commonAxisUsed,
807             final Matrix hardIron,
808             final RobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibratorListener listener) {
809         super(groundTruthMagneticFluxDensityNorm, measurements, commonAxisUsed, hardIron, listener);
810     }
811 
812     /**
813      * Constructor.
814      *
815      * @param groundTruthMagneticFluxDensityNorm ground truth magnetic flux density norm expressed in Teslas (T).
816      * @param measurements                       collection of body magnetic flux density
817      *                                           measurements with standard deviation of
818      *                                           magnetometer measurements taken at the same
819      *                                           position with zero velocity and unknown different
820      *                                           orientations.
821      * @param hardIron                           known hard-iron.
822      * @param initialMm                          initial soft-iron matrix containing scale factors
823      *                                           and cross coupling errors.
824      * @throws IllegalArgumentException if provided magnetic flux norm value is negative,
825      *                                  or if provided hard-iron matrix is not 3x1 or if
826      *                                  soft-iron matrix is not 3x3.
827      */
828     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
829             final Double groundTruthMagneticFluxDensityNorm,
830             final List<StandardDeviationBodyMagneticFluxDensity> measurements, final Matrix hardIron,
831             final Matrix initialMm) {
832         super(groundTruthMagneticFluxDensityNorm, measurements, hardIron, initialMm);
833     }
834 
835     /**
836      * Constructor.
837      *
838      * @param groundTruthMagneticFluxDensityNorm ground truth magnetic flux density norm expressed in Teslas (T).
839      * @param measurements                       collection of body magnetic flux density
840      *                                           measurements with standard deviation of
841      *                                           magnetometer measurements taken at the same
842      *                                           position with zero velocity and unknown different
843      *                                           orientations.
844      * @param hardIron                           known hard-iron.
845      * @param initialMm                          initial soft-iron matrix containing scale factors
846      *                                           and cross coupling errors.
847      * @param listener                           listener to handle events raised by this calibrator.
848      * @throws IllegalArgumentException if provided magnetic flux norm value is negative,
849      *                                  or if provided hard-iron matrix is not 3x1 or if
850      *                                  soft-iron matrix is not 3x3.
851      */
852     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
853             final Double groundTruthMagneticFluxDensityNorm,
854             final List<StandardDeviationBodyMagneticFluxDensity> measurements, final Matrix hardIron,
855             final Matrix initialMm,
856             final RobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibratorListener listener) {
857         super(groundTruthMagneticFluxDensityNorm, measurements, hardIron, initialMm, listener);
858     }
859 
860     /**
861      * Constructor.
862      *
863      * @param groundTruthMagneticFluxDensityNorm ground truth magnetic flux density norm expressed in Teslas (T).
864      * @param measurements                       collection of body magnetic flux density
865      *                                           measurements with standard deviation of
866      *                                           magnetometer measurements taken at the same
867      *                                           position with zero velocity and unknown different
868      *                                           orientations.
869      * @param commonAxisUsed                     indicates whether z-axis is assumed to be common
870      *                                           for the accelerometer, gyroscope and magnetometer.
871      * @param hardIron                           known hard-iron.
872      * @param initialMm                          initial soft-iron matrix containing scale factors
873      *                                           and cross coupling errors.
874      * @throws IllegalArgumentException if provided magnetic flux norm value is negative,
875      *                                  or if provided hard-iron matrix is not 3x1
876      *                                  or if soft-iron matrix is not 3x3.
877      */
878     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
879             final Double groundTruthMagneticFluxDensityNorm,
880             final List<StandardDeviationBodyMagneticFluxDensity> measurements, final boolean commonAxisUsed,
881             final Matrix hardIron, final Matrix initialMm) {
882         super(groundTruthMagneticFluxDensityNorm, measurements, commonAxisUsed, hardIron, initialMm);
883     }
884 
885     /**
886      * Constructor.
887      *
888      * @param groundTruthMagneticFluxDensityNorm ground truth magnetic flux density norm expressed in Teslas (T).
889      * @param measurements                       collection of body magnetic flux density
890      *                                           measurements with standard deviation of
891      *                                           magnetometer measurements taken at the same
892      *                                           position with zero velocity and unknown different
893      *                                           orientations.
894      * @param commonAxisUsed                     indicates whether z-axis is assumed to be common
895      *                                           for the accelerometer, gyroscope and magnetometer.
896      * @param hardIron                           known hard-iron.
897      * @param initialMm                          initial soft-iron matrix containing scale factors
898      *                                           and cross coupling errors.
899      * @param listener                           listener to handle events raised by this calibrator.
900      * @throws IllegalArgumentException if provided magnetic flux norm value is negative,
901      *                                  or if provided hard-iron matrix is not 3x1
902      *                                  or if soft-iron matrix is not 3x3.
903      */
904     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
905             final Double groundTruthMagneticFluxDensityNorm,
906             final List<StandardDeviationBodyMagneticFluxDensity> measurements, final boolean commonAxisUsed,
907             final Matrix hardIron, final Matrix initialMm,
908             final RobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibratorListener listener) {
909         super(groundTruthMagneticFluxDensityNorm, measurements, commonAxisUsed, hardIron, initialMm, listener);
910     }
911 
912     /**
913      * Constructor.
914      *
915      * @param qualityScores quality scores corresponding to each provided
916      *                      measurement. The larger the score value the better
917      *                      the quality of the sample.
918      * @param measurements  list of body magnetic flux density
919      *                      measurements with standard deviation of
920      *                      magnetometer measurements taken at the same
921      *                      position with zero velocity and unknown different
922      *                      orientations.
923      * @throws IllegalArgumentException if provided quality scores length
924      *                                  is smaller than 10 samples.
925      */
926     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
927             final double[] qualityScores, final List<StandardDeviationBodyMagneticFluxDensity> measurements) {
928         super(measurements);
929         internalSetQualityScores(qualityScores);
930     }
931 
932     /**
933      * Constructor.
934      *
935      * @param qualityScores  quality scores corresponding to each provided
936      *                       measurement. The larger the score value the better
937      *                       the quality of the sample.
938      * @param commonAxisUsed indicates whether z-axis is assumed to be common
939      *                       for the accelerometer, gyroscope and magnetometer.
940      * @throws IllegalArgumentException if provided quality scores length
941      *                                  is smaller than 10 samples.
942      */
943     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
944             final double[] qualityScores, final boolean commonAxisUsed) {
945         super(commonAxisUsed);
946         internalSetQualityScores(qualityScores);
947     }
948 
949     /**
950      * Constructor.
951      *
952      * @param qualityScores quality scores corresponding to each provided
953      *                      measurement. The larger the score value the better
954      *                      the quality of the sample.
955      * @param hardIron      known hard-iron.
956      * @throws IllegalArgumentException if provided hard-iron array does
957      *                                  not have length 3 or if provided
958      *                                  quality scores length is smaller
959      *                                  than 10 samples.
960      */
961     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
962             final double[] qualityScores, final double[] hardIron) {
963         super(hardIron);
964         internalSetQualityScores(qualityScores);
965     }
966 
967     /**
968      * Constructor.
969      *
970      * @param qualityScores quality scores corresponding to each provided
971      *                      measurement. The larger the score value the better
972      *                      the quality of the sample.
973      * @param hardIron      known hard-iron.
974      * @throws IllegalArgumentException if provided hard-iron matrix is not
975      *                                  3x1 or if provided quality scores
976      *                                  length is smaller than 10 samples.
977      */
978     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
979             final double[] qualityScores, final Matrix hardIron) {
980         super(hardIron);
981         internalSetQualityScores(qualityScores);
982     }
983 
984     /**
985      * Constructor.
986      *
987      * @param qualityScores quality scores corresponding to each provided
988      *                      measurement. The larger the score value the better
989      *                      the quality of the sample.
990      * @param hardIron      known hard-iron.
991      * @param initialMm     initial soft-iron matrix containing scale factors
992      *                      and cross coupling errors.
993      * @throws IllegalArgumentException if provided hard-iron matrix is not
994      *                                  3x1 or if soft-iron matrix is not
995      *                                  3x3 or if provided quality scores
996      *                                  length is smaller than 10 samples.
997      */
998     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
999             final double[] qualityScores, final Matrix hardIron, final Matrix initialMm) {
1000         super(hardIron, initialMm);
1001         internalSetQualityScores(qualityScores);
1002     }
1003 
1004     /**
1005      * Constructor.
1006      *
1007      * @param qualityScores quality scores corresponding to each provided
1008      *                      measurement. The larger the score value the better
1009      *                      the quality of the sample.
1010      * @param measurements  list of body magnetic flux density
1011      *                      measurements with standard deviation of
1012      *                      magnetometer measurements taken at the same
1013      *                      position with zero velocity and unknown different
1014      *                      orientations.
1015      * @param listener      listener to handle events raised by this calibrator.
1016      * @throws IllegalArgumentException if provided quality scores length
1017      *                                  is smaller than 10 samples.
1018      */
1019     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
1020             final double[] qualityScores, final List<StandardDeviationBodyMagneticFluxDensity> measurements,
1021             final RobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibratorListener listener) {
1022         super(measurements, listener);
1023         internalSetQualityScores(qualityScores);
1024     }
1025 
1026     /**
1027      * Constructor.
1028      *
1029      * @param qualityScores  quality scores corresponding to each provided
1030      *                       measurement. The larger the score value the better
1031      *                       the quality of the sample.
1032      * @param measurements   collection of body magnetic flux density
1033      *                       measurements with standard deviation of
1034      *                       magnetometer measurements taken at the same
1035      *                       position with zero velocity and unknown different
1036      *                       orientations.
1037      * @param commonAxisUsed indicates whether z-axis is assumed to be common
1038      *                       for the accelerometer, gyroscope and magnetometer.
1039      * @throws IllegalArgumentException if provided quality scores length
1040      *                                  is smaller than 10 samples.
1041      */
1042     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
1043             final double[] qualityScores, final List<StandardDeviationBodyMagneticFluxDensity> measurements,
1044             final boolean commonAxisUsed) {
1045         super(measurements, commonAxisUsed);
1046         internalSetQualityScores(qualityScores);
1047     }
1048 
1049     /**
1050      * Constructor.
1051      *
1052      * @param qualityScores  quality scores corresponding to each provided
1053      *                       measurement. The larger the score value the better
1054      *                       the quality of the sample.
1055      * @param measurements   collection of body magnetic flux density
1056      *                       measurements with standard deviation of
1057      *                       magnetometer measurements taken at the same
1058      *                       position with zero velocity and unknown different
1059      *                       orientations.
1060      * @param commonAxisUsed indicates whether z-axis is assumed to be common
1061      *                       for the accelerometer, gyroscope and magnetometer.
1062      * @param listener       listener to handle events raised by this calibrator.
1063      * @throws IllegalArgumentException if provided quality scores length
1064      *                                  is smaller than 10 samples.
1065      */
1066     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
1067             final double[] qualityScores, final List<StandardDeviationBodyMagneticFluxDensity> measurements,
1068             final boolean commonAxisUsed,
1069             final RobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibratorListener listener) {
1070         super(measurements, commonAxisUsed, listener);
1071         internalSetQualityScores(qualityScores);
1072     }
1073 
1074     /**
1075      * Constructor.
1076      *
1077      * @param qualityScores quality scores corresponding to each provided
1078      *                      measurement. The larger the score value the better
1079      *                      the quality of the sample.
1080      * @param measurements  collection of body magnetic flux density
1081      *                      measurements with standard deviation of
1082      *                      magnetometer measurements taken at the same
1083      *                      position with zero velocity and unknown different
1084      *                      orientations.
1085      * @param hardIron      known hard-iron.
1086      * @throws IllegalArgumentException if provided hard-iron array does
1087      *                                  not have length 3 or if provided quality
1088      *                                  scores length is smaller than 10 samples.
1089      */
1090     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
1091             final double[] qualityScores, final List<StandardDeviationBodyMagneticFluxDensity> measurements,
1092             final double[] hardIron) {
1093         super(measurements, hardIron);
1094         internalSetQualityScores(qualityScores);
1095     }
1096 
1097     /**
1098      * Constructor.
1099      *
1100      * @param qualityScores quality scores corresponding to each provided
1101      *                      measurement. The larger the score value the better
1102      *                      the quality of the sample.
1103      * @param measurements  collection of body magnetic flux density
1104      *                      measurements with standard deviation of
1105      *                      magnetometer measurements taken at the same
1106      *                      position with zero velocity and unknown different
1107      *                      orientations.
1108      * @param hardIron      known hard-iron.
1109      * @param listener      listener to handle events raised by this calibrator.
1110      * @throws IllegalArgumentException if provided hard-iron array does
1111      *                                  not have length 3 or if provided quality
1112      *                                  scores length is smaller than 10 samples.
1113      */
1114     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
1115             final double[] qualityScores, final List<StandardDeviationBodyMagneticFluxDensity> measurements,
1116             final double[] hardIron,
1117             final RobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibratorListener listener) {
1118         super(measurements, hardIron, listener);
1119         internalSetQualityScores(qualityScores);
1120     }
1121 
1122     /**
1123      * Constructor.
1124      *
1125      * @param qualityScores  quality scores corresponding to each provided
1126      *                       measurement. The larger the score value the better
1127      *                       the quality of the sample.
1128      * @param measurements   collection of body magnetic flux density
1129      *                       measurements with standard deviation of
1130      *                       magnetometer measurements taken at the same
1131      *                       position with zero velocity and unknown different
1132      *                       orientations.
1133      * @param commonAxisUsed indicates whether z-axis is assumed to be common
1134      *                       for the accelerometer, gyroscope and magnetometer.
1135      * @param hardIron       known hard-iron.
1136      * @throws IllegalArgumentException if provided hard-iron array does
1137      *                                  not have length 3 or if provided quality
1138      *                                  scores length is smaller than 10 samples.
1139      */
1140     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
1141             final double[] qualityScores, final List<StandardDeviationBodyMagneticFluxDensity> measurements,
1142             final boolean commonAxisUsed, final double[] hardIron) {
1143         super(measurements, commonAxisUsed, hardIron);
1144         internalSetQualityScores(qualityScores);
1145     }
1146 
1147     /**
1148      * Constructor.
1149      *
1150      * @param qualityScores  quality scores corresponding to each provided
1151      *                       measurement. The larger the score value the better
1152      *                       the quality of the sample.
1153      * @param measurements   collection of body magnetic flux density
1154      *                       measurements with standard deviation of
1155      *                       magnetometer measurements taken at the same
1156      *                       position with zero velocity and unknown different
1157      *                       orientations.
1158      * @param commonAxisUsed indicates whether z-axis is assumed to be common
1159      *                       for the accelerometer, gyroscope and magnetometer.
1160      * @param hardIron       known hard-iron.
1161      * @param listener       listener to handle events raised by this calibrator.
1162      * @throws IllegalArgumentException if provided hard-iron array does
1163      *                                  not have length 3 or if provided quality
1164      *                                  scores length is smaller than 10 samples.
1165      */
1166     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
1167             final double[] qualityScores, final List<StandardDeviationBodyMagneticFluxDensity> measurements,
1168             final boolean commonAxisUsed, final double[] hardIron,
1169             final RobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibratorListener listener) {
1170         super(measurements, commonAxisUsed, hardIron, listener);
1171         internalSetQualityScores(qualityScores);
1172     }
1173 
1174     /**
1175      * Constructor.
1176      *
1177      * @param qualityScores quality scores corresponding to each provided
1178      *                      measurement. The larger the score value the better
1179      *                      the quality of the sample.
1180      * @param measurements  collection of body magnetic flux density
1181      *                      measurements with standard deviation of
1182      *                      magnetometer measurements taken at the same
1183      *                      position with zero velocity and unknown different
1184      *                      orientations.
1185      * @param hardIron      known hard-iron.
1186      * @throws IllegalArgumentException if provided hard-iron matrix is not
1187      *                                  3x1 or if provided quality scores length
1188      *                                  is smaller than 10 samples.
1189      */
1190     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
1191             final double[] qualityScores, final List<StandardDeviationBodyMagneticFluxDensity> measurements,
1192             final Matrix hardIron) {
1193         super(measurements, hardIron);
1194         internalSetQualityScores(qualityScores);
1195     }
1196 
1197     /**
1198      * Constructor.
1199      *
1200      * @param qualityScores quality scores corresponding to each provided
1201      *                      measurement. The larger the score value the better
1202      *                      the quality of the sample.
1203      * @param measurements  collection of body magnetic flux density
1204      *                      measurements with standard deviation of
1205      *                      magnetometer measurements taken at the same
1206      *                      position with zero velocity and unknown different
1207      *                      orientations.
1208      * @param hardIron      known hard-iron.
1209      * @param listener      listener to handle events raised by this calibrator.
1210      * @throws IllegalArgumentException if provided hard-iron matrix is not
1211      *                                  3x1 or if provided quality scores length
1212      *                                  is smaller than 10 samples.
1213      */
1214     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
1215             final double[] qualityScores, final List<StandardDeviationBodyMagneticFluxDensity> measurements,
1216             final Matrix hardIron,
1217             final RobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibratorListener listener) {
1218         super(measurements, hardIron, listener);
1219         internalSetQualityScores(qualityScores);
1220     }
1221 
1222     /**
1223      * Constructor.
1224      *
1225      * @param qualityScores  quality scores corresponding to each provided
1226      *                       measurement. The larger the score value the better
1227      *                       the quality of the sample.
1228      * @param measurements   collection of body magnetic flux density
1229      *                       measurements with standard deviation of
1230      *                       magnetometer measurements taken at the same
1231      *                       position with zero velocity and unknown different
1232      *                       orientations.
1233      * @param commonAxisUsed indicates whether z-axis is assumed to be common
1234      *                       for the accelerometer, gyroscope and magnetometer.
1235      * @param hardIron       known hard-iron.
1236      * @throws IllegalArgumentException if provided hard-iron matrix is not
1237      *                                  3x1 or if provided quality scores length
1238      *                                  is smaller than 10 samples.
1239      */
1240     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
1241             final double[] qualityScores, final List<StandardDeviationBodyMagneticFluxDensity> measurements,
1242             final boolean commonAxisUsed, final Matrix hardIron) {
1243         super(measurements, commonAxisUsed, hardIron);
1244         internalSetQualityScores(qualityScores);
1245     }
1246 
1247     /**
1248      * Constructor.
1249      *
1250      * @param qualityScores  quality scores corresponding to each provided
1251      *                       measurement. The larger the score value the better
1252      *                       the quality of the sample.
1253      * @param measurements   collection of body magnetic flux density
1254      *                       measurements with standard deviation of
1255      *                       magnetometer measurements taken at the same
1256      *                       position with zero velocity and unknown different
1257      *                       orientations.
1258      * @param commonAxisUsed indicates whether z-axis is assumed to be common
1259      *                       for the accelerometer, gyroscope and magnetometer.
1260      * @param hardIron       known hard-iron.
1261      * @param listener       listener to handle events raised by this calibrator.
1262      * @throws IllegalArgumentException if provided hard-iron matrix is not
1263      *                                  3x1 or if provided quality scores length
1264      *                                  is smaller than 10 samples.
1265      */
1266     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
1267             final double[] qualityScores, final List<StandardDeviationBodyMagneticFluxDensity> measurements,
1268             final boolean commonAxisUsed, final Matrix hardIron,
1269             final RobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibratorListener listener) {
1270         super(measurements, commonAxisUsed, hardIron, listener);
1271         internalSetQualityScores(qualityScores);
1272     }
1273 
1274     /**
1275      * Constructor.
1276      *
1277      * @param qualityScores quality scores corresponding to each provided
1278      *                      measurement. The larger the score value the better
1279      *                      the quality of the sample.*
1280      * @param measurements  collection of body magnetic flux density
1281      *                      measurements with standard deviation of
1282      *                      magnetometer measurements taken at the same
1283      *                      position with zero velocity and unknown different
1284      *                      orientations.
1285      * @param hardIron      known hard-iron.
1286      * @param initialMm     initial soft-iron matrix containing scale factors
1287      *                      and cross coupling errors.
1288      * @throws IllegalArgumentException if provided hard-iron matrix is not
1289      *                                  3x1 or if soft-iron matrix is not
1290      *                                  3x3 or if provided quality scores length
1291      *                                  is smaller than 10 samples.
1292      */
1293     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
1294             final double[] qualityScores, final List<StandardDeviationBodyMagneticFluxDensity> measurements,
1295             final Matrix hardIron, final Matrix initialMm) {
1296         super(measurements, hardIron, initialMm);
1297         internalSetQualityScores(qualityScores);
1298     }
1299 
1300     /**
1301      * Constructor.
1302      *
1303      * @param qualityScores quality scores corresponding to each provided
1304      *                      measurement. The larger the score value the better
1305      *                      the quality of the sample.
1306      * @param measurements  collection of body magnetic flux density
1307      *                      measurements with standard deviation of
1308      *                      magnetometer measurements taken at the same
1309      *                      position with zero velocity and unknown different
1310      *                      orientations.
1311      * @param hardIron      known hard-iron.
1312      * @param initialMm     initial soft-iron matrix containing scale factors
1313      *                      and cross coupling errors.
1314      * @param listener      listener to handle events raised by this calibrator.
1315      * @throws IllegalArgumentException if provided hard-iron matrix is not
1316      *                                  3x1 or if soft-iron matrix is not
1317      *                                  3x3 or if provided quality scores length
1318      *                                  is smaller than 10 samples.
1319      */
1320     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
1321             final double[] qualityScores, final List<StandardDeviationBodyMagneticFluxDensity> measurements,
1322             final Matrix hardIron, final Matrix initialMm,
1323             final RobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibratorListener listener) {
1324         super(measurements, hardIron, initialMm, listener);
1325         internalSetQualityScores(qualityScores);
1326     }
1327 
1328     /**
1329      * Constructor.
1330      *
1331      * @param qualityScores  quality scores corresponding to each provided
1332      *                       measurement. The larger the score value the better
1333      *                       the quality of the sample.
1334      * @param measurements   collection of body magnetic flux density
1335      *                       measurements with standard deviation of
1336      *                       magnetometer measurements taken at the same
1337      *                       position with zero velocity and unknown different
1338      *                       orientations.
1339      * @param commonAxisUsed indicates whether z-axis is assumed to be common
1340      *                       for the accelerometer, gyroscope and magnetometer.
1341      * @param hardIron       known hard-iron.
1342      * @param initialMm      initial soft-iron matrix containing scale factors
1343      *                       and cross coupling errors.
1344      * @throws IllegalArgumentException if provided hard-iron matrix is not
1345      *                                  3x1 or if soft-iron matrix is not
1346      *                                  3x3 or if provided quality scores length
1347      *                                  is smaller than 10 samples.
1348      */
1349     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
1350             final double[] qualityScores, final List<StandardDeviationBodyMagneticFluxDensity> measurements,
1351             final boolean commonAxisUsed, final Matrix hardIron, final Matrix initialMm) {
1352         super(measurements, commonAxisUsed, hardIron, initialMm);
1353         internalSetQualityScores(qualityScores);
1354     }
1355 
1356     /**
1357      * Constructor.
1358      *
1359      * @param qualityScores  quality scores corresponding to each provided
1360      *                       measurement. The larger the score value the better
1361      *                       the quality of the sample.
1362      * @param measurements   collection of body magnetic flux density
1363      *                       measurements with standard deviation of
1364      *                       magnetometer measurements taken at the same
1365      *                       position with zero velocity and unknown different
1366      *                       orientations.
1367      * @param commonAxisUsed indicates whether z-axis is assumed to be common
1368      *                       for the accelerometer, gyroscope and magnetometer.
1369      * @param hardIron       known hard-iron.
1370      * @param initialMm      initial soft-iron matrix containing scale factors
1371      *                       and cross coupling errors.
1372      * @param listener       listener to handle events raised by this calibrator.
1373      * @throws IllegalArgumentException if provided hard-iron matrix is not
1374      *                                  3x1 or if soft-iron matrix is not
1375      *                                  3x3 or if provided quality scores length
1376      *                                  is smaller than 10 samples.
1377      */
1378     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
1379             final double[] qualityScores, final List<StandardDeviationBodyMagneticFluxDensity> measurements,
1380             final boolean commonAxisUsed, final Matrix hardIron, final Matrix initialMm,
1381             final RobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibratorListener listener) {
1382         super(measurements, commonAxisUsed, hardIron, initialMm, listener);
1383         internalSetQualityScores(qualityScores);
1384     }
1385 
1386     /**
1387      * Constructor.
1388      *
1389      * @param qualityScores                      quality scores corresponding to each provided
1390      *                                           measurement. The larger the score value the better
1391      *                                           the quality of the sample.
1392      * @param groundTruthMagneticFluxDensityNorm ground truth magnetic flux density norm expressed in Teslas (T).
1393      * @throws IllegalArgumentException if provided magnetic flux norm value is negative
1394      *                                  or if provided quality scores length is smaller
1395      *                                  than 10 samples.
1396      */
1397     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
1398             final double[] qualityScores, final Double groundTruthMagneticFluxDensityNorm) {
1399         super(groundTruthMagneticFluxDensityNorm);
1400         internalSetQualityScores(qualityScores);
1401     }
1402 
1403     /**
1404      * Constructor.
1405      *
1406      * @param qualityScores                      quality scores corresponding to each provided
1407      *                                           measurement. The larger the score value the better
1408      *                                           the quality of the sample.
1409      * @param groundTruthMagneticFluxDensityNorm ground truth magnetic flux density norm expressed in Teslas (T).
1410      * @param listener                           listener to handle events raised by this calibrator.
1411      * @throws IllegalArgumentException if provided magnetic flux norm value is negative
1412      *                                  or if provided quality scores length is smaller
1413      *                                  than 10 samples.
1414      */
1415     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
1416             final double[] qualityScores, final Double groundTruthMagneticFluxDensityNorm,
1417             final RobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibratorListener listener) {
1418         super(groundTruthMagneticFluxDensityNorm, listener);
1419         internalSetQualityScores(qualityScores);
1420     }
1421 
1422     /**
1423      * Constructor.
1424      *
1425      * @param qualityScores                      quality scores corresponding to each provided
1426      *                                           measurement. The larger the score value the better
1427      *                                           the quality of the sample.
1428      * @param groundTruthMagneticFluxDensityNorm ground truth magnetic flux density norm expressed in Teslas (T).
1429      * @param measurements                       collection of body magnetic flux density
1430      *                                           measurements with standard deviation of
1431      *                                           magnetometer measurements taken at the same
1432      *                                           position with zero velocity and unknown different
1433      *                                           orientations.
1434      * @throws IllegalArgumentException if provided magnetic flux norm value is negative
1435      *                                  or if provided quality scores length is smaller
1436      *                                  than 10 samples.
1437      */
1438     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
1439             final double[] qualityScores, final Double groundTruthMagneticFluxDensityNorm,
1440             final List<StandardDeviationBodyMagneticFluxDensity> measurements) {
1441         super(groundTruthMagneticFluxDensityNorm, measurements);
1442         internalSetQualityScores(qualityScores);
1443     }
1444 
1445     /**
1446      * Constructor.
1447      *
1448      * @param qualityScores                      quality scores corresponding to each provided
1449      *                                           measurement. The larger the score value the better
1450      *                                           the quality of the sample.
1451      * @param groundTruthMagneticFluxDensityNorm ground truth magnetic flux density norm expressed in Teslas (T).
1452      * @param commonAxisUsed                     indicates whether z-axis is assumed to be common
1453      *                                           for the accelerometer, gyroscope and magnetometer.
1454      * @throws IllegalArgumentException if provided magnetic flux norm value is negative
1455      *                                  or if provided quality scores length is smaller
1456      *                                  than 10 samples.
1457      */
1458     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
1459             final double[] qualityScores, final Double groundTruthMagneticFluxDensityNorm,
1460             final boolean commonAxisUsed) {
1461         super(groundTruthMagneticFluxDensityNorm, commonAxisUsed);
1462         internalSetQualityScores(qualityScores);
1463     }
1464 
1465     /**
1466      * Constructor.
1467      *
1468      * @param qualityScores                      quality scores corresponding to each provided
1469      *                                           measurement. The larger the score value the better
1470      *                                           the quality of the sample.
1471      * @param groundTruthMagneticFluxDensityNorm ground truth magnetic flux density norm expressed in Teslas (T).
1472      * @param hardIron                           known hard-iron.
1473      * @throws IllegalArgumentException if provided magnetic flux norm value is
1474      *                                  negative, or if provided hard-iron array does
1475      *                                  not have length 3, or if provided quality scores
1476      *                                  length is smaller than 10 samples.
1477      */
1478     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
1479             final double[] qualityScores, final Double groundTruthMagneticFluxDensityNorm, final double[] hardIron) {
1480         super(groundTruthMagneticFluxDensityNorm, hardIron);
1481         internalSetQualityScores(qualityScores);
1482     }
1483 
1484     /**
1485      * Constructor.
1486      *
1487      * @param qualityScores                      quality scores corresponding to each provided
1488      *                                           measurement. The larger the score value the better
1489      *                                           the quality of the sample.
1490      * @param groundTruthMagneticFluxDensityNorm ground truth magnetic flux density norm expressed in Teslas (T).
1491      * @param hardIron                           known hard-iron.
1492      * @throws IllegalArgumentException if provided magnetic flux norm value is
1493      *                                  negative, or if provided hard-iron matrix is not
1494      *                                  3x1, or if provided quality scores length
1495      *                                  is smaller than 10 samples.
1496      */
1497     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
1498             final double[] qualityScores, final Double groundTruthMagneticFluxDensityNorm, final Matrix hardIron) {
1499         super(groundTruthMagneticFluxDensityNorm, hardIron);
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 hardIron                           known hard-iron.
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 PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
1520             final double[] qualityScores, final Double groundTruthMagneticFluxDensityNorm, final Matrix hardIron,
1521             final Matrix initialMm) {
1522         super(groundTruthMagneticFluxDensityNorm, hardIron, 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 PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
1544             final double[] qualityScores, final Double groundTruthMagneticFluxDensityNorm,
1545             final List<StandardDeviationBodyMagneticFluxDensity> measurements,
1546             final RobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibratorListener 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 PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
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 PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
1596             final double[] qualityScores, final Double groundTruthMagneticFluxDensityNorm,
1597             final List<StandardDeviationBodyMagneticFluxDensity> measurements, final boolean commonAxisUsed,
1598             final RobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibratorListener 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 hardIron                           known hard-iron.
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 PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
1622             final double[] qualityScores, final Double groundTruthMagneticFluxDensityNorm,
1623             final List<StandardDeviationBodyMagneticFluxDensity> measurements, final double[] hardIron) {
1624         super(groundTruthMagneticFluxDensityNorm, measurements, hardIron);
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 hardIron                           known hard-iron.
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 PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
1648             final double[] qualityScores, final Double groundTruthMagneticFluxDensityNorm,
1649             final List<StandardDeviationBodyMagneticFluxDensity> measurements, final double[] hardIron,
1650             final RobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibratorListener listener) {
1651         super(groundTruthMagneticFluxDensityNorm, measurements, hardIron, 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 hardIron                           known hard-iron.
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 PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
1676             final double[] qualityScores, final Double groundTruthMagneticFluxDensityNorm,
1677             final List<StandardDeviationBodyMagneticFluxDensity> measurements, final boolean commonAxisUsed,
1678             final double[] hardIron) {
1679         super(groundTruthMagneticFluxDensityNorm, measurements, commonAxisUsed, hardIron);
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 hardIron                           known hard-iron.
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 PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
1705             final double[] qualityScores, final Double groundTruthMagneticFluxDensityNorm,
1706             final List<StandardDeviationBodyMagneticFluxDensity> measurements, final boolean commonAxisUsed,
1707             final double[] hardIron,
1708             final RobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibratorListener listener) {
1709         super(groundTruthMagneticFluxDensityNorm, measurements, commonAxisUsed, hardIron, 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 hardIron                           known hard-iron.
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 PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
1732             final double[] qualityScores, final Double groundTruthMagneticFluxDensityNorm,
1733             final List<StandardDeviationBodyMagneticFluxDensity> measurements, final Matrix hardIron) {
1734         super(groundTruthMagneticFluxDensityNorm, measurements, hardIron);
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 hardIron                           known hard-iron.
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 PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
1758             final double[] qualityScores, final Double groundTruthMagneticFluxDensityNorm,
1759             final List<StandardDeviationBodyMagneticFluxDensity> measurements, final Matrix hardIron,
1760             final RobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibratorListener listener) {
1761         super(groundTruthMagneticFluxDensityNorm, measurements, hardIron, 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 hardIron                           known hard-iron.
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 PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
1786             final double[] qualityScores, final Double groundTruthMagneticFluxDensityNorm,
1787             final List<StandardDeviationBodyMagneticFluxDensity> measurements, final boolean commonAxisUsed,
1788             final Matrix hardIron) {
1789         super(groundTruthMagneticFluxDensityNorm, measurements, commonAxisUsed, hardIron);
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 hardIron                           known hard-iron.
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 PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
1815             final double[] qualityScores, final Double groundTruthMagneticFluxDensityNorm,
1816             final List<StandardDeviationBodyMagneticFluxDensity> measurements, final boolean commonAxisUsed,
1817             final Matrix hardIron,
1818             final RobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibratorListener listener) {
1819         super(groundTruthMagneticFluxDensityNorm, measurements, commonAxisUsed, hardIron, 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 hardIron                           known hard-iron.
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 PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
1844             final double[] qualityScores, final Double groundTruthMagneticFluxDensityNorm,
1845             final List<StandardDeviationBodyMagneticFluxDensity> measurements, final Matrix hardIron,
1846             final Matrix initialMm) {
1847         super(groundTruthMagneticFluxDensityNorm, measurements, hardIron, 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 hardIron                           known hard-iron.
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 PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
1873             final double[] qualityScores, final Double groundTruthMagneticFluxDensityNorm,
1874             final List<StandardDeviationBodyMagneticFluxDensity> measurements, final Matrix hardIron,
1875             final Matrix initialMm,
1876             final RobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibratorListener listener) {
1877         super(groundTruthMagneticFluxDensityNorm, measurements, hardIron, initialMm, listener);
1878         internalSetQualityScores(qualityScores);
1879     }
1880 
1881     /**
1882      * Constructor.
1883      *
1884      * @param qualityScores                      quality scores corresponding to each provided
1885      *                                           measurement. The larger the score value the better
1886      *                                           the quality of the sample.
1887      * @param groundTruthMagneticFluxDensityNorm ground truth magnetic flux density norm expressed in Teslas (T).
1888      * @param measurements                       collection of body magnetic flux density
1889      *                                           measurements with standard deviation of
1890      *                                           magnetometer measurements taken at the same
1891      *                                           position with zero velocity and unknown different
1892      *                                           orientations.
1893      * @param commonAxisUsed                     indicates whether z-axis is assumed to be common
1894      *                                           for the accelerometer, gyroscope and magnetometer.
1895      * @param hardIron                           known hard-iron.
1896      * @param initialMm                          initial soft-iron matrix containing scale factors
1897      *                                           and cross coupling errors.
1898      * @throws IllegalArgumentException if provided magnetic flux norm value is negative,
1899      *                                  or if provided hard-iron matrix is not 3x1
1900      *                                  or if soft-iron matrix is not 3x3, or if
1901      *                                  provided quality scores length is smaller
1902      *                                  than 10 samples.
1903      */
1904     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
1905             final double[] qualityScores, final Double groundTruthMagneticFluxDensityNorm,
1906             final List<StandardDeviationBodyMagneticFluxDensity> measurements, final boolean commonAxisUsed,
1907             final Matrix hardIron, final Matrix initialMm) {
1908         super(groundTruthMagneticFluxDensityNorm, measurements, commonAxisUsed, hardIron, initialMm);
1909         internalSetQualityScores(qualityScores);
1910     }
1911 
1912     /**
1913      * Constructor.
1914      *
1915      * @param qualityScores                      quality scores corresponding to each provided
1916      *                                           measurement. The larger the score value the better
1917      *                                           the quality of the sample.
1918      * @param groundTruthMagneticFluxDensityNorm ground truth magnetic flux density norm expressed in Teslas (T).
1919      * @param measurements                       collection of body magnetic flux density
1920      *                                           measurements with standard deviation of
1921      *                                           magnetometer measurements taken at the same
1922      *                                           position with zero velocity and unknown different
1923      *                                           orientations.
1924      * @param commonAxisUsed                     indicates whether z-axis is assumed to be common
1925      *                                           for the accelerometer, gyroscope and magnetometer.
1926      * @param hardIron                           known hard-iron.
1927      * @param initialMm                          initial soft-iron matrix containing scale factors
1928      *                                           and cross coupling errors.
1929      * @param listener                           listener to handle events raised by this calibrator.
1930      * @throws IllegalArgumentException if provided magnetic flux norm value is negative,
1931      *                                  or if provided hard-iron matrix is not 3x1
1932      *                                  or if soft-iron matrix is not 3x3, or if
1933      *                                  provided quality scores length is smaller
1934      *                                  than 10 samples.
1935      */
1936     public PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator(
1937             final double[] qualityScores, final Double groundTruthMagneticFluxDensityNorm,
1938             final List<StandardDeviationBodyMagneticFluxDensity> measurements, final boolean commonAxisUsed,
1939             final Matrix hardIron, final Matrix initialMm,
1940             final RobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibratorListener listener) {
1941         super(groundTruthMagneticFluxDensityNorm, measurements, commonAxisUsed, hardIron, initialMm, listener);
1942         internalSetQualityScores(qualityScores);
1943     }
1944 
1945     /**
1946      * Gets threshold to determine whether samples are inliers or not when testing possible solutions.
1947      * The threshold refers to the amount of error on norm between measured specific forces and the
1948      * ones generated with estimated calibration parameters provided for each sample.
1949      *
1950      * @return threshold to determine whether samples are inliers or not.
1951      */
1952     public double getThreshold() {
1953         return threshold;
1954     }
1955 
1956     /**
1957      * Sets threshold to determine whether samples are inliers or not when testing possible solutions.
1958      * The threshold refers to the amount of error on norm between measured specific forces and the
1959      * ones generated with estimated calibration parameters provided for each sample.
1960      *
1961      * @param threshold threshold to determine whether samples are inliers or not.
1962      * @throws IllegalArgumentException if provided value is equal or less than zero.
1963      * @throws LockedException          if calibrator is currently running.
1964      */
1965     public void setThreshold(final double threshold) throws LockedException {
1966         if (running) {
1967             throw new LockedException();
1968         }
1969         if (threshold <= MIN_THRESHOLD) {
1970             throw new IllegalArgumentException();
1971         }
1972         this.threshold = threshold;
1973     }
1974 
1975     /**
1976      * Returns quality scores corresponding to each provided sample.
1977      * The larger the score value the better the quality of the sample.
1978      *
1979      * @return quality scores corresponding to each sample.
1980      */
1981     @Override
1982     public double[] getQualityScores() {
1983         return qualityScores;
1984     }
1985 
1986     /**
1987      * Sets quality scores corresponding to each provided sample.
1988      * The larger the score value the better the quality of the sample.
1989      *
1990      * @param qualityScores quality scores corresponding to each sample.
1991      * @throws IllegalArgumentException if provided quality scores length
1992      *                                  is smaller than minimum required samples.
1993      * @throws LockedException          if calibrator is currently running.
1994      */
1995     @Override
1996     public void setQualityScores(final double[] qualityScores) throws LockedException {
1997         if (running) {
1998             throw new LockedException();
1999         }
2000         internalSetQualityScores(qualityScores);
2001     }
2002 
2003     /**
2004      * Indicates whether calibrator is ready to find a solution.
2005      *
2006      * @return true if calibrator is ready, false otherwise.
2007      */
2008     @Override
2009     public boolean isReady() {
2010         return super.isReady() && qualityScores != null && qualityScores.length == measurements.size();
2011     }
2012 
2013     /**
2014      * Indicates whether inliers must be computed and kept.
2015      *
2016      * @return true if inliers must be computed and kept, false if inliers
2017      * only need to be computed but not kept.
2018      */
2019     public boolean isComputeAndKeepInliersEnabled() {
2020         return computeAndKeepInliers;
2021     }
2022 
2023     /**
2024      * Specifies whether inliers must be computed and kept.
2025      *
2026      * @param computeAndKeepInliers true if inliers must be computed and kept,
2027      *                              false if inliers only need to be computed but not kept.
2028      * @throws LockedException if calibrator is currently running.
2029      */
2030     public void setComputeAndKeepInliersEnabled(final boolean computeAndKeepInliers) throws LockedException {
2031         if (running) {
2032             throw new LockedException();
2033         }
2034         this.computeAndKeepInliers = computeAndKeepInliers;
2035     }
2036 
2037     /**
2038      * Indicates whether residuals must be computed and kept.
2039      *
2040      * @return true if residuals must be computed and kept, false if residuals
2041      * only need to be computed but not kept.
2042      */
2043     public boolean isComputeAndKeepResiduals() {
2044         return computeAndKeepResiduals;
2045     }
2046 
2047     /**
2048      * Specifies whether residuals must be computed and kept.
2049      *
2050      * @param computeAndKeepResiduals true if residuals must be computed and kept,
2051      *                                false if residuals only need to be computed but not kept.
2052      * @throws LockedException if calibrator is currently running.
2053      */
2054     public void setComputeAndKeepResidualsEnabled(final boolean computeAndKeepResiduals) throws LockedException {
2055         if (running) {
2056             throw new LockedException();
2057         }
2058         this.computeAndKeepResiduals = computeAndKeepResiduals;
2059     }
2060 
2061     /**
2062      * Estimates magnetometer calibration parameters containing hard-iron
2063      * bias and soft-iron scale factors and cross-coupling errors.
2064      *
2065      * @throws LockedException      if calibrator is currently running.
2066      * @throws NotReadyException    if calibrator is not ready.
2067      * @throws CalibrationException if estimation fails for numerical reasons.
2068      */
2069     @SuppressWarnings("DuplicatedCode")
2070     @Override
2071     public void calibrate() throws LockedException, NotReadyException, CalibrationException {
2072         if (running) {
2073             throw new LockedException();
2074         }
2075         if (!isReady()) {
2076             throw new NotReadyException();
2077         }
2078 
2079         final var innerEstimator = new PROSACRobustEstimator<>(new PROSACRobustEstimatorListener<PreliminaryResult>() {
2080             @Override
2081             public double[] getQualityScores() {
2082                 return qualityScores;
2083             }
2084 
2085             @Override
2086             public double getThreshold() {
2087                 return threshold;
2088             }
2089 
2090             @Override
2091             public int getTotalSamples() {
2092                 return measurements.size();
2093             }
2094 
2095             @Override
2096             public int getSubsetSize() {
2097                 return preliminarySubsetSize;
2098             }
2099 
2100             @Override
2101             public void estimatePreliminarSolutions(
2102                     final int[] samplesIndices, final List<PreliminaryResult> solutions) {
2103                 computePreliminarySolutions(samplesIndices, solutions);
2104             }
2105 
2106             @Override
2107             public double computeResidual(final PreliminaryResult currentEstimation, final int i) {
2108                 return computeError(measurements.get(i), currentEstimation);
2109             }
2110 
2111             @Override
2112             public boolean isReady() {
2113                 return PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator.this.isReady();
2114             }
2115 
2116             @Override
2117             public void onEstimateStart(final RobustEstimator<PreliminaryResult> estimator) {
2118                 // no action needed
2119             }
2120 
2121             @Override
2122             public void onEstimateEnd(final RobustEstimator<PreliminaryResult> estimator) {
2123                 // no action needed
2124             }
2125 
2126             @Override
2127             public void onEstimateNextIteration(
2128                     final RobustEstimator<PreliminaryResult> estimator, final int iteration) {
2129                 if (listener != null) {
2130                     listener.onCalibrateNextIteration(
2131                             PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator.this,
2132                             iteration);
2133                 }
2134             }
2135 
2136             @Override
2137             public void onEstimateProgressChange(
2138                     final RobustEstimator<PreliminaryResult> estimator, final float progress) {
2139                 if (listener != null) {
2140                     listener.onCalibrateProgressChange(
2141                             PROSACRobustKnownHardIronMagneticFluxDensityNormMagnetometerCalibrator.this,
2142                             progress);
2143                 }
2144             }
2145         });
2146 
2147         try {
2148             running = true;
2149 
2150             if (listener != null) {
2151                 listener.onCalibrateStart(this);
2152             }
2153 
2154             inliersData = null;
2155 
2156             innerEstimator.setComputeAndKeepInliersEnabled(computeAndKeepInliers || refineResult);
2157             innerEstimator.setComputeAndKeepResidualsEnabled(computeAndKeepResiduals || refineResult);
2158             innerEstimator.setConfidence(confidence);
2159             innerEstimator.setMaxIterations(maxIterations);
2160             innerEstimator.setProgressDelta(progressDelta);
2161             final var preliminaryResult = innerEstimator.estimate();
2162             inliersData = innerEstimator.getInliersData();
2163 
2164             attemptRefine(preliminaryResult);
2165 
2166             if (listener != null) {
2167                 listener.onCalibrateEnd(this);
2168             }
2169 
2170         } catch (final com.irurueta.numerical.LockedException e) {
2171             throw new LockedException(e);
2172         } catch (final com.irurueta.numerical.NotReadyException e) {
2173             throw new NotReadyException(e);
2174         } catch (final RobustEstimatorException e) {
2175             throw new CalibrationException(e);
2176         } finally {
2177             running = false;
2178         }
2179     }
2180 
2181     /**
2182      * Returns method being used for robust estimation.
2183      *
2184      * @return method being used for robust estimation.
2185      */
2186     @Override
2187     public RobustEstimatorMethod getMethod() {
2188         return RobustEstimatorMethod.PROSAC;
2189     }
2190 
2191     /**
2192      * Indicates whether this calibrator requires quality scores for each
2193      * measurement or not.
2194      *
2195      * @return true if quality scores are required, false otherwise.
2196      */
2197     @Override
2198     public boolean isQualityScoresRequired() {
2199         return true;
2200     }
2201 
2202     /**
2203      * Sets quality scores corresponding to each provided sample.
2204      * This method is used internally and does not check whether instance is
2205      * locked or not.
2206      *
2207      * @param qualityScores quality scores to be set.
2208      * @throws IllegalArgumentException if provided quality scores length
2209      *                                  is smaller than 4 samples.
2210      */
2211     private void internalSetQualityScores(final double[] qualityScores) {
2212         if (qualityScores == null || qualityScores.length < MINIMUM_MEASUREMENTS_COMMON_Z_AXIS) {
2213             throw new IllegalArgumentException();
2214         }
2215 
2216         this.qualityScores = qualityScores;
2217     }
2218 }