View Javadoc
1   /*
2    * Copyright (C) 2020 Alberto Irurueta Carro (alberto@irurueta.com)
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *         http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package com.irurueta.navigation.inertial.calibration.accelerometer;
17  
18  import com.irurueta.algebra.AlgebraException;
19  import com.irurueta.algebra.Matrix;
20  import com.irurueta.algebra.Utils;
21  import com.irurueta.algebra.WrongSizeException;
22  import com.irurueta.navigation.LockedException;
23  import com.irurueta.navigation.NotReadyException;
24  import com.irurueta.navigation.inertial.BodyKinematics;
25  import com.irurueta.navigation.inertial.calibration.AccelerationTriad;
26  import com.irurueta.navigation.inertial.calibration.CalibrationException;
27  import com.irurueta.navigation.inertial.calibration.StandardDeviationBodyKinematics;
28  import com.irurueta.numerical.robust.InliersData;
29  import com.irurueta.numerical.robust.RobustEstimatorMethod;
30  import com.irurueta.units.Acceleration;
31  import com.irurueta.units.AccelerationConverter;
32  import com.irurueta.units.AccelerationUnit;
33  
34  import java.util.ArrayList;
35  import java.util.List;
36  
37  /**
38   * This is an abstract class to robustly estimate accelerometer cross
39   * couplings and scaling factors.
40   * <p>
41   * To use this calibrator at least 7 measurements taken at a single position
42   * where gravity norm is known must be taken at 7 different unknown
43   * orientations and zero velocity when common z-axis
44   * is assumed, otherwise at least 10 measurements are required.
45   * <p>
46   * Measured specific force is assumed to follow the model shown below:
47   * <pre>
48   *     fmeas = ba + (I + Ma) * ftrue + w
49   * </pre>
50   * Where:
51   * - fmeas is the measured specific force. This is a 3x1 vector.
52   * - ba is accelerometer bias. Ideally, on a perfect accelerometer, this should be a
53   * 3x1 zero vector.
54   * - I is the 3x3 identity matrix.
55   * - Ma is the 3x3 matrix containing cross-couplings and scaling factors. Ideally, on
56   * a perfect accelerometer, this should be a 3x3 zero matrix.
57   * - ftrue is ground-truth specific force.
58   * - w is measurement noise.
59   */
60  public abstract class RobustKnownBiasAndGravityNormAccelerometerCalibrator implements
61          AccelerometerNonLinearCalibrator, KnownBiasAccelerometerCalibrator,
62          OrderedStandardDeviationBodyKinematicsAccelerometerCalibrator, QualityScoredAccelerometerCalibrator {
63  
64      /**
65       * Indicates whether by default a common z-axis is assumed for both the accelerometer
66       * and gyroscope.
67       */
68      public static final boolean DEFAULT_USE_COMMON_Z_AXIS = false;
69  
70      /**
71       * Required minimum number of measurements when common z-axis is assumed.
72       */
73      public static final int MINIMUM_MEASUREMENTS_COMMON_Z_AXIS =
74              BaseBiasGravityNormAccelerometerCalibrator.MINIMUM_MEASUREMENTS_COMMON_Z_AXIS;
75  
76      /**
77       * Required minimum number of measurements for the general case.
78       */
79      public static final int MINIMUM_MEASUREMENTS_GENERAL =
80              BaseBiasGravityNormAccelerometerCalibrator.MINIMUM_MEASUREMENTS_GENERAL;
81  
82      /**
83       * Default robust estimator method when none is provided.
84       */
85      public static final RobustEstimatorMethod DEFAULT_ROBUST_METHOD = RobustEstimatorMethod.LMEDS;
86  
87      /**
88       * Indicates that result is refined by default.
89       */
90      public static final boolean DEFAULT_REFINE_RESULT = true;
91  
92      /**
93       * Indicates that covariance is kept by default after refining result.
94       */
95      public static final boolean DEFAULT_KEEP_COVARIANCE = true;
96  
97      /**
98       * Default amount of progress variation before notifying a change in estimation progress.
99       * By default this is set to 5%.
100      */
101     public static final float DEFAULT_PROGRESS_DELTA = 0.05f;
102 
103     /**
104      * Minimum allowed value for progress delta.
105      */
106     public static final float MIN_PROGRESS_DELTA = 0.0f;
107 
108     /**
109      * Maximum allowed value for progress delta.
110      */
111     public static final float MAX_PROGRESS_DELTA = 1.0f;
112 
113     /**
114      * Constant defining default confidence of the estimated result, which is
115      * 99%. This means that with a probability of 99% estimation will be
116      * accurate because chosen sub-samples will be inliers.
117      */
118     public static final double DEFAULT_CONFIDENCE = 0.99;
119 
120     /**
121      * Default maximum allowed number of iterations.
122      */
123     public static final int DEFAULT_MAX_ITERATIONS = 5000;
124 
125     /**
126      * Minimum allowed confidence value.
127      */
128     public static final double MIN_CONFIDENCE = 0.0;
129 
130     /**
131      * Maximum allowed confidence value.
132      */
133     public static final double MAX_CONFIDENCE = 1.0;
134 
135     /**
136      * Minimum allowed number of iterations.
137      */
138     public static final int MIN_ITERATIONS = 1;
139 
140     /**
141      * Contains a list of body kinematics measurements taken at a
142      * given position with different unknown orientations and containing the
143      * standard deviations of accelerometer and gyroscope measurements.
144      */
145     protected List<StandardDeviationBodyKinematics> measurements;
146 
147     /**
148      * Listener to be notified of events such as when calibration starts, ends or its
149      * progress significantly changes.
150      */
151     protected RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener;
152 
153     /**
154      * Indicates whether calibrator is running.
155      */
156     protected boolean running;
157 
158     /**
159      * Amount of progress variation before notifying a progress change during calibration.
160      */
161     protected float progressDelta = DEFAULT_PROGRESS_DELTA;
162 
163     /**
164      * Amount of confidence expressed as a value between 0.0 and 1.0 (which is equivalent
165      * to 100%). The amount of confidence indicates the probability that the estimated
166      * result is correct. Usually this value will be close to 1.0, but not exactly 1.0.
167      */
168     protected double confidence = DEFAULT_CONFIDENCE;
169 
170     /**
171      * Maximum allowed number of iterations. When the maximum number of iterations is
172      * exceeded, result will not be available, however an approximate result will be
173      * available for retrieval.
174      */
175     protected int maxIterations = DEFAULT_MAX_ITERATIONS;
176 
177     /**
178      * Data related to inliers found after calibration.
179      */
180     protected InliersData inliersData;
181 
182     /**
183      * Indicates whether result must be refined using a non linear calibrator over
184      * found inliers.
185      * If true, inliers will be computed and kept in any implementation regardless of the
186      * settings.
187      */
188     protected boolean refineResult = DEFAULT_REFINE_RESULT;
189 
190     /**
191      * Size of subsets to be checked during robust estimation.
192      */
193     protected int preliminarySubsetSize = MINIMUM_MEASUREMENTS_GENERAL;
194 
195     /**
196      * This flag indicates whether z-axis is assumed to be common for accelerometer
197      * and gyroscope.
198      * When enabled, this eliminates 3 variables from Ma matrix.
199      */
200     private boolean commonAxisUsed = DEFAULT_USE_COMMON_Z_AXIS;
201 
202     /**
203      * X-coordinate of known accelerometer bias.
204      * This is expressed in meters per squared second (m/s^2).
205      */
206     private double biasX;
207 
208     /**
209      * Y-coordinate of known accelerometer bias.
210      * This is expressed in meters per squared second (m/s^2).
211      */
212     private double biasY;
213 
214     /**
215      * Z-coordinate of known accelerometer bias.
216      * This is expressed in meters per squared second (m/s^2).
217      */
218     private double biasZ;
219 
220     /**
221      * Initial x scaling factor.
222      */
223     private double initialSx;
224 
225     /**
226      * Initial y scaling factor.
227      */
228     private double initialSy;
229 
230     /**
231      * Initial z scaling factor.
232      */
233     private double initialSz;
234 
235     /**
236      * Initial x-y cross coupling error.
237      */
238     private double initialMxy;
239 
240     /**
241      * Initial x-z cross coupling error.
242      */
243     private double initialMxz;
244 
245     /**
246      * Initial y-x cross coupling error.
247      */
248     private double initialMyx;
249 
250     /**
251      * Initial y-z cross coupling error.
252      */
253     private double initialMyz;
254 
255     /**
256      * Initial z-x cross coupling error.
257      */
258     private double initialMzx;
259 
260     /**
261      * Initial z-y cross coupling error.
262      */
263     private double initialMzy;
264 
265     /**
266      * Ground truth gravity norm to be expected at location where measurements have been made,
267      * expressed in meters per squared second (m/s^2).
268      */
269     protected Double groundTruthGravityNorm;
270 
271     /**
272      * Estimated accelerometer scale factors and cross coupling errors.
273      * This is the product of matrix Ta containing cross coupling errors and Ka
274      * containing scaling factors.
275      * So tat:
276      * <pre>
277      *     Ma = [sx    mxy  mxz] = Ta*Ka
278      *          [myx   sy   myz]
279      *          [mzx   mzy  sz ]
280      * </pre>
281      * Where:
282      * <pre>
283      *     Ka = [sx 0   0 ]
284      *          [0  sy  0 ]
285      *          [0  0   sz]
286      * </pre>
287      * and
288      * <pre>
289      *     Ta = [1          -alphaXy    alphaXz ]
290      *          [alphaYx    1           -alphaYz]
291      *          [-alphaZx   alphaZy     1       ]
292      * </pre>
293      * Hence:
294      * <pre>
295      *     Ma = [sx    mxy  mxz] = Ta*Ka =  [sx             -sy * alphaXy   sz * alphaXz ]
296      *          [myx   sy   myz]            [sx * alphaYx   sy              -sz * alphaYz]
297      *          [mzx   mzy  sz ]            [-sx * alphaZx  sy * alphaZy    sz           ]
298      * </pre>
299      * This instance allows any 3x3 matrix however, typically alphaYx, alphaZx and alphaZy
300      * are considered to be zero if the accelerometer z-axis is assumed to be the same
301      * as the body z-axis. When this is assumed, myx = mzx = mzy = 0 and the Ma matrix
302      * becomes upper diagonal:
303      * <pre>
304      *     Ma = [sx    mxy  mxz]
305      *          [0     sy   myz]
306      *          [0     0    sz ]
307      * </pre>
308      * Values of this matrix are unit-less.
309      */
310     private Matrix estimatedMa;
311 
312     /**
313      * Indicates whether covariance must be kept after refining result.
314      * This setting is only taken into account if result is refined.
315      */
316     private boolean keepCovariance = DEFAULT_KEEP_COVARIANCE;
317 
318     /**
319      * Estimated covariance of estimated position.
320      * This is only available when result has been refined and covariance is kept.
321      */
322     private Matrix estimatedCovariance;
323 
324     /**
325      * Estimated chi square value.
326      */
327     private double estimatedChiSq;
328 
329     /**
330      * Estimated mean square error respect to provided measurements.
331      */
332     private double estimatedMse;
333 
334     /**
335      * Estimated degrees of freedom of chi square value. Degrees of freedom is equal to the number of sampled data
336      * minus the number of estimated parameters.
337      */
338     private int estimatedChiSqDegreesOfFreedom;
339 
340     /**
341      * Estimated reduced chi square value. This is equal to estimated chi square value divided by its degrees of
342      * freedom. Ideally this value should be close to 1.0.
343      */
344     private double estimatedReducedChiSq;
345 
346     /**
347      * Estimated probability of finding a smaller chi square value expressed as a value between 0.0 and 1.0. The smaller
348      * the found chi square value is, the better the fit of the estimated parameters to the actual parameter. Thus, the
349      * smaller the chance of finding a smaller chi square value, then the better the estimated fit is.
350      */
351     private double estimatedP;
352 
353     /**
354      * Estimated measure of quality of estimated fit as a value between 0.0 and 1.0. The larger the quality value is,
355      * the better the fit that has been estimated.
356      */
357     private double estimatedQ;
358 
359     /**
360      * Inner calibrator to compute calibration for each subset of data or during
361      * final refining.
362      */
363     private final KnownBiasAndGravityNormAccelerometerCalibrator innerCalibrator =
364             new KnownBiasAndGravityNormAccelerometerCalibrator();
365 
366     /**
367      * Contains 3x3 identify to be reused.
368      */
369     protected Matrix identity;
370 
371     /**
372      * Contains 3x3 temporary matrix.
373      */
374     protected Matrix tmp1;
375 
376     /**
377      * Contains 3x3 temporary matrix.
378      */
379     protected Matrix tmp2;
380 
381     /**
382      * Contains 3x1 temporary matrix.
383      */
384     protected Matrix tmp3;
385 
386     /**
387      * Contains 3x1 temporary matrix.
388      */
389     protected Matrix tmp4;
390 
391     /**
392      * Constructor.
393      */
394     protected RobustKnownBiasAndGravityNormAccelerometerCalibrator() {
395     }
396 
397     /**
398      * Constructor.
399      *
400      * @param listener listener to be notified of events such as when estimation
401      *                 starts, ends or its progress significantly changes.
402      */
403     protected RobustKnownBiasAndGravityNormAccelerometerCalibrator(
404             final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener) {
405         this.listener = listener;
406     }
407 
408     /**
409      * Constructor.
410      *
411      * @param measurements collection of body kinematics measurements with standard
412      *                     deviations taken at the same position with zero velocity
413      *                     and unknown different orientations.
414      */
415     protected RobustKnownBiasAndGravityNormAccelerometerCalibrator(
416             final List<StandardDeviationBodyKinematics> measurements) {
417         this.measurements = measurements;
418     }
419 
420 
421     /**
422      * Constructor.
423      *
424      * @param commonAxisUsed indicates whether z-axis is assumed to be common for
425      *                       accelerometer and gyroscope.
426      */
427     protected RobustKnownBiasAndGravityNormAccelerometerCalibrator(final boolean commonAxisUsed) {
428         this.commonAxisUsed = commonAxisUsed;
429     }
430 
431     /**
432      * Constructor.
433      *
434      * @param bias known accelerometer bias. This must have length 3 and is expressed
435      *             in meters per squared second (m/s^2).
436      * @throws IllegalArgumentException if provided bias array does not have length 3.
437      */
438     protected RobustKnownBiasAndGravityNormAccelerometerCalibrator(final double[] bias) {
439         try {
440             setBias(bias);
441         } catch (final LockedException ignore) {
442             // never happens
443         }
444     }
445 
446     /**
447      * Constructor.
448      *
449      * @param bias known accelerometer bias.
450      * @throws IllegalArgumentException if provided bias matrix is not 3x1.
451      */
452     protected RobustKnownBiasAndGravityNormAccelerometerCalibrator(final Matrix bias) {
453         try {
454             setBias(bias);
455         } catch (final LockedException ignore) {
456             // never happens
457         }
458     }
459 
460     /**
461      * Constructor.
462      *
463      * @param bias      known accelerometer bias.
464      * @param initialMa initial scale factors and cross coupling errors matrix.
465      * @throws IllegalArgumentException if either provided bias matrix is not 3x1 or
466      *                                  scaling and coupling error matrix is not 3x3.
467      */
468     protected RobustKnownBiasAndGravityNormAccelerometerCalibrator(final Matrix bias, final Matrix initialMa) {
469         this(bias);
470         try {
471             setInitialMa(initialMa);
472         } catch (final LockedException ignore) {
473             // never happens
474         }
475     }
476 
477     /**
478      * Constructor.
479      *
480      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
481      *                               squared second (m/s^2).
482      * @throws IllegalArgumentException if provided gravity norm value is negative.
483      */
484     protected RobustKnownBiasAndGravityNormAccelerometerCalibrator(final Double groundTruthGravityNorm) {
485         internalSetGroundTruthGravityNorm(groundTruthGravityNorm);
486     }
487 
488     /**
489      * Constructor.
490      *
491      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
492      *                               squared second (m/s^2).
493      * @param measurements           list of body kinematics measurements taken at a given position with
494      *                               different unknown orientations and containing the standard deviations
495      *                               of accelerometer and gyroscope measurements.
496      * @throws IllegalArgumentException if provided gravity norm value is negative.
497      */
498     protected RobustKnownBiasAndGravityNormAccelerometerCalibrator(
499             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements) {
500         this(measurements);
501         internalSetGroundTruthGravityNorm(groundTruthGravityNorm);
502     }
503 
504     /**
505      * Constructor.
506      *
507      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
508      *                               squared second (m/s^2).
509      * @param measurements           list of body kinematics measurements taken at a given position with
510      *                               different unknown orientations and containing the standard deviations
511      *                               of accelerometer and gyroscope measurements.
512      * @param listener               listener to be notified of events such as when estimation
513      *                               starts, ends or its progress significantly changes.
514      * @throws IllegalArgumentException if provided gravity norm value is negative.
515      */
516     protected RobustKnownBiasAndGravityNormAccelerometerCalibrator(
517             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
518             final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener) {
519         this(measurements);
520         internalSetGroundTruthGravityNorm(groundTruthGravityNorm);
521         this.listener = listener;
522     }
523 
524     /**
525      * Constructor.
526      *
527      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
528      *                               squared second (m/s^2).
529      * @param measurements           list of body kinematics measurements taken at a given position with
530      *                               different unknown orientations and containing the standard deviations
531      *                               of accelerometer and gyroscope measurements.
532      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
533      *                               accelerometer and gyroscope.
534      * @throws IllegalArgumentException if provided gravity norm value is negative.
535      */
536     protected RobustKnownBiasAndGravityNormAccelerometerCalibrator(
537             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
538             final boolean commonAxisUsed) {
539         this(measurements);
540         internalSetGroundTruthGravityNorm(groundTruthGravityNorm);
541         this.commonAxisUsed = commonAxisUsed;
542     }
543 
544     /**
545      * Constructor.
546      *
547      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
548      *                               squared second (m/s^2).
549      * @param measurements           list of body kinematics measurements taken at a given position with
550      *                               different unknown orientations and containing the standard deviations
551      *                               of accelerometer and gyroscope measurements.
552      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
553      *                               accelerometer and gyroscope.
554      * @param listener               listener to be notified of events such as when estimation
555      *                               starts, ends or its progress significantly changes.
556      * @throws IllegalArgumentException if provided gravity norm value is negative.
557      */
558     protected RobustKnownBiasAndGravityNormAccelerometerCalibrator(
559             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
560             final boolean commonAxisUsed, final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener) {
561         this(groundTruthGravityNorm, measurements, commonAxisUsed);
562         this.listener = listener;
563     }
564 
565     /**
566      * Constructor.
567      *
568      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
569      *                               squared second (m/s^2).
570      * @param measurements           collection of body kinematics measurements with standard
571      *                               deviations taken at the same position with zero velocity
572      *                               and unknown different orientations.
573      * @param bias                   known accelerometer bias. This must have length 3 and is expressed
574      *                               in meters per squared second (m/s^2).
575      * @throws IllegalArgumentException if provided bias array does not have length 3 or
576      *                                  if provided gravity norm value is negative.
577      */
578     protected RobustKnownBiasAndGravityNormAccelerometerCalibrator(
579             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
580             final double[] bias) {
581         this(bias);
582         internalSetGroundTruthGravityNorm(groundTruthGravityNorm);
583         this.measurements = measurements;
584     }
585 
586     /**
587      * Constructor.
588      *
589      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
590      *                               squared second (m/s^2).
591      * @param measurements           collection of body kinematics measurements with standard
592      *                               deviations taken at the same position with zero velocity
593      *                               and unknown different orientations.
594      * @param bias                   known accelerometer bias. This must have length 3 and is expressed
595      *                               in meters per squared second (m/s^2).
596      * @param listener               listener to handle events raised by this calibrator.
597      * @throws IllegalArgumentException if provided bias array does not have length 3 or
598      *                                  if provided gravity norm value is negative.
599      */
600     protected RobustKnownBiasAndGravityNormAccelerometerCalibrator(
601             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
602             final double[] bias, final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener) {
603         this(groundTruthGravityNorm, measurements, bias);
604         this.listener = listener;
605     }
606 
607     /**
608      * Constructor.
609      *
610      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
611      *                               squared second (m/s^2).
612      * @param measurements           collection of body kinematics measurements with standard
613      *                               deviations taken at the same position with zero velocity
614      *                               and unknown different orientations.
615      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
616      *                               accelerometer and gyroscope.
617      * @param bias                   known accelerometer bias. This must have length 3 and is expressed
618      *                               in meters per squared second (m/s^2).
619      * @throws IllegalArgumentException if provided bias array does not have length 3 or
620      *                                  if provided gravity norm value is negative.
621      */
622     protected RobustKnownBiasAndGravityNormAccelerometerCalibrator(
623             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
624             final boolean commonAxisUsed, final double[] bias) {
625         this(groundTruthGravityNorm, measurements, bias);
626         this.commonAxisUsed = commonAxisUsed;
627     }
628 
629     /**
630      * Constructor.
631      *
632      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
633      *                               squared second (m/s^2).
634      * @param measurements           collection of body kinematics measurements with standard
635      *                               deviations taken at the same position with zero velocity
636      *                               and unknown different orientations.
637      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
638      *                               accelerometer and gyroscope.
639      * @param bias                   known accelerometer bias. This must have length 3 and is
640      *                               expressed in meters per squared second (m/s^2).
641      * @param listener               listener to handle events raised by this calibrator.
642      * @throws IllegalArgumentException if provided bias array does not have length 3 or
643      *                                  if provided gravity norm value is negative.
644      */
645     protected RobustKnownBiasAndGravityNormAccelerometerCalibrator(
646             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
647             final boolean commonAxisUsed, final double[] bias,
648             final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener) {
649         this(groundTruthGravityNorm, measurements, commonAxisUsed, bias);
650         this.listener = listener;
651     }
652 
653     /**
654      * Constructor.
655      *
656      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
657      *                               squared second (m/s^2).
658      * @param measurements           collection of body kinematics measurements with standard
659      *                               deviations taken at the same position with zero velocity
660      *                               and unknown different orientations.
661      * @param bias                   known accelerometer bias.
662      * @throws IllegalArgumentException if provided bias matrix is not 3x1 or
663      *                                  if provided gravity norm value is negative.
664      */
665     protected RobustKnownBiasAndGravityNormAccelerometerCalibrator(
666             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
667             final Matrix bias) {
668         this(bias);
669         internalSetGroundTruthGravityNorm(groundTruthGravityNorm);
670         this.measurements = measurements;
671     }
672 
673     /**
674      * Constructor.
675      *
676      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
677      *                               squared second (m/s^2).
678      * @param measurements           collection of body kinematics measurements with standard
679      *                               deviations taken at the same position with zero velocity
680      *                               and unknown different orientations.
681      * @param bias                   known accelerometer bias.
682      * @param listener               listener to handle events raised by this calibrator.
683      * @throws IllegalArgumentException if provided bias matrix is not 3x1 or
684      *                                  if provided gravity norm value is negative.
685      */
686     protected RobustKnownBiasAndGravityNormAccelerometerCalibrator(
687             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
688             final Matrix bias, final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener) {
689         this(groundTruthGravityNorm, measurements, bias);
690         this.listener = listener;
691     }
692 
693     /**
694      * Constructor.
695      *
696      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
697      *                               squared second (m/s^2).
698      * @param measurements           collection of body kinematics measurements with standard
699      *                               deviations taken at the same position with zero velocity
700      *                               and unknown different orientations.
701      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
702      *                               accelerometer and gyroscope.
703      * @param bias                   known accelerometer bias.
704      * @throws IllegalArgumentException if provided bias matrix is not 3x1 or
705      *                                  if provided gravity norm value is negative.
706      */
707     protected RobustKnownBiasAndGravityNormAccelerometerCalibrator(
708             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
709             final boolean commonAxisUsed, final Matrix bias) {
710         this(groundTruthGravityNorm, measurements, bias);
711         this.commonAxisUsed = commonAxisUsed;
712     }
713 
714     /**
715      * Constructor.
716      *
717      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
718      *                               squared second (m/s^2).
719      * @param measurements           collection of body kinematics measurements with standard
720      *                               deviations taken at the same position with zero velocity
721      *                               and unknown different orientations.
722      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
723      *                               accelerometer and gyroscope.
724      * @param bias                   known accelerometer bias.
725      * @param listener               listener to handle events raised by this calibrator.
726      * @throws IllegalArgumentException if provided bias matrix is not 3x1 or
727      *                                  if provided gravity norm value is negative.
728      */
729     protected RobustKnownBiasAndGravityNormAccelerometerCalibrator(
730             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
731             final boolean commonAxisUsed, final Matrix bias,
732             final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener) {
733         this(groundTruthGravityNorm, measurements, commonAxisUsed, bias);
734         this.listener = listener;
735     }
736 
737     /**
738      * Constructor.
739      *
740      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
741      *                               squared second (m/s^2).
742      * @param measurements           collection of body kinematics measurements with standard
743      *                               deviations taken at the same position with zero velocity
744      *                               and unknown different orientations.
745      * @param bias                   known accelerometer bias.
746      * @param initialMa              initial scale factors and cross coupling errors matrix.
747      * @throws IllegalArgumentException if either provided bias matrix is not 3x1 or
748      *                                  scaling and coupling error matrix is not 3x3 or
749      *                                  if provided gravity norm value is negative.
750      */
751     protected RobustKnownBiasAndGravityNormAccelerometerCalibrator(
752             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
753             final Matrix bias, final Matrix initialMa) {
754         this(bias, initialMa);
755         internalSetGroundTruthGravityNorm(groundTruthGravityNorm);
756         this.measurements = measurements;
757     }
758 
759     /**
760      * Constructor.
761      *
762      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
763      *                               squared second (m/s^2).
764      * @param measurements           collection of body kinematics measurements with standard
765      *                               deviations taken at the same position with zero velocity
766      *                               and unknown different orientations.
767      * @param bias                   known accelerometer bias.
768      * @param initialMa              initial scale factors and cross coupling errors matrix.
769      * @param listener               listener to handle events raised by this calibrator.
770      * @throws IllegalArgumentException if either provided bias matrix is not 3x1 or
771      *                                  scaling and coupling error matrix is not 3x3 or
772      *                                  if provided gravity norm value is negative.
773      */
774     protected RobustKnownBiasAndGravityNormAccelerometerCalibrator(
775             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
776             final Matrix bias, final Matrix initialMa,
777             final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener) {
778         this(groundTruthGravityNorm, measurements, bias, initialMa);
779         this.listener = listener;
780     }
781 
782     /**
783      * Constructor.
784      *
785      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
786      *                               squared second (m/s^2).
787      * @param measurements           collection of body kinematics measurements with standard
788      *                               deviations taken at the same position with zero velocity
789      *                               and unknown different orientations.
790      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
791      *                               accelerometer and gyroscope.
792      * @param bias                   known accelerometer bias.
793      * @param initialMa              initial scale factors and cross coupling errors matrix.
794      * @throws IllegalArgumentException if either provided bias matrix is not 3x1 or
795      *                                  scaling and coupling error matrix is not 3x3 or
796      *                                  if provided gravity norm value is negative.
797      */
798     protected RobustKnownBiasAndGravityNormAccelerometerCalibrator(
799             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
800             final boolean commonAxisUsed, final Matrix bias, final Matrix initialMa) {
801         this(groundTruthGravityNorm, measurements, bias, initialMa);
802         this.commonAxisUsed = commonAxisUsed;
803     }
804 
805     /**
806      * Constructor.
807      *
808      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
809      *                               squared second (m/s^2).
810      * @param measurements           collection of body kinematics measurements with standard
811      *                               deviations taken at the same position with zero velocity
812      *                               and unknown different orientations.
813      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
814      *                               accelerometer and gyroscope.
815      * @param bias                   known accelerometer bias.
816      * @param initialMa              initial scale factors and cross coupling errors matrix.
817      * @param listener               listener to handle events raised by this calibrator.
818      * @throws IllegalArgumentException if either provided bias matrix is not 3x1 or
819      *                                  scaling and coupling error matrix is not 3x3 or
820      *                                  if provided gravity norm value is negative.
821      */
822     protected RobustKnownBiasAndGravityNormAccelerometerCalibrator(
823             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
824             final boolean commonAxisUsed, final Matrix bias, final Matrix initialMa,
825             final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener) {
826         this(groundTruthGravityNorm, measurements, commonAxisUsed, bias, initialMa);
827         this.listener = listener;
828     }
829 
830     /**
831      * Constructor.
832      *
833      * @param groundTruthGravityNorm ground truth gravity norm.
834      * @throws IllegalArgumentException if provided gravity norm value is negative.
835      */
836     protected RobustKnownBiasAndGravityNormAccelerometerCalibrator(final Acceleration groundTruthGravityNorm) {
837         this(convertAcceleration(groundTruthGravityNorm));
838     }
839 
840     /**
841      * Constructor.
842      *
843      * @param groundTruthGravityNorm ground truth gravity norm.
844      * @param measurements           list of body kinematics measurements taken at a given position with
845      *                               different unknown orientations and containing the standard deviations
846      *                               of accelerometer and gyroscope measurements.
847      * @throws IllegalArgumentException if provided gravity norm value is negative.
848      */
849     protected RobustKnownBiasAndGravityNormAccelerometerCalibrator(
850             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements) {
851         this(convertAcceleration(groundTruthGravityNorm), measurements);
852     }
853 
854     /**
855      * Constructor.
856      *
857      * @param groundTruthGravityNorm ground truth gravity norm.
858      * @param measurements           list of body kinematics measurements taken at a given position with
859      *                               different unknown orientations and containing the standard deviations
860      *                               of accelerometer and gyroscope measurements.
861      * @param listener               listener to be notified of events such as when estimation
862      *                               starts, ends or its progress significantly changes.
863      * @throws IllegalArgumentException if provided gravity norm value is negative.
864      */
865     protected RobustKnownBiasAndGravityNormAccelerometerCalibrator(
866             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
867             final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener) {
868         this(convertAcceleration(groundTruthGravityNorm), measurements, listener);
869     }
870 
871     /**
872      * Constructor.
873      *
874      * @param groundTruthGravityNorm ground truth gravity norm.
875      * @param measurements           list of body kinematics measurements taken at a given position with
876      *                               different unknown orientations and containing the standard deviations
877      *                               of accelerometer and gyroscope measurements.
878      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
879      *                               accelerometer and gyroscope.
880      * @throws IllegalArgumentException if provided gravity norm value is negative.
881      */
882     protected RobustKnownBiasAndGravityNormAccelerometerCalibrator(
883             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
884             final boolean commonAxisUsed) {
885         this(convertAcceleration(groundTruthGravityNorm), measurements, commonAxisUsed);
886     }
887 
888     /**
889      * Constructor.
890      *
891      * @param groundTruthGravityNorm ground truth gravity norm.
892      * @param measurements           list of body kinematics measurements taken at a given position with
893      *                               different unknown orientations and containing the standard deviations
894      *                               of accelerometer and gyroscope measurements.
895      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
896      *                               accelerometer and gyroscope.
897      * @param listener               listener to be notified of events such as when estimation
898      *                               starts, ends or its progress significantly changes.
899      * @throws IllegalArgumentException if provided gravity norm value is negative.
900      */
901     protected RobustKnownBiasAndGravityNormAccelerometerCalibrator(
902             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
903             final boolean commonAxisUsed, final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener) {
904         this(convertAcceleration(groundTruthGravityNorm), measurements, commonAxisUsed, listener);
905     }
906 
907     /**
908      * Constructor.
909      *
910      * @param groundTruthGravityNorm ground truth gravity norm.
911      * @param measurements           collection of body kinematics measurements with standard
912      *                               deviations taken at the same position with zero velocity
913      *                               and unknown different orientations.
914      * @param bias                   known accelerometer bias. This must have length 3 and is expressed
915      *                               in meters per squared second (m/s^2).
916      * @throws IllegalArgumentException if provided bias array does not have length 3 or
917      *                                  if provided gravity norm value is negative.
918      */
919     protected RobustKnownBiasAndGravityNormAccelerometerCalibrator(
920             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
921             final double[] bias) {
922         this(convertAcceleration(groundTruthGravityNorm), measurements, bias);
923     }
924 
925     /**
926      * Constructor.
927      *
928      * @param groundTruthGravityNorm ground truth gravity norm.
929      * @param measurements           collection of body kinematics measurements with standard
930      *                               deviations taken at the same position with zero velocity
931      *                               and unknown different orientations.
932      * @param bias                   known accelerometer bias. This must have length 3 and is expressed
933      *                               in meters per squared second (m/s^2).
934      * @param listener               listener to handle events raised by this calibrator.
935      * @throws IllegalArgumentException if provided bias array does not have length 3 or
936      *                                  if provided gravity norm value is negative.
937      */
938     protected RobustKnownBiasAndGravityNormAccelerometerCalibrator(
939             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
940             final double[] bias, final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener) {
941         this(convertAcceleration(groundTruthGravityNorm), measurements, bias, listener);
942     }
943 
944     /**
945      * Constructor.
946      *
947      * @param groundTruthGravityNorm ground truth gravity norm.
948      * @param measurements           collection of body kinematics measurements with standard
949      *                               deviations taken at the same position with zero velocity
950      *                               and unknown different orientations.
951      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
952      *                               accelerometer and gyroscope.
953      * @param bias                   known accelerometer bias. This must have length 3 and is expressed
954      *                               in meters per squared second (m/s^2).
955      * @throws IllegalArgumentException if provided bias array does not have length 3 or
956      *                                  if provided gravity norm value is negative.
957      */
958     protected RobustKnownBiasAndGravityNormAccelerometerCalibrator(
959             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
960             final boolean commonAxisUsed, final double[] bias) {
961         this(convertAcceleration(groundTruthGravityNorm), measurements, commonAxisUsed, bias);
962     }
963 
964     /**
965      * Constructor.
966      *
967      * @param groundTruthGravityNorm ground truth gravity norm.
968      * @param measurements           collection of body kinematics measurements with standard
969      *                               deviations taken at the same position with zero velocity
970      *                               and unknown different orientations.
971      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
972      *                               accelerometer and gyroscope.
973      * @param bias                   known accelerometer bias. This must have length 3 and is expressed
974      *                               in meters per squared second (m/s^2).
975      * @param listener               listener to handle events raised by this calibrator.
976      * @throws IllegalArgumentException if provided bias array does not have length 3 or
977      *                                  if provided gravity norm value is negative.
978      */
979     protected RobustKnownBiasAndGravityNormAccelerometerCalibrator(
980             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
981             final boolean commonAxisUsed, final double[] bias,
982             final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener) {
983         this(convertAcceleration(groundTruthGravityNorm), measurements, commonAxisUsed, bias, listener);
984     }
985 
986     /**
987      * Constructor.
988      *
989      * @param groundTruthGravityNorm ground truth gravity norm.
990      * @param measurements           collection of body kinematics measurements with standard
991      *                               deviations taken at the same position with zero velocity
992      *                               and unknown different orientations.
993      * @param bias                   known accelerometer bias.
994      * @throws IllegalArgumentException if provided bias matrix is not 3x1 or
995      *                                  if provided gravity norm value is negative.
996      */
997     protected RobustKnownBiasAndGravityNormAccelerometerCalibrator(
998             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
999             final Matrix bias) {
1000         this(convertAcceleration(groundTruthGravityNorm), measurements, bias);
1001     }
1002 
1003     /**
1004      * Constructor.
1005      *
1006      * @param groundTruthGravityNorm ground truth gravity norm.
1007      * @param measurements           collection of body kinematics measurements with standard
1008      *                               deviations taken at the same position with zero velocity
1009      *                               and unknown different orientations.
1010      * @param bias                   known accelerometer bias.
1011      * @param listener               listener to handle events raised by this calibrator.
1012      * @throws IllegalArgumentException if provided bias matrix is not 3x1 or
1013      *                                  if provided gravity norm value is negative.
1014      */
1015     protected RobustKnownBiasAndGravityNormAccelerometerCalibrator(
1016             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
1017             final Matrix bias, final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener) {
1018         this(convertAcceleration(groundTruthGravityNorm), measurements, bias, listener);
1019     }
1020 
1021     /**
1022      * Constructor.
1023      *
1024      * @param groundTruthGravityNorm ground truth gravity norm.
1025      * @param measurements           collection of body kinematics measurements with standard
1026      *                               deviations taken at the same position with zero velocity
1027      *                               and unknown different orientations.
1028      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
1029      *                               accelerometer and gyroscope.
1030      * @param bias                   known accelerometer bias.
1031      * @throws IllegalArgumentException if provided bias matrix is not 3x1 or
1032      *                                  if provided gravity norm value is negative.
1033      */
1034     protected RobustKnownBiasAndGravityNormAccelerometerCalibrator(
1035             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
1036             final boolean commonAxisUsed, final Matrix bias) {
1037         this(convertAcceleration(groundTruthGravityNorm), measurements, commonAxisUsed, bias);
1038     }
1039 
1040     /**
1041      * Constructor.
1042      *
1043      * @param groundTruthGravityNorm ground truth gravity norm.
1044      * @param measurements           collection of body kinematics measurements with standard
1045      *                               deviations taken at the same position with zero velocity
1046      *                               and unknown different orientations.
1047      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
1048      *                               accelerometer and gyroscope.
1049      * @param bias                   known accelerometer bias.
1050      * @param listener               listener to handle events raised by this calibrator.
1051      * @throws IllegalArgumentException if provided bias matrix is not 3x1 or
1052      *                                  if provided gravity norm value is negative.
1053      */
1054     protected RobustKnownBiasAndGravityNormAccelerometerCalibrator(
1055             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
1056             final boolean commonAxisUsed, final Matrix bias,
1057             final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener) {
1058         this(convertAcceleration(groundTruthGravityNorm), measurements, commonAxisUsed, bias, listener);
1059     }
1060 
1061     /**
1062      * Constructor.
1063      *
1064      * @param groundTruthGravityNorm ground truth gravity norm.
1065      * @param measurements           collection of body kinematics measurements with standard
1066      *                               deviations taken at the same position with zero velocity
1067      *                               and unknown different orientations.
1068      * @param bias                   known accelerometer bias.
1069      * @param initialMa              initial scale factors and cross coupling errors matrix.
1070      * @throws IllegalArgumentException if either provided bias matrix is not 3x1 or
1071      *                                  scaling and coupling error matrix is not 3x3 or
1072      *                                  if provided gravity norm value is negative.
1073      */
1074     protected RobustKnownBiasAndGravityNormAccelerometerCalibrator(
1075             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
1076             final Matrix bias, final Matrix initialMa) {
1077         this(convertAcceleration(groundTruthGravityNorm), measurements, bias, initialMa);
1078     }
1079 
1080     /**
1081      * Constructor.
1082      *
1083      * @param groundTruthGravityNorm ground truth gravity norm.
1084      * @param measurements           collection of body kinematics measurements with standard
1085      *                               deviations taken at the same position with zero velocity
1086      *                               and unknown different orientations.
1087      * @param bias                   known accelerometer bias.
1088      * @param initialMa              initial scale factors and cross coupling errors matrix.
1089      * @param listener               listener to handle events raised by this calibrator.
1090      * @throws IllegalArgumentException if either provided bias matrix is not 3x1 or
1091      *                                  scaling and coupling error matrix is not 3x3 or
1092      *                                  if provided gravity norm value is negative.
1093      */
1094     protected RobustKnownBiasAndGravityNormAccelerometerCalibrator(
1095             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
1096             final Matrix bias, final Matrix initialMa,
1097             final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener) {
1098         this(convertAcceleration(groundTruthGravityNorm), measurements, bias, initialMa, listener);
1099     }
1100 
1101     /**
1102      * Constructor.
1103      *
1104      * @param groundTruthGravityNorm ground truth gravity norm.
1105      * @param measurements           collection of body kinematics measurements with standard
1106      *                               deviations taken at the same position with zero velocity
1107      *                               and unknown different orientations.
1108      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
1109      *                               accelerometer and gyroscope.
1110      * @param bias                   known accelerometer bias.
1111      * @param initialMa              initial scale factors and cross coupling errors matrix.
1112      * @throws IllegalArgumentException if either provided bias matrix is not 3x1 or
1113      *                                  scaling and coupling error matrix is not 3x3 or
1114      *                                  if provided gravity norm value is negative.
1115      */
1116     protected RobustKnownBiasAndGravityNormAccelerometerCalibrator(
1117             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
1118             final boolean commonAxisUsed, final Matrix bias, final Matrix initialMa) {
1119         this(convertAcceleration(groundTruthGravityNorm), measurements, commonAxisUsed, bias, initialMa);
1120     }
1121 
1122     /**
1123      * Constructor.
1124      *
1125      * @param groundTruthGravityNorm ground truth gravity norm.
1126      * @param measurements           collection of body kinematics measurements with standard
1127      *                               deviations taken at the same position with zero velocity
1128      *                               and unknown different orientations.
1129      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
1130      *                               accelerometer and gyroscope.
1131      * @param bias                   known accelerometer bias.
1132      * @param initialMa              initial scale factors and cross coupling errors matrix.
1133      * @param listener               listener to handle events raised by this calibrator.
1134      * @throws IllegalArgumentException if either provided bias matrix is not 3x1 or
1135      *                                  scaling and coupling error matrix is not 3x3 or
1136      *                                  if provided gravity norm value is negative.
1137      */
1138     protected RobustKnownBiasAndGravityNormAccelerometerCalibrator(
1139             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
1140             final boolean commonAxisUsed, final Matrix bias, final Matrix initialMa,
1141             final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener) {
1142         this(convertAcceleration(groundTruthGravityNorm), measurements, commonAxisUsed, bias, initialMa, listener);
1143     }
1144 
1145     /**
1146      * Gets x-coordinate of known accelerometer bias.
1147      * This is expressed in meters per squared second (m/s^2).
1148      *
1149      * @return x-coordinate of known accelerometer bias.
1150      */
1151     @Override
1152     public double getBiasX() {
1153         return biasX;
1154     }
1155 
1156     /**
1157      * Sets x-coordinate of known accelerometer bias.
1158      * This is expressed in meters per squared second (m/s^2).
1159      *
1160      * @param biasX x-coordinate of known accelerometer bias.
1161      * @throws LockedException if calibrator is currently running.
1162      */
1163     @Override
1164     public void setBiasX(final double biasX) throws LockedException {
1165         if (running) {
1166             throw new LockedException();
1167         }
1168         this.biasX = biasX;
1169     }
1170 
1171     /**
1172      * Gets y-coordinate of known accelerometer bias.
1173      * This is expressed in meters per squared second (m/s^2).
1174      *
1175      * @return y-coordinate of known accelerometer bias.
1176      */
1177     @Override
1178     public double getBiasY() {
1179         return biasY;
1180     }
1181 
1182     /**
1183      * Sets y-coordinate of known accelerometer bias.
1184      * This is expressed in meters per squared second (m/s^2).
1185      *
1186      * @param biasY y-coordinate of known accelerometer bias.
1187      * @throws LockedException if calibrator is currently running.
1188      */
1189     @Override
1190     public void setBiasY(final double biasY) throws LockedException {
1191         if (running) {
1192             throw new LockedException();
1193         }
1194         this.biasY = biasY;
1195     }
1196 
1197     /**
1198      * Gets z-coordinate of known accelerometer bias.
1199      * This is expressed in meters per squared second (m/s^2).
1200      *
1201      * @return z-coordinate of known accelerometer bias.
1202      */
1203     @Override
1204     public double getBiasZ() {
1205         return biasZ;
1206     }
1207 
1208     /**
1209      * Sets z-coordinate of known accelerometer bias.
1210      * This is expressed in meters per squared second (m/s^2).
1211      *
1212      * @param biasZ z-coordinate of known accelerometer bias.
1213      * @throws LockedException if calibrator is currently running.
1214      */
1215     @Override
1216     public void setBiasZ(final double biasZ) throws LockedException {
1217         if (running) {
1218             throw new LockedException();
1219         }
1220         this.biasZ = biasZ;
1221     }
1222 
1223     /**
1224      * Gets x-coordinate of known accelerometer bias.
1225      *
1226      * @return x-coordinate of known accelerometer bias.
1227      */
1228     @Override
1229     public Acceleration getBiasXAsAcceleration() {
1230         return new Acceleration(biasX, AccelerationUnit.METERS_PER_SQUARED_SECOND);
1231     }
1232 
1233     /**
1234      * Gets x-coordinate of known accelerometer bias.
1235      *
1236      * @param result instance where result data will be stored.
1237      */
1238     @Override
1239     public void getBiasXAsAcceleration(final Acceleration result) {
1240         result.setValue(biasX);
1241         result.setUnit(AccelerationUnit.METERS_PER_SQUARED_SECOND);
1242     }
1243 
1244     /**
1245      * Sets x-coordinate of known accelerometer bias.
1246      *
1247      * @param biasX x-coordinate of known accelerometer bias.
1248      * @throws LockedException if calibrator is currently running.
1249      */
1250     @Override
1251     public void setBiasX(final Acceleration biasX) throws LockedException {
1252         if (running) {
1253             throw new LockedException();
1254         }
1255         this.biasX = convertAcceleration(biasX);
1256     }
1257 
1258     /**
1259      * Gets y-coordinate of known accelerometer bias.
1260      *
1261      * @return y-coordinate of known accelerometer bias.
1262      */
1263     @Override
1264     public Acceleration getBiasYAsAcceleration() {
1265         return new Acceleration(biasY, AccelerationUnit.METERS_PER_SQUARED_SECOND);
1266     }
1267 
1268     /**
1269      * Gets y-coordinate of known accelerometer bias.
1270      *
1271      * @param result instance where result data will be stored.
1272      */
1273     @Override
1274     public void getBiasYAsAcceleration(final Acceleration result) {
1275         result.setValue(biasY);
1276         result.setUnit(AccelerationUnit.METERS_PER_SQUARED_SECOND);
1277     }
1278 
1279     /**
1280      * Sets y-coordinate of known accelerometer bias.
1281      *
1282      * @param biasY y-coordinate of known accelerometer bias.
1283      * @throws LockedException if calibrator is currently running.
1284      */
1285     @Override
1286     public void setBiasY(final Acceleration biasY) throws LockedException {
1287         if (running) {
1288             throw new LockedException();
1289         }
1290         this.biasY = convertAcceleration(biasY);
1291     }
1292 
1293     /**
1294      * Gets z-coordinate of known accelerometer bias.
1295      *
1296      * @return z-coordinate of known accelerometer bias.
1297      */
1298     @Override
1299     public Acceleration getBiasZAsAcceleration() {
1300         return new Acceleration(biasZ, AccelerationUnit.METERS_PER_SQUARED_SECOND);
1301     }
1302 
1303     /**
1304      * Gets z-coordinate of known accelerometer bias.
1305      *
1306      * @param result instance where result data will be stored.
1307      */
1308     @Override
1309     public void getBiasZAsAcceleration(final Acceleration result) {
1310         result.setValue(biasZ);
1311         result.setUnit(AccelerationUnit.METERS_PER_SQUARED_SECOND);
1312     }
1313 
1314     /**
1315      * Sets z-coordinate of known accelerometer bias to be used to find a solution.
1316      *
1317      * @param biasZ z-coordinate of known accelerometer bias.
1318      * @throws LockedException if calibrator is currently running.
1319      */
1320     @Override
1321     public void setBiasZ(final Acceleration biasZ) throws LockedException {
1322         if (running) {
1323             throw new LockedException();
1324         }
1325         this.biasZ = convertAcceleration(biasZ);
1326     }
1327 
1328     /**
1329      * Sets known bias coordinates of accelerometer expressed in meters
1330      * per squared second (m/s^2).
1331      *
1332      * @param biasX x-coordinate of known accelerometer bias.
1333      * @param biasY y-coordinate of known accelerometer bias.
1334      * @param biasZ z-coordinate of known accelerometer bias.
1335      * @throws LockedException if calibrator is currently running.
1336      */
1337     @Override
1338     public void setBiasCoordinates(final double biasX, final double biasY, final double biasZ) throws LockedException {
1339         if (running) {
1340             throw new LockedException();
1341         }
1342         this.biasX = biasX;
1343         this.biasY = biasY;
1344         this.biasZ = biasZ;
1345     }
1346 
1347     /**
1348      * Sets known bias coordinates of accelerometer.
1349      *
1350      * @param biasX x-coordinate of known accelerometer bias.
1351      * @param biasY y-coordinate of known accelerometer bias.
1352      * @param biasZ z-coordinate of known accelerometer bias.
1353      * @throws LockedException if calibrator is currently running.
1354      */
1355     @Override
1356     public void setBiasCoordinates(final Acceleration biasX, final Acceleration biasY, final Acceleration biasZ)
1357             throws LockedException {
1358         if (running) {
1359             throw new LockedException();
1360         }
1361         this.biasX = convertAcceleration(biasX);
1362         this.biasY = convertAcceleration(biasY);
1363         this.biasZ = convertAcceleration(biasZ);
1364     }
1365 
1366     /**
1367      * Gets known accelerometer bias.
1368      *
1369      * @return known accelerometer bias.
1370      */
1371     @Override
1372     public AccelerationTriad getBiasAsTriad() {
1373         return new AccelerationTriad(AccelerationUnit.METERS_PER_SQUARED_SECOND, biasX, biasY, biasZ);
1374     }
1375 
1376     /**
1377      * Gets known accelerometer bias.
1378      *
1379      * @param result instance where result will be stored.
1380      */
1381     @Override
1382     public void getBiasAsTriad(final AccelerationTriad result) {
1383         result.setValueCoordinatesAndUnit(biasX, biasY, biasZ, AccelerationUnit.METERS_PER_SQUARED_SECOND);
1384     }
1385 
1386     /**
1387      * Sets known accelerometer bias.
1388      *
1389      * @param bias accelerometer bias to be set.
1390      * @throws LockedException if calibrator is currently running.
1391      */
1392     @Override
1393     public void setBias(final AccelerationTriad bias) throws LockedException {
1394         if (running) {
1395             throw new LockedException();
1396         }
1397 
1398         biasX = convertAcceleration(bias.getValueX(), bias.getUnit());
1399         biasY = convertAcceleration(bias.getValueY(), bias.getUnit());
1400         biasZ = convertAcceleration(bias.getValueZ(), bias.getUnit());
1401     }
1402 
1403     /**
1404      * Gets initial x scaling factor.
1405      * This is only taken into account if non-linear preliminary solutions are used.
1406      *
1407      * @return initial x scaling factor.
1408      */
1409     @Override
1410     public double getInitialSx() {
1411         return initialSx;
1412     }
1413 
1414     /**
1415      * Sets initial x scaling factor.
1416      * This is only taken into account if non-linear preliminary solutions are used.
1417      *
1418      * @param initialSx initial x scaling factor.
1419      * @throws LockedException if calibrator is currently running.
1420      */
1421     @Override
1422     public void setInitialSx(final double initialSx) throws LockedException {
1423         if (running) {
1424             throw new LockedException();
1425         }
1426         this.initialSx = initialSx;
1427     }
1428 
1429     /**
1430      * Gets initial y scaling factor.
1431      * This is only taken into account if non-linear preliminary solutions are used.
1432      *
1433      * @return initial y scaling factor.
1434      */
1435     @Override
1436     public double getInitialSy() {
1437         return initialSy;
1438     }
1439 
1440     /**
1441      * Sets initial y scaling factor.
1442      * This is only taken into account if non-linear preliminary solutions are used.
1443      *
1444      * @param initialSy initial y scaling factor.
1445      * @throws LockedException if calibrator is currently running.
1446      */
1447     @Override
1448     public void setInitialSy(final double initialSy) throws LockedException {
1449         if (running) {
1450             throw new LockedException();
1451         }
1452         this.initialSy = initialSy;
1453     }
1454 
1455     /**
1456      * Gets initial z scaling factor.
1457      * This is only taken into account if non-linear preliminary solutions are used.
1458      *
1459      * @return initial z scaling factor.
1460      */
1461     @Override
1462     public double getInitialSz() {
1463         return initialSz;
1464     }
1465 
1466     /**
1467      * Sets initial z scaling factor.
1468      * This is only taken into account if non-linear preliminary solutions are used.
1469      *
1470      * @param initialSz initial z scaling factor.
1471      * @throws LockedException if calibrator is currently running.
1472      */
1473     @Override
1474     public void setInitialSz(final double initialSz) throws LockedException {
1475         if (running) {
1476             throw new LockedException();
1477         }
1478         this.initialSz = initialSz;
1479     }
1480 
1481     /**
1482      * Gets initial x-y cross coupling error.
1483      * This is only taken into account if non-linear preliminary solutions are used.
1484      *
1485      * @return initial x-y cross coupling error.
1486      */
1487     @Override
1488     public double getInitialMxy() {
1489         return initialMxy;
1490     }
1491 
1492     /**
1493      * Sets initial x-y cross coupling error.
1494      * This is only taken into account if non-linear preliminary solutions are used.
1495      *
1496      * @param initialMxy initial x-y cross coupling error.
1497      * @throws LockedException if calibrator is currently running.
1498      */
1499     @Override
1500     public void setInitialMxy(final double initialMxy) throws LockedException {
1501         if (running) {
1502             throw new LockedException();
1503         }
1504         this.initialMxy = initialMxy;
1505     }
1506 
1507     /**
1508      * Gets initial x-z cross coupling error.
1509      * This is only taken into account if non-linear preliminary solutions are used.
1510      *
1511      * @return initial x-z cross coupling error.
1512      */
1513     @Override
1514     public double getInitialMxz() {
1515         return initialMxz;
1516     }
1517 
1518     /**
1519      * Sets initial x-z cross coupling error.
1520      * This is only taken into account if non-linear preliminary solutions are used.
1521      *
1522      * @param initialMxz initial x-z cross coupling error.
1523      * @throws LockedException if calibrator is currently running.
1524      */
1525     @Override
1526     public void setInitialMxz(final double initialMxz) throws LockedException {
1527         if (running) {
1528             throw new LockedException();
1529         }
1530         this.initialMxz = initialMxz;
1531     }
1532 
1533     /**
1534      * Gets initial y-x cross coupling error.
1535      * This is only taken into account if non-linear preliminary solutions are used.
1536      *
1537      * @return initial y-x cross coupling error.
1538      */
1539     @Override
1540     public double getInitialMyx() {
1541         return initialMyx;
1542     }
1543 
1544     /**
1545      * Sets initial y-x cross coupling error.
1546      * This is only taken into account if non-linear preliminary solutions are used.
1547      *
1548      * @param initialMyx initial y-x cross coupling error.
1549      * @throws LockedException if calibrator is currently running.
1550      */
1551     @Override
1552     public void setInitialMyx(final double initialMyx) throws LockedException {
1553         if (running) {
1554             throw new LockedException();
1555         }
1556         this.initialMyx = initialMyx;
1557     }
1558 
1559     /**
1560      * Gets initial y-z cross coupling error.
1561      * This is only taken into account if non-linear preliminary solutions are used.
1562      *
1563      * @return initial y-z cross coupling error.
1564      */
1565     @Override
1566     public double getInitialMyz() {
1567         return initialMyz;
1568     }
1569 
1570     /**
1571      * Sets initial y-z cross coupling error.
1572      * This is only taken into account if non-linear preliminary solutions are used.
1573      *
1574      * @param initialMyz initial y-z cross coupling error.
1575      * @throws LockedException if calibrator is currently running.
1576      */
1577     @Override
1578     public void setInitialMyz(final double initialMyz) throws LockedException {
1579         if (running) {
1580             throw new LockedException();
1581         }
1582         this.initialMyz = initialMyz;
1583     }
1584 
1585     /**
1586      * Gets initial z-x cross coupling error.
1587      * This is only taken into account if non-linear preliminary solutions are used.
1588      *
1589      * @return initial z-x cross coupling error.
1590      */
1591     @Override
1592     public double getInitialMzx() {
1593         return initialMzx;
1594     }
1595 
1596     /**
1597      * Sets initial z-x cross coupling error.
1598      * This is only taken into account if non-linear preliminary solutions are used.
1599      *
1600      * @param initialMzx initial z-x cross coupling error.
1601      * @throws LockedException if calibrator is currently running.
1602      */
1603     @Override
1604     public void setInitialMzx(final double initialMzx) throws LockedException {
1605         if (running) {
1606             throw new LockedException();
1607         }
1608         this.initialMzx = initialMzx;
1609     }
1610 
1611     /**
1612      * Gets initial z-y cross coupling error.
1613      * This is only taken into account if non-linear preliminary solutions are used.
1614      *
1615      * @return initial z-y cross coupling error.
1616      */
1617     @Override
1618     public double getInitialMzy() {
1619         return initialMzy;
1620     }
1621 
1622     /**
1623      * Sets initial z-y cross coupling error.
1624      * This is only taken into account if non-linear preliminary solutions are used.
1625      *
1626      * @param initialMzy initial z-y cross coupling error.
1627      * @throws LockedException if calibrator is currently running.
1628      */
1629     @Override
1630     public void setInitialMzy(final double initialMzy) throws LockedException {
1631         if (running) {
1632             throw new LockedException();
1633         }
1634         this.initialMzy = initialMzy;
1635     }
1636 
1637     /**
1638      * Sets initial scaling factors.
1639      * This is only taken into account if non-linear preliminary solutions are used.
1640      *
1641      * @param initialSx initial x scaling factor.
1642      * @param initialSy initial y scaling factor.
1643      * @param initialSz initial z scaling factor.
1644      * @throws LockedException if calibrator is currently running.
1645      */
1646     @Override
1647     public void setInitialScalingFactors(final double initialSx, final double initialSy, final double initialSz)
1648             throws LockedException {
1649         if (running) {
1650             throw new LockedException();
1651         }
1652         this.initialSx = initialSx;
1653         this.initialSy = initialSy;
1654         this.initialSz = initialSz;
1655     }
1656 
1657     /**
1658      * Sets initial cross coupling errors.
1659      * This is only taken into account if non-linear preliminary solutions are used.
1660      *
1661      * @param initialMxy initial x-y cross coupling error.
1662      * @param initialMxz initial x-z cross coupling error.
1663      * @param initialMyx initial y-x cross coupling error.
1664      * @param initialMyz initial y-z cross coupling error.
1665      * @param initialMzx initial z-x cross coupling error.
1666      * @param initialMzy initial z-y cross coupling error.
1667      * @throws LockedException if calibrator is currently running.
1668      */
1669     @Override
1670     public void setInitialCrossCouplingErrors(
1671             final double initialMxy, final double initialMxz, final double initialMyx,
1672             final double initialMyz, final double initialMzx, final double initialMzy) throws LockedException {
1673         if (running) {
1674             throw new LockedException();
1675         }
1676         this.initialMxy = initialMxy;
1677         this.initialMxz = initialMxz;
1678         this.initialMyx = initialMyx;
1679         this.initialMyz = initialMyz;
1680         this.initialMzx = initialMzx;
1681         this.initialMzy = initialMzy;
1682     }
1683 
1684     /**
1685      * Sets initial scaling factors and cross coupling errors.
1686      * This is only taken into account if non-linear preliminary solutions are used.
1687      *
1688      * @param initialSx  initial x scaling factor.
1689      * @param initialSy  initial y scaling factor.
1690      * @param initialSz  initial z scaling factor.
1691      * @param initialMxy initial x-y cross coupling error.
1692      * @param initialMxz initial x-z cross coupling error.
1693      * @param initialMyx initial y-x cross coupling error.
1694      * @param initialMyz initial y-z cross coupling error.
1695      * @param initialMzx initial z-x cross coupling error.
1696      * @param initialMzy initial z-y cross coupling error.
1697      * @throws LockedException if calibrator is currently running.
1698      */
1699     @Override
1700     public void setInitialScalingFactorsAndCrossCouplingErrors(
1701             final double initialSx, final double initialSy, final double initialSz,
1702             final double initialMxy, final double initialMxz, final double initialMyx,
1703             final double initialMyz, final double initialMzx, final double initialMzy) throws LockedException {
1704         if (running) {
1705             throw new LockedException();
1706         }
1707         setInitialScalingFactors(initialSx, initialSy, initialSz);
1708         setInitialCrossCouplingErrors(initialMxy, initialMxz, initialMyx, initialMyz, initialMzx, initialMzy);
1709     }
1710 
1711     /**
1712      * Gets known bias as an array.
1713      * Array values are expressed in meters per squared second (m/s^2).
1714      *
1715      * @return array containing coordinates of known bias.
1716      */
1717     @Override
1718     public double[] getBias() {
1719         final var result = new double[BodyKinematics.COMPONENTS];
1720         getBias(result);
1721         return result;
1722     }
1723 
1724     /**
1725      * Gets known bias as an array.
1726      * Array values are expressed in meters per squared second (m/s^2).
1727      *
1728      * @param result instance where result data will be copied to.
1729      * @throws IllegalArgumentException if provided array does not have length 3.
1730      */
1731     @Override
1732     public void getBias(final double[] result) {
1733         if (result.length != BodyKinematics.COMPONENTS) {
1734             throw new IllegalArgumentException();
1735         }
1736         result[0] = biasX;
1737         result[1] = biasY;
1738         result[2] = biasZ;
1739     }
1740 
1741     /**
1742      * Sets known bias as an array.
1743      * Array values are expressed in meters per squared second (m/s^2).
1744      *
1745      * @param bias known bias to be set
1746      * @throws LockedException          if calibrator is currently running.
1747      * @throws IllegalArgumentException if provided array does not have length 3.
1748      */
1749     @Override
1750     public void setBias(final double[] bias) throws LockedException {
1751         if (running) {
1752             throw new LockedException();
1753         }
1754 
1755         if (bias.length != BodyKinematics.COMPONENTS) {
1756             throw new IllegalArgumentException();
1757         }
1758         biasX = bias[0];
1759         biasY = bias[1];
1760         biasZ = bias[2];
1761     }
1762 
1763     /**
1764      * Gets known bias as a column matrix.
1765      *
1766      * @return known bias as a column matrix.
1767      */
1768     @Override
1769     public Matrix getBiasAsMatrix() {
1770         Matrix result;
1771         try {
1772             result = new Matrix(BodyKinematics.COMPONENTS, 1);
1773             getBiasAsMatrix(result);
1774         } catch (final WrongSizeException ignore) {
1775             // never happens
1776             result = null;
1777         }
1778         return result;
1779     }
1780 
1781     /**
1782      * Gets known bias as a column matrix.
1783      *
1784      * @param result instance where result data will be copied to.
1785      * @throws IllegalArgumentException if provided matrix is not 3x1.
1786      */
1787     @Override
1788     public void getBiasAsMatrix(final Matrix result) {
1789         if (result.getRows() != BodyKinematics.COMPONENTS || result.getColumns() != 1) {
1790             throw new IllegalArgumentException();
1791         }
1792         result.setElementAtIndex(0, biasX);
1793         result.setElementAtIndex(1, biasY);
1794         result.setElementAtIndex(2, biasZ);
1795     }
1796 
1797     /**
1798      * Sets known bias as an array.
1799      *
1800      * @param bias bias to be set.
1801      * @throws LockedException          if calibrator is currently running.
1802      * @throws IllegalArgumentException if provided matrix is not 3x1.
1803      */
1804     @Override
1805     public void setBias(final Matrix bias) throws LockedException {
1806         if (running) {
1807             throw new LockedException();
1808         }
1809         if (bias.getRows() != BodyKinematics.COMPONENTS || bias.getColumns() != 1) {
1810             throw new IllegalArgumentException();
1811         }
1812 
1813         biasX = bias.getElementAtIndex(0);
1814         biasY = bias.getElementAtIndex(1);
1815         biasZ = bias.getElementAtIndex(2);
1816     }
1817 
1818     /**
1819      * Gets initial scale factors and cross coupling errors matrix.
1820      * This is only taken into account if non-linear preliminary solutions are used.
1821      *
1822      * @return initial scale factors and cross coupling errors matrix.
1823      */
1824     @Override
1825     public Matrix getInitialMa() {
1826         Matrix result;
1827         try {
1828             result = new Matrix(BodyKinematics.COMPONENTS, BodyKinematics.COMPONENTS);
1829             getInitialMa(result);
1830         } catch (final WrongSizeException ignore) {
1831             // never happens
1832             result = null;
1833         }
1834         return result;
1835     }
1836 
1837     /**
1838      * Gets initial scale factors and cross coupling errors matrix.
1839      * This is only taken into account if non-linear preliminary solutions are used.
1840      *
1841      * @param result instance where data will be stored.
1842      * @throws IllegalArgumentException if provided matrix is not 3x3.
1843      */
1844     @Override
1845     public void getInitialMa(final Matrix result) {
1846         if (result.getRows() != BodyKinematics.COMPONENTS || result.getColumns() != BodyKinematics.COMPONENTS) {
1847             throw new IllegalArgumentException();
1848         }
1849         result.setElementAtIndex(0, initialSx);
1850         result.setElementAtIndex(1, initialMyx);
1851         result.setElementAtIndex(2, initialMzx);
1852 
1853         result.setElementAtIndex(3, initialMxy);
1854         result.setElementAtIndex(4, initialSy);
1855         result.setElementAtIndex(5, initialMzy);
1856 
1857         result.setElementAtIndex(6, initialMxz);
1858         result.setElementAtIndex(7, initialMyz);
1859         result.setElementAtIndex(8, initialSz);
1860     }
1861 
1862     /**
1863      * Sets initial scale factors and cross coupling errors matrix.
1864      * This is only taken into account if non-linear preliminary solutions are used.
1865      *
1866      * @param initialMa initial scale factors and cross coupling errors matrix.
1867      * @throws IllegalArgumentException if provided matrix is not 3x3.
1868      * @throws LockedException          if calibrator is currently running.
1869      */
1870     @Override
1871     public void setInitialMa(final Matrix initialMa) throws LockedException {
1872         if (running) {
1873             throw new LockedException();
1874         }
1875         if (initialMa.getRows() != BodyKinematics.COMPONENTS || initialMa.getColumns() != BodyKinematics.COMPONENTS) {
1876             throw new IllegalArgumentException();
1877         }
1878 
1879         initialSx = initialMa.getElementAtIndex(0);
1880         initialMyx = initialMa.getElementAtIndex(1);
1881         initialMzx = initialMa.getElementAtIndex(2);
1882 
1883         initialMxy = initialMa.getElementAtIndex(3);
1884         initialSy = initialMa.getElementAtIndex(4);
1885         initialMzy = initialMa.getElementAtIndex(5);
1886 
1887         initialMxz = initialMa.getElementAtIndex(6);
1888         initialMyz = initialMa.getElementAtIndex(7);
1889         initialSz = initialMa.getElementAtIndex(8);
1890     }
1891 
1892     /**
1893      * Gets ground truth gravity norm to be expected at location where measurements have been made,
1894      * expressed in meter per squared second (m/s^2).
1895      *
1896      * @return ground truth gravity norm or null.
1897      */
1898     public Double getGroundTruthGravityNorm() {
1899         return groundTruthGravityNorm;
1900     }
1901 
1902     /**
1903      * Sets ground truth gravity norm to be expected at location where
1904      * measurements have been made, expressed in meters per squared second
1905      * (m/s^2).
1906      *
1907      * @param groundTruthGravityNorm ground truth gravity norm or
1908      *                               null if undefined.
1909      * @throws IllegalArgumentException if provided value is negative.
1910      * @throws LockedException          if calibrator is currently running.
1911      */
1912     public void setGroundTruthGravityNorm(final Double groundTruthGravityNorm) throws LockedException {
1913         if (isRunning()) {
1914             throw new LockedException();
1915         }
1916         internalSetGroundTruthGravityNorm(groundTruthGravityNorm);
1917     }
1918 
1919     /**
1920      * Gets ground truth gravity norm to be expected at location where measurements have been made.
1921      *
1922      * @return ground truth gravity norm or null.
1923      */
1924     public Acceleration getGroundTruthGravityNormAsAcceleration() {
1925         return groundTruthGravityNorm != null
1926                 ? new Acceleration(groundTruthGravityNorm, AccelerationUnit.METERS_PER_SQUARED_SECOND) : null;
1927     }
1928 
1929     /**
1930      * Gets ground truth gravity norm to be expected at location where measurements have been made.
1931      *
1932      * @param result instance where result will be stored.
1933      * @return true if ground truth gravity norm has been defined, false if it is not available yet.
1934      */
1935     public boolean getGroundTruthGravityNormAsAcceleration(final Acceleration result) {
1936         if (groundTruthGravityNorm != null) {
1937             result.setValue(groundTruthGravityNorm);
1938             result.setUnit(AccelerationUnit.METERS_PER_SQUARED_SECOND);
1939             return true;
1940         } else {
1941             return false;
1942         }
1943     }
1944 
1945     /**
1946      * Sets ground truth gravity norm to be expected at location where
1947      * measurements have been made.
1948      *
1949      * @param groundTruthGravityNorm ground truth gravity norm or null
1950      *                               if undefined.
1951      * @throws IllegalArgumentException if provided value is negative.
1952      * @throws LockedException          if calibrator is currently running.
1953      */
1954     public void setGroundTruthGravityNorm(final Acceleration groundTruthGravityNorm) throws LockedException {
1955         setGroundTruthGravityNorm(groundTruthGravityNorm != null ? convertAcceleration(groundTruthGravityNorm) : null);
1956     }
1957 
1958     /**
1959      * Gets a list of body kinematics measurements taken at a
1960      * given position with different unknown orientations and containing the
1961      * standard deviations of accelerometer and gyroscope measurements.
1962      *
1963      * @return list of body kinematics measurements.
1964      */
1965     @Override
1966     public List<StandardDeviationBodyKinematics> getMeasurements() {
1967         return measurements;
1968     }
1969 
1970     /**
1971      * Sets a list of body kinematics measurements taken at a
1972      * given position with different unknown orientations and containing the
1973      * standard deviations of accelerometer and gyroscope measurements.
1974      *
1975      * @param measurements list of body kinematics measurements.
1976      * @throws LockedException if calibrator is currently running.
1977      */
1978     @Override
1979     public void setMeasurements(final List<StandardDeviationBodyKinematics> measurements) throws LockedException {
1980         if (running) {
1981             throw new LockedException();
1982         }
1983         this.measurements = measurements;
1984     }
1985 
1986     /**
1987      * Indicates the type of measurement used by this calibrator.
1988      *
1989      * @return type of measurement used by this calibrator.
1990      */
1991     @Override
1992     public AccelerometerCalibratorMeasurementType getMeasurementType() {
1993         return AccelerometerCalibratorMeasurementType.STANDARD_DEVIATION_BODY_KINEMATICS;
1994     }
1995 
1996     /**
1997      * Indicates whether this calibrator requires ordered measurements in a
1998      * list or not.
1999      *
2000      * @return true if measurements must be ordered, false otherwise.
2001      */
2002     @Override
2003     public boolean isOrderedMeasurementsRequired() {
2004         return true;
2005     }
2006 
2007     /**
2008      * Indicates whether z-axis is assumed to be common for accelerometer and
2009      * gyroscope.
2010      * When enabled, this eliminates 3 variables from Ma matrix.
2011      *
2012      * @return true if z-axis is assumed to be common for accelerometer and gyroscope,
2013      * false otherwise.
2014      */
2015     @Override
2016     public boolean isCommonAxisUsed() {
2017         return commonAxisUsed;
2018     }
2019 
2020     /**
2021      * Specifies whether z-axis is assumed to be common for accelerometer and
2022      * gyroscope.
2023      * When enabled, this eliminates 3 variables from Ma matrix.
2024      *
2025      * @param commonAxisUsed true if z-axis is assumed to be common for accelerometer
2026      *                       and gyroscope, false otherwise.
2027      * @throws LockedException if calibrator is currently running.
2028      */
2029     @Override
2030     public void setCommonAxisUsed(final boolean commonAxisUsed) throws LockedException {
2031         if (running) {
2032             throw new LockedException();
2033         }
2034 
2035         this.commonAxisUsed = commonAxisUsed;
2036     }
2037 
2038     /**
2039      * Gets listener to handle events raised by this estimator.
2040      *
2041      * @return listener to handle events raised by this estimator.
2042      */
2043     public RobustKnownBiasAndGravityNormAccelerometerCalibratorListener getListener() {
2044         return listener;
2045     }
2046 
2047     /**
2048      * Sets listener to handle events raised by this estimator.
2049      *
2050      * @param listener listener to handle events raised by this estimator.
2051      * @throws LockedException if calibrator is currently running.
2052      */
2053     public void setListener(final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener)
2054             throws LockedException {
2055         if (running) {
2056             throw new LockedException();
2057         }
2058 
2059         this.listener = listener;
2060     }
2061 
2062     /**
2063      * Gets minimum number of required measurements.
2064      *
2065      * @return minimum number of required measurements.
2066      */
2067     @Override
2068     public int getMinimumRequiredMeasurements() {
2069         return commonAxisUsed ? MINIMUM_MEASUREMENTS_COMMON_Z_AXIS : MINIMUM_MEASUREMENTS_GENERAL;
2070     }
2071 
2072     /**
2073      * Indicates whether calibrator is ready to start.
2074      *
2075      * @return true if calibrator is ready, false otherwise.
2076      */
2077     @Override
2078     public boolean isReady() {
2079         return measurements != null && measurements.size() >= getMinimumRequiredMeasurements()
2080                 && groundTruthGravityNorm != null;
2081     }
2082 
2083     /**
2084      * Indicates whether calibrator is currently running or not.
2085      *
2086      * @return true if calibrator is running, false otherwise.
2087      */
2088     @Override
2089     public boolean isRunning() {
2090         return running;
2091     }
2092 
2093     /**
2094      * Returns amount of progress variation before notifying a progress change during
2095      * calibration.
2096      *
2097      * @return amount of progress variation before notifying a progress change during
2098      * calibration.
2099      */
2100     public float getProgressDelta() {
2101         return progressDelta;
2102     }
2103 
2104     /**
2105      * Sets amount of progress variation before notifying a progress change during
2106      * calibration.
2107      *
2108      * @param progressDelta amount of progress variation before notifying a progress
2109      *                      change during calibration.
2110      * @throws IllegalArgumentException if progress delta is less than zero or greater than 1.
2111      * @throws LockedException          if calibrator is currently running.
2112      */
2113     public void setProgressDelta(final float progressDelta) throws LockedException {
2114         if (running) {
2115             throw new LockedException();
2116         }
2117         if (progressDelta < MIN_PROGRESS_DELTA || progressDelta > MAX_PROGRESS_DELTA) {
2118             throw new IllegalArgumentException();
2119         }
2120         this.progressDelta = progressDelta;
2121     }
2122 
2123     /**
2124      * Returns amount of confidence expressed as a value between 0.0 and 1.0
2125      * (which is equivalent to 100%). The amount of confidence indicates the probability
2126      * that the estimated result is correct. Usually this value will be close to 1.0, but
2127      * not exactly 1.0.
2128      *
2129      * @return amount of confidence as a value between 0.0 and 1.0.
2130      */
2131     public double getConfidence() {
2132         return confidence;
2133     }
2134 
2135     /**
2136      * Sets amount of confidence expressed as a value between 0.0 and 1.0 (which is
2137      * equivalent to 100%). The amount of confidence indicates the probability that
2138      * the estimated result is correct. Usually this value will be close to 1.0, but
2139      * not exactly 1.0.
2140      *
2141      * @param confidence confidence to be set as a value between 0.0 and 1.0.
2142      * @throws IllegalArgumentException if provided value is not between 0.0 and 1.0.
2143      * @throws LockedException          if calibrator is currently running.
2144      */
2145     public void setConfidence(final double confidence) throws LockedException {
2146         if (running) {
2147             throw new LockedException();
2148         }
2149         if (confidence < MIN_CONFIDENCE || confidence > MAX_CONFIDENCE) {
2150             throw new IllegalArgumentException();
2151         }
2152         this.confidence = confidence;
2153     }
2154 
2155     /**
2156      * Returns maximum allowed number of iterations. If maximum allowed number of
2157      * iterations is achieved without converging to a result when calling calibrate(),
2158      * a RobustEstimatorException will be raised.
2159      *
2160      * @return maximum allowed number of iterations.
2161      */
2162     public int getMaxIterations() {
2163         return maxIterations;
2164     }
2165 
2166     /**
2167      * Sets maximum allowed number of iterations. When the maximum number of iterations
2168      * is exceeded, result will not be available, however an approximate result will be
2169      * available for retrieval.
2170      *
2171      * @param maxIterations maximum allowed number of iterations to be set.
2172      * @throws IllegalArgumentException if provided value is less than 1.
2173      * @throws LockedException          if calibrator is currently running.
2174      */
2175     public void setMaxIterations(final int maxIterations) throws LockedException {
2176         if (running) {
2177             throw new LockedException();
2178         }
2179         if (maxIterations < MIN_ITERATIONS) {
2180             throw new IllegalArgumentException();
2181         }
2182         this.maxIterations = maxIterations;
2183     }
2184 
2185     /**
2186      * Gets data related to inliers found after estimation.
2187      *
2188      * @return data related to inliers found after estimation.
2189      */
2190     public InliersData getInliersData() {
2191         return inliersData;
2192     }
2193 
2194     /**
2195      * Indicates whether result must be refined using a non-linear solver over found inliers.
2196      *
2197      * @return true to refine result, false to simply use result found by robust estimator
2198      * without further refining.
2199      */
2200     public boolean isResultRefined() {
2201         return refineResult;
2202     }
2203 
2204     /**
2205      * Specifies whether result must be refined using a non-linear solver over found inliers.
2206      *
2207      * @param refineResult true to refine result, false to simply use result found by robust
2208      *                     estimator without further refining.
2209      * @throws LockedException if calibrator is currently running.
2210      */
2211     public void setResultRefined(final boolean refineResult) throws LockedException {
2212         if (running) {
2213             throw new LockedException();
2214         }
2215         this.refineResult = refineResult;
2216     }
2217 
2218     /**
2219      * Indicates whether covariance must be kept after refining result.
2220      * This setting is only taken into account if result is refined.
2221      *
2222      * @return true if covariance must be kept after refining result, false otherwise.
2223      */
2224     public boolean isCovarianceKept() {
2225         return keepCovariance;
2226     }
2227 
2228     /**
2229      * Specifies whether covariance must be kept after refining result.
2230      * This setting is only taken into account if result is refined.
2231      *
2232      * @param keepCovariance true if covariance must be kept after refining result,
2233      *                       false otherwise.
2234      * @throws LockedException if calibrator is currently running.
2235      */
2236     public void setCovarianceKept(final boolean keepCovariance) throws LockedException {
2237         if (running) {
2238             throw new LockedException();
2239         }
2240         this.keepCovariance = keepCovariance;
2241     }
2242 
2243     /**
2244      * Returns quality scores corresponding to each measurement.
2245      * The larger the score value the better the quality of the sample.
2246      * This implementation always returns null.
2247      * Subclasses using quality scores must implement proper behavior.
2248      *
2249      * @return quality scores corresponding to each sample.
2250      */
2251     @Override
2252     public double[] getQualityScores() {
2253         return null;
2254     }
2255 
2256     /**
2257      * Sets quality scores corresponding to each measurement.
2258      * The larger the score value the better the quality of the sample.
2259      * This implementation makes no action.
2260      * Subclasses using quality scores must implement proper behaviour.
2261      *
2262      * @param qualityScores quality scores corresponding to each pair of
2263      *                      matched points.
2264      * @throws IllegalArgumentException if provided quality scores length
2265      *                                  is smaller than minimum required samples.
2266      * @throws LockedException          if calibrator is currently running.
2267      */
2268     @Override
2269     public void setQualityScores(final double[] qualityScores) throws LockedException {
2270     }
2271 
2272     /**
2273      * Gets estimated accelerometer scale factors and ross coupling errors.
2274      * This is the product of matrix Ta containing cross coupling errors and Ka
2275      * containing scaling factors.
2276      * So tat:
2277      * <pre>
2278      *     Ma = [sx    mxy  mxz] = Ta*Ka
2279      *          [myx   sy   myz]
2280      *          [mzx   mzy  sz ]
2281      * </pre>
2282      * Where:
2283      * <pre>
2284      *     Ka = [sx 0   0 ]
2285      *          [0  sy  0 ]
2286      *          [0  0   sz]
2287      * </pre>
2288      * and
2289      * <pre>
2290      *     Ta = [1          -alphaXy    alphaXz ]
2291      *          [alphaYx    1           -alphaYz]
2292      *          [-alphaZx   alphaZy     1       ]
2293      * </pre>
2294      * Hence:
2295      * <pre>
2296      *     Ma = [sx    mxy  mxz] = Ta*Ka =  [sx             -sy * alphaXy   sz * alphaXz ]
2297      *          [myx   sy   myz]            [sx * alphaYx   sy              -sz * alphaYz]
2298      *          [mzx   mzy  sz ]            [-sx * alphaZx  sy * alphaZy    sz           ]
2299      * </pre>
2300      * This instance allows any 3x3 matrix however, typically alphaYx, alphaZx and alphaZy
2301      * are considered to be zero if the accelerometer z-axis is assumed to be the same
2302      * as the body z-axis. When this is assumed, myx = mzx = mzy = 0 and the Ma matrix
2303      * becomes upper diagonal:
2304      * <pre>
2305      *     Ma = [sx    mxy  mxz]
2306      *          [0     sy   myz]
2307      *          [0     0    sz ]
2308      * </pre>
2309      * Values of this matrix are unit-less.
2310      *
2311      * @return estimated accelerometer scale factors and cross coupling errors, or null
2312      * if not available.
2313      */
2314     @Override
2315     public Matrix getEstimatedMa() {
2316         return estimatedMa;
2317     }
2318 
2319     /**
2320      * Gets estimated x-axis scale factor.
2321      *
2322      * @return estimated x-axis scale factor or null if not available.
2323      */
2324     @Override
2325     public Double getEstimatedSx() {
2326         return estimatedMa != null ? estimatedMa.getElementAt(0, 0) : null;
2327     }
2328 
2329     /**
2330      * Gets estimated y-axis scale factor.
2331      *
2332      * @return estimated y-axis scale factor or null if not available.
2333      */
2334     @Override
2335     public Double getEstimatedSy() {
2336         return estimatedMa != null ? estimatedMa.getElementAt(1, 1) : null;
2337     }
2338 
2339     /**
2340      * Gets estimated z-axis scale factor.
2341      *
2342      * @return estimated z-axis scale factor or null if not available.
2343      */
2344     @Override
2345     public Double getEstimatedSz() {
2346         return estimatedMa != null ? estimatedMa.getElementAt(2, 2) : null;
2347     }
2348 
2349     /**
2350      * Gets estimated x-y cross-coupling error.
2351      *
2352      * @return estimated x-y cross-coupling error or null if not available.
2353      */
2354     @Override
2355     public Double getEstimatedMxy() {
2356         return estimatedMa != null ? estimatedMa.getElementAt(0, 1) : null;
2357     }
2358 
2359     /**
2360      * Gets estimated x-z cross-coupling error.
2361      *
2362      * @return estimated x-z cross-coupling error or null if not available.
2363      */
2364     @Override
2365     public Double getEstimatedMxz() {
2366         return estimatedMa != null ? estimatedMa.getElementAt(0, 2) : null;
2367     }
2368 
2369     /**
2370      * Gets estimated y-x cross-coupling error.
2371      *
2372      * @return estimated y-x cross-coupling error or null if not available.
2373      */
2374     @Override
2375     public Double getEstimatedMyx() {
2376         return estimatedMa != null ? estimatedMa.getElementAt(1, 0) : null;
2377     }
2378 
2379     /**
2380      * Gets estimated y-z cross-coupling error.
2381      *
2382      * @return estimated y-z cross-coupling error or null if not available.
2383      */
2384     @Override
2385     public Double getEstimatedMyz() {
2386         return estimatedMa != null ? estimatedMa.getElementAt(1, 2) : null;
2387     }
2388 
2389     /**
2390      * Gets estimated z-x cross-coupling error.
2391      *
2392      * @return estimated z-x cross-coupling error or null if not available.
2393      */
2394     @Override
2395     public Double getEstimatedMzx() {
2396         return estimatedMa != null ? estimatedMa.getElementAt(2, 0) : null;
2397     }
2398 
2399     /**
2400      * Gets estimated z-y cross-coupling error.
2401      *
2402      * @return estimated z-y cross-coupling error or null if not available.
2403      */
2404     @Override
2405     public Double getEstimatedMzy() {
2406         return estimatedMa != null ? estimatedMa.getElementAt(2, 1) : null;
2407     }
2408 
2409     /**
2410      * Gets estimated covariance matrix for estimated calibration solution.
2411      * Diagonal elements of the matrix contains variance for the following
2412      * parameters (following indicated order): sx, sy, sz, mxy, mxz, myx,
2413      * myz, mzx, mzy.
2414      * This is only available when result has been refined and covariance
2415      * is kept.
2416      *
2417      * @return estimated covariance matrix for estimated position.
2418      */
2419     @Override
2420     public Matrix getEstimatedCovariance() {
2421         return estimatedCovariance;
2422     }
2423 
2424     /**
2425      * Gets estimated chi square value.
2426      *
2427      * @return estimated chi square value.
2428      */
2429     @Override
2430     public double getEstimatedChiSq() {
2431         return estimatedChiSq;
2432     }
2433 
2434     /**
2435      * Gets estimated chi square degrees of freedom. Degrees of freedom is equal to the number of sampled data minus the
2436      * number of estimated parameters.
2437      *
2438      * @return estimated degrees of freedom of chi square value
2439      */
2440     @Override
2441     public int getEstimatedChiSqDegreesOfFreedom() {
2442         return estimatedChiSqDegreesOfFreedom;
2443     }
2444 
2445     /**
2446      * Gets estimated reduced chi square value. This is equal to estimated chi square value divided by its degrees of
2447      * freedom. Ideally this value should be close to 1.0, indicating that fit is optimal.
2448      * A value larger than 1.0 indicates that fit is not good or noise has been underestimated, and a value smaller than
2449      * 1.0 indicates that there is overfitting or noise has been overestimated.
2450      *
2451      * @return estimated reduced chi square value
2452      */
2453     @Override
2454     public double getEstimatedReducedChiSq() {
2455         return estimatedReducedChiSq;
2456     }
2457 
2458     /**
2459      * Gets estimated mean square error respect to provided measurements.
2460      *
2461      * @return estimated mean square error respect to provided measurements.
2462      */
2463     @Override
2464     public double getEstimatedMse() {
2465         return estimatedMse;
2466     }
2467 
2468     /**
2469      * Gets estimated probability of finding a smaller chi square value expressed as a value between 0.0 and 1.0. The
2470      * smaller the found chi square value is, the better the fit of the estimated parameters to the actual parameter.
2471      * Thus, the smaller the chance of finding a smaller chi square value, then the better the estimated fit is.
2472      *
2473      * @return estimated probability of finding a smaller chi square value.
2474      */
2475     @Override
2476     public double getEstimatedP() {
2477         return estimatedP;
2478     }
2479 
2480     /**
2481      * Gets estimated measure of quality of estimated fit as a value between 0.0 and 1.0. The larger the quality value
2482      * is, the better the fit that has been estimated.
2483      *
2484      * @return estimated measure of quality of estimated fit.
2485      */
2486     @Override
2487     public double getEstimatedQ() {
2488         return estimatedQ;
2489     }
2490 
2491     /**
2492      * Gets size of subsets to be checked during robust estimation.
2493      * This has to be at least {@link #getMinimumRequiredMeasurements()}.
2494      *
2495      * @return size of subsets to be checked during robust estimation.
2496      */
2497     public int getPreliminarySubsetSize() {
2498         return preliminarySubsetSize;
2499     }
2500 
2501     /**
2502      * Sets size of subsets to be checked during robust estimation.
2503      * This has to be at least {@link #getMinimumRequiredMeasurements()}.
2504      *
2505      * @param preliminarySubsetSize size of subsets to be checked during robust estimation.
2506      * @throws LockedException          if calibrator is currently running.
2507      * @throws IllegalArgumentException if provided value is less than {@link #getMinimumRequiredMeasurements()}.
2508      */
2509     public void setPreliminarySubsetSize(final int preliminarySubsetSize) throws LockedException {
2510         if (running) {
2511             throw new LockedException();
2512         }
2513         if (preliminarySubsetSize < getMinimumRequiredMeasurements()) {
2514             throw new IllegalArgumentException();
2515         }
2516 
2517         this.preliminarySubsetSize = preliminarySubsetSize;
2518     }
2519 
2520     /**
2521      * Returns method being used for robust estimation.
2522      *
2523      * @return method being used for robust estimation.
2524      */
2525     public abstract RobustEstimatorMethod getMethod();
2526 
2527     /**
2528      * Creates a robust accelerometer calibrator.
2529      *
2530      * @param method robust estimator method.
2531      * @return a robust accelerometer calibrator.
2532      */
2533     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(final RobustEstimatorMethod method) {
2534         return switch (method) {
2535             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator();
2536             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator();
2537             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator();
2538             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator();
2539             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator();
2540         };
2541     }
2542 
2543     /**
2544      * Creates a robust accelerometer calibrator.
2545      *
2546      * @param listener listener to be notified of events such as when estimation
2547      *                 starts, ends or its progress significantly changes.
2548      * @param method   robust estimator method.
2549      * @return a robust accelerometer calibrator.
2550      */
2551     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
2552             final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener,
2553             final RobustEstimatorMethod method) {
2554         return switch (method) {
2555             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(listener);
2556             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(listener);
2557             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(listener);
2558             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(listener);
2559             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(listener);
2560         };
2561     }
2562 
2563     /**
2564      * Creates a robust accelerometer calibrator.
2565      *
2566      * @param measurements collection of body kinematics measurements with standard
2567      *                     deviations taken at the same position with zero velocity
2568      *                     and unknown different orientations.
2569      * @param method       robust estimator method.
2570      * @return a robust accelerometer calibrator.
2571      */
2572     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
2573             final List<StandardDeviationBodyKinematics> measurements, final RobustEstimatorMethod method) {
2574         return switch (method) {
2575             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(measurements);
2576             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(measurements);
2577             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(measurements);
2578             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(measurements);
2579             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(measurements);
2580         };
2581     }
2582 
2583     /**
2584      * Creates a robust accelerometer calibrator.
2585      *
2586      * @param commonAxisUsed indicates whether z-axis is assumed to be common for
2587      *                       accelerometer and gyroscope.
2588      * @param method         robust estimator method.
2589      * @return a robust accelerometer calibrator.
2590      */
2591     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
2592             final boolean commonAxisUsed, final RobustEstimatorMethod method) {
2593         return switch (method) {
2594             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(commonAxisUsed);
2595             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(commonAxisUsed);
2596             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(commonAxisUsed);
2597             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(commonAxisUsed);
2598             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(commonAxisUsed);
2599         };
2600     }
2601 
2602     /**
2603      * Creates a robust accelerometer calibrator.
2604      *
2605      * @param bias   known accelerometer bias. This must have length 3 and is expressed
2606      *               in meters per squared second (m/s^2).
2607      * @param method robust estimator method.
2608      * @return a robust accelerometer calibrator.
2609      * @throws IllegalArgumentException if provided bias array does not have length 3.
2610      */
2611     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
2612             final double[] bias, final RobustEstimatorMethod method) {
2613         return switch (method) {
2614             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(bias);
2615             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(bias);
2616             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(bias);
2617             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(bias);
2618             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(bias);
2619         };
2620     }
2621 
2622     /**
2623      * Creates a robust accelerometer calibrator.
2624      *
2625      * @param bias   known accelerometer bias.
2626      * @param method robust estimator method.
2627      * @return a robust accelerometer calibrator.
2628      * @throws IllegalArgumentException if provided bias matrix is not 3x1.
2629      */
2630     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
2631             final Matrix bias, final RobustEstimatorMethod method) {
2632         return switch (method) {
2633             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(bias);
2634             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(bias);
2635             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(bias);
2636             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(bias);
2637             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(bias);
2638         };
2639     }
2640 
2641     /**
2642      * Creates a robust accelerometer calibrator.
2643      *
2644      * @param bias      known accelerometer bias.
2645      * @param initialMa initial scale factors and cross coupling errors matrix.
2646      * @param method    robust estimator method.
2647      * @return a robust accelerometer calibrator.
2648      * @throws IllegalArgumentException if either provided bias matrix is not 3x1 or
2649      *                                  scaling and coupling error matrix is not 3x3.
2650      */
2651     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
2652             final Matrix bias, final Matrix initialMa, final RobustEstimatorMethod method) {
2653         return switch (method) {
2654             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(bias, initialMa);
2655             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(bias, initialMa);
2656             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(bias, initialMa);
2657             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(bias, initialMa);
2658             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(bias, initialMa);
2659         };
2660     }
2661 
2662     /**
2663      * Creates a robust accelerometer calibrator.
2664      *
2665      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
2666      *                               squared second (m/s^2).
2667      * @param method                 robust estimator method.
2668      * @return a robust accelerometer calibrator.
2669      * @throws IllegalArgumentException if provided gravity norm value is negative.
2670      */
2671     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
2672             final Double groundTruthGravityNorm, final RobustEstimatorMethod method) {
2673         return switch (method) {
2674             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(groundTruthGravityNorm);
2675             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(groundTruthGravityNorm);
2676             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(groundTruthGravityNorm);
2677             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(groundTruthGravityNorm);
2678             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(groundTruthGravityNorm);
2679         };
2680     }
2681 
2682     /**
2683      * Creates a robust accelerometer calibrator.
2684      *
2685      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
2686      *                               squared second (m/s^2).
2687      * @param measurements           list of body kinematics measurements taken at a given position with
2688      *                               different unknown orientations and containing the standard deviations
2689      *                               of accelerometer and gyroscope measurements.
2690      * @param method                 robust estimator method.
2691      * @return a robust accelerometer calibrator.
2692      * @throws IllegalArgumentException if provided gravity norm value is negative.
2693      */
2694     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
2695             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
2696             final RobustEstimatorMethod method) {
2697         return switch (method) {
2698             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(groundTruthGravityNorm,
2699                     measurements);
2700             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(groundTruthGravityNorm,
2701                     measurements);
2702             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(groundTruthGravityNorm,
2703                     measurements);
2704             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(groundTruthGravityNorm,
2705                     measurements);
2706             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(groundTruthGravityNorm,
2707                     measurements);
2708         };
2709     }
2710 
2711     /**
2712      * Creates a robust accelerometer calibrator.
2713      *
2714      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
2715      *                               squared second (m/s^2).
2716      * @param measurements           list of body kinematics measurements taken at a given position with
2717      *                               different unknown orientations and containing the standard deviations
2718      *                               of accelerometer and gyroscope measurements.
2719      * @param listener               listener to be notified of events such as when estimation
2720      *                               starts, ends or its progress significantly changes.
2721      * @param method                 robust estimator method.
2722      * @return a robust accelerometer calibrator.
2723      * @throws IllegalArgumentException if provided gravity norm value is negative.
2724      */
2725     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
2726             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
2727             final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener,
2728             final RobustEstimatorMethod method) {
2729         return switch (method) {
2730             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(groundTruthGravityNorm,
2731                     measurements, listener);
2732             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(groundTruthGravityNorm,
2733                     measurements, listener);
2734             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(groundTruthGravityNorm,
2735                     measurements, listener);
2736             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(groundTruthGravityNorm,
2737                     measurements, listener);
2738             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(groundTruthGravityNorm,
2739                     measurements, listener);
2740         };
2741     }
2742 
2743     /**
2744      * Creates a robust accelerometer calibrator.
2745      *
2746      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
2747      *                               squared second (m/s^2).
2748      * @param measurements           list of body kinematics measurements taken at a given position with
2749      *                               different unknown orientations and containing the standard deviations
2750      *                               of accelerometer and gyroscope measurements.
2751      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
2752      *                               accelerometer and gyroscope.
2753      * @param method                 robust estimator method.
2754      * @return a robust accelerometer calibrator.
2755      * @throws IllegalArgumentException if provided gravity norm value is negative.
2756      */
2757     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
2758             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
2759             final boolean commonAxisUsed, final RobustEstimatorMethod method) {
2760         return switch (method) {
2761             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(groundTruthGravityNorm,
2762                     measurements, commonAxisUsed);
2763             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(groundTruthGravityNorm,
2764                     measurements, commonAxisUsed);
2765             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(groundTruthGravityNorm,
2766                     measurements, commonAxisUsed);
2767             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(groundTruthGravityNorm,
2768                     measurements, commonAxisUsed);
2769             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(groundTruthGravityNorm,
2770                     measurements, commonAxisUsed);
2771         };
2772     }
2773 
2774     /**
2775      * Creates a robust accelerometer calibrator.
2776      *
2777      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
2778      *                               squared second (m/s^2).
2779      * @param measurements           list of body kinematics measurements taken at a given position with
2780      *                               different unknown orientations and containing the standard deviations
2781      *                               of accelerometer and gyroscope measurements.
2782      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
2783      *                               accelerometer and gyroscope.
2784      * @param listener               listener to be notified of events such as when estimation
2785      *                               starts, ends or its progress significantly changes.
2786      * @param method                 robust estimator method.
2787      * @return a robust accelerometer calibrator.
2788      * @throws IllegalArgumentException if provided gravity norm value is negative.
2789      */
2790     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
2791             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
2792             final boolean commonAxisUsed, final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener,
2793             final RobustEstimatorMethod method) {
2794         return switch (method) {
2795             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
2796                     groundTruthGravityNorm, measurements, commonAxisUsed, listener);
2797             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
2798                     groundTruthGravityNorm, measurements, commonAxisUsed, listener);
2799             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
2800                     groundTruthGravityNorm, measurements, commonAxisUsed, listener);
2801             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
2802                     groundTruthGravityNorm, measurements, commonAxisUsed, listener);
2803             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
2804                     groundTruthGravityNorm, measurements, commonAxisUsed, listener);
2805         };
2806     }
2807 
2808     /**
2809      * Creates a robust accelerometer calibrator.
2810      *
2811      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
2812      *                               squared second (m/s^2).
2813      * @param measurements           collection of body kinematics measurements with standard
2814      *                               deviations taken at the same position with zero velocity
2815      *                               and unknown different orientations.
2816      * @param bias                   known accelerometer bias. This must have length 3 and is expressed
2817      *                               in meters per squared second (m/s^2).
2818      * @param method                 robust estimator method.
2819      * @return a robust accelerometer calibrator.
2820      * @throws IllegalArgumentException if provided bias array does not have length 3 or
2821      *                                  if provided gravity norm value is negative.
2822      */
2823     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
2824             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
2825             final double[] bias, final RobustEstimatorMethod method) {
2826         return switch (method) {
2827             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
2828                     groundTruthGravityNorm, measurements, bias);
2829             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
2830                     groundTruthGravityNorm, measurements, bias);
2831             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
2832                     groundTruthGravityNorm, measurements, bias);
2833             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
2834                     groundTruthGravityNorm, measurements, bias);
2835             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
2836                     groundTruthGravityNorm, measurements, bias);
2837         };
2838     }
2839 
2840     /**
2841      * Creates a robust accelerometer calibrator.
2842      *
2843      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
2844      *                               squared second (m/s^2).
2845      * @param measurements           collection of body kinematics measurements with standard
2846      *                               deviations taken at the same position with zero velocity
2847      *                               and unknown different orientations.
2848      * @param bias                   known accelerometer bias. This must have length 3 and is expressed
2849      *                               in meters per squared second (m/s^2).
2850      * @param listener               listener to handle events raised by this calibrator.
2851      * @param method                 robust estimator method.
2852      * @return a robust accelerometer calibrator.
2853      * @throws IllegalArgumentException if provided bias array does not have length 3 or
2854      *                                  if provided gravity norm value is negative.
2855      */
2856     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
2857             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
2858             final double[] bias, final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener,
2859             final RobustEstimatorMethod method) {
2860         return switch (method) {
2861             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
2862                     groundTruthGravityNorm, measurements, bias, listener);
2863             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
2864                     groundTruthGravityNorm, measurements, bias, listener);
2865             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
2866                     groundTruthGravityNorm, measurements, bias, listener);
2867             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
2868                     groundTruthGravityNorm, measurements, bias, listener);
2869             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
2870                     groundTruthGravityNorm, measurements, bias, listener);
2871         };
2872     }
2873 
2874     /**
2875      * Creates a robust accelerometer calibrator.
2876      *
2877      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
2878      *                               squared second (m/s^2).
2879      * @param measurements           collection of body kinematics measurements with standard
2880      *                               deviations taken at the same position with zero velocity
2881      *                               and unknown different orientations.
2882      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
2883      *                               accelerometer and gyroscope.
2884      * @param bias                   known accelerometer bias. This must have length 3 and is expressed
2885      *                               in meters per squared second (m/s^2).
2886      * @param method                 robust estimator method.
2887      * @return a robust accelerometer calibrator.
2888      * @throws IllegalArgumentException if provided bias array does not have length 3 or
2889      *                                  if provided gravity norm value is negative.
2890      */
2891     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
2892             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
2893             final boolean commonAxisUsed, final double[] bias, final RobustEstimatorMethod method) {
2894         return switch (method) {
2895             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
2896                     groundTruthGravityNorm, measurements, commonAxisUsed, bias);
2897             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
2898                     groundTruthGravityNorm, measurements, commonAxisUsed, bias);
2899             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
2900                     groundTruthGravityNorm, measurements, commonAxisUsed, bias);
2901             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
2902                     groundTruthGravityNorm, measurements, commonAxisUsed, bias);
2903             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
2904                     groundTruthGravityNorm, measurements, commonAxisUsed, bias);
2905         };
2906     }
2907 
2908     /**
2909      * Creates a robust accelerometer calibrator.
2910      *
2911      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
2912      *                               squared second (m/s^2).
2913      * @param measurements           collection of body kinematics measurements with standard
2914      *                               deviations taken at the same position with zero velocity
2915      *                               and unknown different orientations.
2916      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
2917      *                               accelerometer and gyroscope.
2918      * @param bias                   known accelerometer bias. This must have length 3 and is
2919      *                               expressed in meters per squared second (m/s^2).
2920      * @param listener               listener to handle events raised by this calibrator.
2921      * @param method                 robust estimator method.
2922      * @return a robust accelerometer calibrator.
2923      * @throws IllegalArgumentException if provided bias array does not have length 3 or
2924      *                                  if provided gravity norm value is negative.
2925      */
2926     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
2927             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
2928             final boolean commonAxisUsed, final double[] bias,
2929             final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener,
2930             final RobustEstimatorMethod method) {
2931         return switch (method) {
2932             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
2933                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, listener);
2934             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
2935                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, listener);
2936             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
2937                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, listener);
2938             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
2939                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, listener);
2940             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
2941                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, listener);
2942         };
2943     }
2944 
2945     /**
2946      * Creates a robust accelerometer calibrator.
2947      *
2948      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
2949      *                               squared second (m/s^2).
2950      * @param measurements           collection of body kinematics measurements with standard
2951      *                               deviations taken at the same position with zero velocity
2952      *                               and unknown different orientations.
2953      * @param bias                   known accelerometer bias.
2954      * @param method                 robust estimator method.
2955      * @return a robust accelerometer calibrator.
2956      * @throws IllegalArgumentException if provided bias matrix is not 3x1 or
2957      *                                  if provided gravity norm value is negative.
2958      */
2959     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
2960             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
2961             final Matrix bias, final RobustEstimatorMethod method) {
2962         return switch (method) {
2963             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
2964                     groundTruthGravityNorm, measurements, bias);
2965             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
2966                     groundTruthGravityNorm, measurements, bias);
2967             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
2968                     groundTruthGravityNorm, measurements, bias);
2969             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
2970                     groundTruthGravityNorm, measurements, bias);
2971             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
2972                     groundTruthGravityNorm, measurements, bias);
2973         };
2974     }
2975 
2976     /**
2977      * Creates a robust accelerometer calibrator.
2978      *
2979      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
2980      *                               squared second (m/s^2).
2981      * @param measurements           collection of body kinematics measurements with standard
2982      *                               deviations taken at the same position with zero velocity
2983      *                               and unknown different orientations.
2984      * @param bias                   known accelerometer bias.
2985      * @param listener               listener to handle events raised by this calibrator.
2986      * @param method                 robust estimator method.
2987      * @return a robust accelerometer calibrator.
2988      * @throws IllegalArgumentException if provided bias matrix is not 3x1 or
2989      *                                  if provided gravity norm value is negative.
2990      */
2991     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
2992             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
2993             final Matrix bias, final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener,
2994             final RobustEstimatorMethod method) {
2995         return switch (method) {
2996             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
2997                     groundTruthGravityNorm, measurements, bias, listener);
2998             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
2999                     groundTruthGravityNorm, measurements, bias, listener);
3000             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3001                     groundTruthGravityNorm, measurements, bias, listener);
3002             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3003                     groundTruthGravityNorm, measurements, bias, listener);
3004             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3005                     groundTruthGravityNorm, measurements, bias, listener);
3006         };
3007     }
3008 
3009     /**
3010      * Creates a robust accelerometer calibrator.
3011      *
3012      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
3013      *                               squared second (m/s^2).
3014      * @param measurements           collection of body kinematics measurements with standard
3015      *                               deviations taken at the same position with zero velocity
3016      *                               and unknown different orientations.
3017      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
3018      *                               accelerometer and gyroscope.
3019      * @param bias                   known accelerometer bias.
3020      * @param method                 robust estimator method.
3021      * @return a robust accelerometer calibrator.
3022      * @throws IllegalArgumentException if provided bias matrix is not 3x1 or
3023      *                                  if provided gravity norm value is negative.
3024      */
3025     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
3026             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
3027             final boolean commonAxisUsed, final Matrix bias, final RobustEstimatorMethod method) {
3028         return switch (method) {
3029             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3030                     groundTruthGravityNorm, measurements, commonAxisUsed, bias);
3031             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3032                     groundTruthGravityNorm, measurements, commonAxisUsed, bias);
3033             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3034                     groundTruthGravityNorm, measurements, commonAxisUsed, bias);
3035             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3036                     groundTruthGravityNorm, measurements, commonAxisUsed, bias);
3037             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3038                     groundTruthGravityNorm, measurements, commonAxisUsed, bias);
3039         };
3040     }
3041 
3042     /**
3043      * Creates a robust accelerometer calibrator.
3044      *
3045      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
3046      *                               squared second (m/s^2).
3047      * @param measurements           collection of body kinematics measurements with standard
3048      *                               deviations taken at the same position with zero velocity
3049      *                               and unknown different orientations.
3050      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
3051      *                               accelerometer and gyroscope.
3052      * @param bias                   known accelerometer bias.
3053      * @param listener               listener to handle events raised by this calibrator.
3054      * @param method                 robust estimator method.
3055      * @return a robust accelerometer calibrator.
3056      * @throws IllegalArgumentException if provided bias matrix is not 3x1 or
3057      *                                  if provided gravity norm value is negative.
3058      */
3059     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
3060             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
3061             final boolean commonAxisUsed, final Matrix bias,
3062             final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener,
3063             final RobustEstimatorMethod method) {
3064         return switch (method) {
3065             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3066                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, listener);
3067             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3068                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, listener);
3069             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3070                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, listener);
3071             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3072                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, listener);
3073             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3074                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, listener);
3075         };
3076     }
3077 
3078     /**
3079      * Creates a robust accelerometer calibrator.
3080      *
3081      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
3082      *                               squared second (m/s^2).
3083      * @param measurements           collection of body kinematics measurements with standard
3084      *                               deviations taken at the same position with zero velocity
3085      *                               and unknown different orientations.
3086      * @param bias                   known accelerometer bias.
3087      * @param initialMa              initial scale factors and cross coupling errors matrix.
3088      * @param method                 robust estimator method.
3089      * @return a robust accelerometer calibrator.
3090      * @throws IllegalArgumentException if either provided bias matrix is not 3x1 or
3091      *                                  scaling and coupling error matrix is not 3x3 or
3092      *                                  if provided gravity norm value is negative.
3093      */
3094     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
3095             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
3096             final Matrix bias, final Matrix initialMa, final RobustEstimatorMethod method) {
3097         return switch (method) {
3098             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3099                     groundTruthGravityNorm, measurements, bias, initialMa);
3100             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3101                     groundTruthGravityNorm, measurements, bias, initialMa);
3102             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3103                     groundTruthGravityNorm, measurements, bias, initialMa);
3104             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3105                     groundTruthGravityNorm, measurements, bias, initialMa);
3106             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3107                     groundTruthGravityNorm, measurements, bias, initialMa);
3108         };
3109     }
3110 
3111     /**
3112      * Creates a robust accelerometer calibrator.
3113      *
3114      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
3115      *                               squared second (m/s^2).
3116      * @param measurements           collection of body kinematics measurements with standard
3117      *                               deviations taken at the same position with zero velocity
3118      *                               and unknown different orientations.
3119      * @param bias                   known accelerometer bias.
3120      * @param initialMa              initial scale factors and cross coupling errors matrix.
3121      * @param listener               listener to handle events raised by this calibrator.
3122      * @param method                 robust estimator method.
3123      * @return a robust accelerometer calibrator.
3124      * @throws IllegalArgumentException if either provided bias matrix is not 3x1 or
3125      *                                  scaling and coupling error matrix is not 3x3 or
3126      *                                  if provided gravity norm value is negative.
3127      */
3128     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
3129             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
3130             final Matrix bias, final Matrix initialMa,
3131             final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener,
3132             final RobustEstimatorMethod method) {
3133         return switch (method) {
3134             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3135                     groundTruthGravityNorm, measurements, bias, initialMa, listener);
3136             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3137                     groundTruthGravityNorm, measurements, bias, initialMa, listener);
3138             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3139                     groundTruthGravityNorm, measurements, bias, initialMa, listener);
3140             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3141                     groundTruthGravityNorm, measurements, bias, initialMa, listener);
3142             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3143                     groundTruthGravityNorm, measurements, bias, initialMa, listener);
3144         };
3145     }
3146 
3147     /**
3148      * Creates a robust accelerometer calibrator.
3149      *
3150      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
3151      *                               squared second (m/s^2).
3152      * @param measurements           collection of body kinematics measurements with standard
3153      *                               deviations taken at the same position with zero velocity
3154      *                               and unknown different orientations.
3155      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
3156      *                               accelerometer and gyroscope.
3157      * @param bias                   known accelerometer bias.
3158      * @param initialMa              initial scale factors and cross coupling errors matrix.
3159      * @param method                 robust estimator method.
3160      * @return a robust accelerometer calibrator.
3161      * @throws IllegalArgumentException if either provided bias matrix is not 3x1 or
3162      *                                  scaling and coupling error matrix is not 3x3 or
3163      *                                  if provided gravity norm value is negative.
3164      */
3165     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
3166             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
3167             final boolean commonAxisUsed, final Matrix bias, final Matrix initialMa,
3168             final RobustEstimatorMethod method) {
3169         return switch (method) {
3170             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3171                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, initialMa);
3172             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3173                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, initialMa);
3174             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3175                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, initialMa);
3176             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3177                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, initialMa);
3178             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3179                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, initialMa);
3180         };
3181     }
3182 
3183     /**
3184      * Creates a robust accelerometer calibrator.
3185      *
3186      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
3187      *                               squared second (m/s^2).
3188      * @param measurements           collection of body kinematics measurements with standard
3189      *                               deviations taken at the same position with zero velocity
3190      *                               and unknown different orientations.
3191      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
3192      *                               accelerometer and gyroscope.
3193      * @param bias                   known accelerometer bias.
3194      * @param initialMa              initial scale factors and cross coupling errors matrix.
3195      * @param listener               listener to handle events raised by this calibrator.
3196      * @param method                 robust estimator method.
3197      * @return a robust accelerometer calibrator.
3198      * @throws IllegalArgumentException if either provided bias matrix is not 3x1 or
3199      *                                  scaling and coupling error matrix is not 3x3 or
3200      *                                  if provided gravity norm value is negative.
3201      */
3202     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
3203             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
3204             final boolean commonAxisUsed, final Matrix bias, final Matrix initialMa,
3205             final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener,
3206             final RobustEstimatorMethod method) {
3207         return switch (method) {
3208             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3209                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, initialMa, listener);
3210             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3211                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, initialMa, listener);
3212             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3213                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, initialMa, listener);
3214             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3215                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, initialMa, listener);
3216             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3217                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, initialMa, listener);
3218         };
3219     }
3220 
3221     /**
3222      * Creates a robust accelerometer calibrator.
3223      *
3224      * @param groundTruthGravityNorm ground truth gravity norm.
3225      * @param method                 robust estimator method.
3226      * @return a robust accelerometer calibrator.
3227      * @throws IllegalArgumentException if provided gravity norm value is negative.
3228      */
3229     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
3230             final Acceleration groundTruthGravityNorm, final RobustEstimatorMethod method) {
3231         return switch (method) {
3232             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(groundTruthGravityNorm);
3233             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(groundTruthGravityNorm);
3234             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(groundTruthGravityNorm);
3235             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(groundTruthGravityNorm);
3236             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(groundTruthGravityNorm);
3237         };
3238     }
3239 
3240     /**
3241      * Creates a robust accelerometer calibrator.
3242      *
3243      * @param groundTruthGravityNorm ground truth gravity norm.
3244      * @param measurements           list of body kinematics measurements taken at a given position with
3245      *                               different unknown orientations and containing the standard deviations
3246      *                               of accelerometer and gyroscope measurements.
3247      * @param method                 robust estimator method.
3248      * @return a robust accelerometer calibrator.
3249      * @throws IllegalArgumentException if provided gravity norm value is negative.
3250      */
3251     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
3252             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
3253             final RobustEstimatorMethod method) {
3254         return switch (method) {
3255             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3256                     groundTruthGravityNorm, measurements);
3257             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3258                     groundTruthGravityNorm, measurements);
3259             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3260                     groundTruthGravityNorm, measurements);
3261             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3262                     groundTruthGravityNorm, measurements);
3263             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3264                     groundTruthGravityNorm, measurements);
3265         };
3266     }
3267 
3268     /**
3269      * Creates a robust accelerometer calibrator.
3270      *
3271      * @param groundTruthGravityNorm ground truth gravity norm.
3272      * @param measurements           list of body kinematics measurements taken at a given position with
3273      *                               different unknown orientations and containing the standard deviations
3274      *                               of accelerometer and gyroscope measurements.
3275      * @param listener               listener to be notified of events such as when estimation
3276      *                               starts, ends or its progress significantly changes.
3277      * @param method                 robust estimator method.
3278      * @return a robust accelerometer calibrator.
3279      * @throws IllegalArgumentException if provided gravity norm value is negative.
3280      */
3281     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
3282             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
3283             final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener,
3284             final RobustEstimatorMethod method) {
3285         return switch (method) {
3286             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3287                     groundTruthGravityNorm, measurements, listener);
3288             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3289                     groundTruthGravityNorm, measurements, listener);
3290             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3291                     groundTruthGravityNorm, measurements, listener);
3292             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3293                     groundTruthGravityNorm, measurements, listener);
3294             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3295                     groundTruthGravityNorm, measurements, listener);
3296         };
3297     }
3298 
3299     /**
3300      * Creates a robust accelerometer calibrator.
3301      *
3302      * @param groundTruthGravityNorm ground truth gravity norm.
3303      * @param measurements           list of body kinematics measurements taken at a given position with
3304      *                               different unknown orientations and containing the standard deviations
3305      *                               of accelerometer and gyroscope measurements.
3306      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
3307      *                               accelerometer and gyroscope.
3308      * @param method                 robust estimator method.
3309      * @return a robust accelerometer calibrator.
3310      * @throws IllegalArgumentException if provided gravity norm value is negative.
3311      */
3312     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
3313             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
3314             final boolean commonAxisUsed, final RobustEstimatorMethod method) {
3315         return switch (method) {
3316             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3317                     groundTruthGravityNorm, measurements, commonAxisUsed);
3318             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3319                     groundTruthGravityNorm, measurements, commonAxisUsed);
3320             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3321                     groundTruthGravityNorm, measurements, commonAxisUsed);
3322             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3323                     groundTruthGravityNorm, measurements, commonAxisUsed);
3324             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3325                     groundTruthGravityNorm, measurements, commonAxisUsed);
3326         };
3327     }
3328 
3329     /**
3330      * Creates a robust accelerometer calibrator.
3331      *
3332      * @param groundTruthGravityNorm ground truth gravity norm.
3333      * @param measurements           list of body kinematics measurements taken at a given position with
3334      *                               different unknown orientations and containing the standard deviations
3335      *                               of accelerometer and gyroscope measurements.
3336      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
3337      *                               accelerometer and gyroscope.
3338      * @param listener               listener to be notified of events such as when estimation
3339      *                               starts, ends or its progress significantly changes.
3340      * @param method                 robust estimator method.
3341      * @return a robust accelerometer calibrator.
3342      * @throws IllegalArgumentException if provided gravity norm value is negative.
3343      */
3344     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
3345             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
3346             final boolean commonAxisUsed, final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener,
3347             final RobustEstimatorMethod method) {
3348         return switch (method) {
3349             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3350                     groundTruthGravityNorm, measurements, commonAxisUsed, listener);
3351             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3352                     groundTruthGravityNorm, measurements, commonAxisUsed, listener);
3353             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3354                     groundTruthGravityNorm, measurements, commonAxisUsed, listener);
3355             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3356                     groundTruthGravityNorm, measurements, commonAxisUsed, listener);
3357             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3358                     groundTruthGravityNorm, measurements, commonAxisUsed, listener);
3359         };
3360     }
3361 
3362     /**
3363      * Creates a robust accelerometer calibrator.
3364      *
3365      * @param groundTruthGravityNorm ground truth gravity norm.
3366      * @param measurements           collection of body kinematics measurements with standard
3367      *                               deviations taken at the same position with zero velocity
3368      *                               and unknown different orientations.
3369      * @param bias                   known accelerometer bias. This must have length 3 and is expressed
3370      *                               in meters per squared second (m/s^2).
3371      * @param method                 robust estimator method.
3372      * @return a robust accelerometer calibrator.
3373      * @throws IllegalArgumentException if provided bias array does not have length 3 or
3374      *                                  if provided gravity norm value is negative.
3375      */
3376     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
3377             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
3378             final double[] bias, final RobustEstimatorMethod method) {
3379         return switch (method) {
3380             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3381                     groundTruthGravityNorm, measurements, bias);
3382             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3383                     groundTruthGravityNorm, measurements, bias);
3384             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3385                     groundTruthGravityNorm, measurements, bias);
3386             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3387                     groundTruthGravityNorm, measurements, bias);
3388             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3389                     groundTruthGravityNorm, measurements, bias);
3390         };
3391     }
3392 
3393     /**
3394      * Creates a robust accelerometer calibrator.
3395      *
3396      * @param groundTruthGravityNorm ground truth gravity norm.
3397      * @param measurements           collection of body kinematics measurements with standard
3398      *                               deviations taken at the same position with zero velocity
3399      *                               and unknown different orientations.
3400      * @param bias                   known accelerometer bias. This must have length 3 and is expressed
3401      *                               in meters per squared second (m/s^2).
3402      * @param listener               listener to handle events raised by this calibrator.
3403      * @param method                 robust estimator method.
3404      * @return a robust accelerometer calibrator.
3405      * @throws IllegalArgumentException if provided bias array does not have length 3 or
3406      *                                  if provided gravity norm value is negative.
3407      */
3408     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
3409             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
3410             final double[] bias, final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener,
3411             final RobustEstimatorMethod method) {
3412         return switch (method) {
3413             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3414                     groundTruthGravityNorm, measurements, bias, listener);
3415             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3416                     groundTruthGravityNorm, measurements, bias, listener);
3417             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3418                     groundTruthGravityNorm, measurements, bias, listener);
3419             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3420                     groundTruthGravityNorm, measurements, bias, listener);
3421             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3422                     groundTruthGravityNorm, measurements, bias, listener);
3423         };
3424     }
3425 
3426     /**
3427      * Creates a robust accelerometer calibrator.
3428      *
3429      * @param groundTruthGravityNorm ground truth gravity norm.
3430      * @param measurements           collection of body kinematics measurements with standard
3431      *                               deviations taken at the same position with zero velocity
3432      *                               and unknown different orientations.
3433      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
3434      *                               accelerometer and gyroscope.
3435      * @param bias                   known accelerometer bias. This must have length 3 and is expressed
3436      *                               in meters per squared second (m/s^2).
3437      * @param method                 robust estimator method.
3438      * @return a robust accelerometer calibrator.
3439      * @throws IllegalArgumentException if provided bias array does not have length 3 or
3440      *                                  if provided gravity norm value is negative.
3441      */
3442     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
3443             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
3444             final boolean commonAxisUsed, final double[] bias, final RobustEstimatorMethod method) {
3445         return switch (method) {
3446             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3447                     groundTruthGravityNorm, measurements, commonAxisUsed, bias);
3448             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3449                     groundTruthGravityNorm, measurements, commonAxisUsed, bias);
3450             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3451                     groundTruthGravityNorm, measurements, commonAxisUsed, bias);
3452             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3453                     groundTruthGravityNorm, measurements, commonAxisUsed, bias);
3454             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3455                     groundTruthGravityNorm, measurements, commonAxisUsed, bias);
3456         };
3457     }
3458 
3459     /**
3460      * Creates a robust accelerometer calibrator.
3461      *
3462      * @param groundTruthGravityNorm ground truth gravity norm.
3463      * @param measurements           collection of body kinematics measurements with standard
3464      *                               deviations taken at the same position with zero velocity
3465      *                               and unknown different orientations.
3466      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
3467      *                               accelerometer and gyroscope.
3468      * @param bias                   known accelerometer bias. This must have length 3 and is expressed
3469      *                               in meters per squared second (m/s^2).
3470      * @param listener               listener to handle events raised by this calibrator.
3471      * @param method                 robust estimator method.
3472      * @return a robust accelerometer calibrator.
3473      * @throws IllegalArgumentException if provided bias array does not have length 3 or
3474      *                                  if provided gravity norm value is negative.
3475      */
3476     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
3477             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
3478             final boolean commonAxisUsed, final double[] bias,
3479             final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener,
3480             final RobustEstimatorMethod method) {
3481         return switch (method) {
3482             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3483                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, listener);
3484             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3485                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, listener);
3486             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3487                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, listener);
3488             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3489                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, listener);
3490             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3491                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, listener);
3492         };
3493     }
3494 
3495     /**
3496      * Creates a robust accelerometer calibrator.
3497      *
3498      * @param groundTruthGravityNorm ground truth gravity norm.
3499      * @param measurements           collection of body kinematics measurements with standard
3500      *                               deviations taken at the same position with zero velocity
3501      *                               and unknown different orientations.
3502      * @param bias                   known accelerometer bias.
3503      * @param method                 robust estimator method.
3504      * @return a robust accelerometer calibrator.
3505      * @throws IllegalArgumentException if provided bias matrix is not 3x1 or
3506      *                                  if provided gravity norm value is negative.
3507      */
3508     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
3509             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
3510             final Matrix bias, final RobustEstimatorMethod method) {
3511         return switch (method) {
3512             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3513                     groundTruthGravityNorm, measurements, bias);
3514             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3515                     groundTruthGravityNorm, measurements, bias);
3516             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3517                     groundTruthGravityNorm, measurements, bias);
3518             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3519                     groundTruthGravityNorm, measurements, bias);
3520             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3521                     groundTruthGravityNorm, measurements, bias);
3522         };
3523     }
3524 
3525     /**
3526      * Creates a robust accelerometer calibrator.
3527      *
3528      * @param groundTruthGravityNorm ground truth gravity norm.
3529      * @param measurements           collection of body kinematics measurements with standard
3530      *                               deviations taken at the same position with zero velocity
3531      *                               and unknown different orientations.
3532      * @param bias                   known accelerometer bias.
3533      * @param listener               listener to handle events raised by this calibrator.
3534      * @param method                 robust estimator method.
3535      * @return a robust accelerometer calibrator.
3536      * @throws IllegalArgumentException if provided bias matrix is not 3x1 or
3537      *                                  if provided gravity norm value is negative.
3538      */
3539     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
3540             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
3541             final Matrix bias, final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener,
3542             final RobustEstimatorMethod method) {
3543         return switch (method) {
3544             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3545                     groundTruthGravityNorm, measurements, bias, listener);
3546             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3547                     groundTruthGravityNorm, measurements, bias, listener);
3548             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3549                     groundTruthGravityNorm, measurements, bias, listener);
3550             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3551                     groundTruthGravityNorm, measurements, bias, listener);
3552             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3553                     groundTruthGravityNorm, measurements, bias, listener);
3554         };
3555     }
3556 
3557     /**
3558      * Creates a robust accelerometer calibrator.
3559      *
3560      * @param groundTruthGravityNorm ground truth gravity norm.
3561      * @param measurements           collection of body kinematics measurements with standard
3562      *                               deviations taken at the same position with zero velocity
3563      *                               and unknown different orientations.
3564      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
3565      *                               accelerometer and gyroscope.
3566      * @param bias                   known accelerometer bias.
3567      * @param method                 robust estimator method.
3568      * @return a robust accelerometer calibrator.
3569      * @throws IllegalArgumentException if provided bias matrix is not 3x1 or
3570      *                                  if provided gravity norm value is negative.
3571      */
3572     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
3573             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
3574             final boolean commonAxisUsed, final Matrix bias, final RobustEstimatorMethod method) {
3575         return switch (method) {
3576             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3577                     groundTruthGravityNorm, measurements, commonAxisUsed, bias);
3578             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3579                     groundTruthGravityNorm, measurements, commonAxisUsed, bias);
3580             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3581                     groundTruthGravityNorm, measurements, commonAxisUsed, bias);
3582             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3583                     groundTruthGravityNorm, measurements, commonAxisUsed, bias);
3584             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3585                     groundTruthGravityNorm, measurements, commonAxisUsed, bias);
3586         };
3587     }
3588 
3589     /**
3590      * Creates a robust accelerometer calibrator.
3591      *
3592      * @param groundTruthGravityNorm ground truth gravity norm.
3593      * @param measurements           collection of body kinematics measurements with standard
3594      *                               deviations taken at the same position with zero velocity
3595      *                               and unknown different orientations.
3596      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
3597      *                               accelerometer and gyroscope.
3598      * @param bias                   known accelerometer bias.
3599      * @param listener               listener to handle events raised by this calibrator.
3600      * @param method                 robust estimator method.
3601      * @return a robust accelerometer calibrator.
3602      * @throws IllegalArgumentException if provided bias matrix is not 3x1 or
3603      *                                  if provided gravity norm value is negative.
3604      */
3605     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
3606             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
3607             final boolean commonAxisUsed, final Matrix bias,
3608             final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener,
3609             final RobustEstimatorMethod method) {
3610         return switch (method) {
3611             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3612                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, listener);
3613             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3614                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, listener);
3615             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3616                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, listener);
3617             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3618                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, listener);
3619             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3620                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, listener);
3621         };
3622     }
3623 
3624     /**
3625      * Creates a robust accelerometer calibrator.
3626      *
3627      * @param groundTruthGravityNorm ground truth gravity norm.
3628      * @param measurements           collection of body kinematics measurements with standard
3629      *                               deviations taken at the same position with zero velocity
3630      *                               and unknown different orientations.
3631      * @param bias                   known accelerometer bias.
3632      * @param initialMa              initial scale factors and cross coupling errors matrix.
3633      * @param method                 robust estimator method.
3634      * @return a robust accelerometer calibrator.
3635      * @throws IllegalArgumentException if either provided bias matrix is not 3x1 or
3636      *                                  scaling and coupling error matrix is not 3x3 or
3637      *                                  if provided gravity norm value is negative.
3638      */
3639     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
3640             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
3641             final Matrix bias, final Matrix initialMa, final RobustEstimatorMethod method) {
3642         return switch (method) {
3643             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3644                     groundTruthGravityNorm, measurements, bias, initialMa);
3645             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3646                     groundTruthGravityNorm, measurements, bias, initialMa);
3647             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3648                     groundTruthGravityNorm, measurements, bias, initialMa);
3649             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3650                     groundTruthGravityNorm, measurements, bias, initialMa);
3651             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3652                     groundTruthGravityNorm, measurements, bias, initialMa);
3653         };
3654     }
3655 
3656     /**
3657      * Creates a robust accelerometer calibrator.
3658      *
3659      * @param groundTruthGravityNorm ground truth gravity norm.
3660      * @param measurements           collection of body kinematics measurements with standard
3661      *                               deviations taken at the same position with zero velocity
3662      *                               and unknown different orientations.
3663      * @param bias                   known accelerometer bias.
3664      * @param initialMa              initial scale factors and cross coupling errors matrix.
3665      * @param listener               listener to handle events raised by this calibrator.
3666      * @param method                 robust estimator method.
3667      * @return a robust accelerometer calibrator.
3668      * @throws IllegalArgumentException if either provided bias matrix is not 3x1 or
3669      *                                  scaling and coupling error matrix is not 3x3 or
3670      *                                  if provided gravity norm value is negative.
3671      */
3672     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
3673             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
3674             final Matrix bias, final Matrix initialMa,
3675             final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener,
3676             final RobustEstimatorMethod method) {
3677         return switch (method) {
3678             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3679                     groundTruthGravityNorm, measurements, bias, initialMa, listener);
3680             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3681                     groundTruthGravityNorm, measurements, bias, initialMa, listener);
3682             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3683                     groundTruthGravityNorm, measurements, bias, initialMa, listener);
3684             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3685                     groundTruthGravityNorm, measurements, bias, initialMa, listener);
3686             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3687                     groundTruthGravityNorm, measurements, bias, initialMa, listener);
3688         };
3689     }
3690 
3691     /**
3692      * Creates a robust accelerometer calibrator.
3693      *
3694      * @param groundTruthGravityNorm ground truth gravity norm.
3695      * @param measurements           collection of body kinematics measurements with standard
3696      *                               deviations taken at the same position with zero velocity
3697      *                               and unknown different orientations.
3698      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
3699      *                               accelerometer and gyroscope.
3700      * @param bias                   known accelerometer bias.
3701      * @param initialMa              initial scale factors and cross coupling errors matrix.
3702      * @param method                 robust estimator method.
3703      * @return a robust accelerometer calibrator.
3704      * @throws IllegalArgumentException if either provided bias matrix is not 3x1 or
3705      *                                  scaling and coupling error matrix is not 3x3 or
3706      *                                  if provided gravity norm value is negative.
3707      */
3708     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
3709             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
3710             final boolean commonAxisUsed, final Matrix bias, final Matrix initialMa,
3711             final RobustEstimatorMethod method) {
3712         return switch (method) {
3713             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3714                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, initialMa);
3715             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3716                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, initialMa);
3717             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3718                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, initialMa);
3719             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3720                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, initialMa);
3721             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3722                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, initialMa);
3723         };
3724     }
3725 
3726     /**
3727      * Creates a robust accelerometer calibrator.
3728      *
3729      * @param groundTruthGravityNorm ground truth gravity norm.
3730      * @param measurements           collection of body kinematics measurements with standard
3731      *                               deviations taken at the same position with zero velocity
3732      *                               and unknown different orientations.
3733      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
3734      *                               accelerometer and gyroscope.
3735      * @param bias                   known accelerometer bias.
3736      * @param initialMa              initial scale factors and cross coupling errors matrix.
3737      * @param listener               listener to handle events raised by this calibrator.
3738      * @param method                 robust estimator method.
3739      * @return a robust accelerometer calibrator.
3740      * @throws IllegalArgumentException if either provided bias matrix is not 3x1 or
3741      *                                  scaling and coupling error matrix is not 3x3 or
3742      *                                  if provided gravity norm value is negative.
3743      */
3744     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
3745             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
3746             final boolean commonAxisUsed, final Matrix bias, final Matrix initialMa,
3747             final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener,
3748             final RobustEstimatorMethod method) {
3749         return switch (method) {
3750             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3751                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, initialMa, listener);
3752             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3753                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, initialMa, listener);
3754             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3755                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, initialMa, listener);
3756             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3757                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, initialMa, listener);
3758             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3759                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, initialMa, listener);
3760         };
3761     }
3762 
3763     /**
3764      * Creates a robust accelerometer calibrator.
3765      *
3766      * @param qualityScores          quality scores corresponding to each provided
3767      *                               measurement. The larger the score value the better
3768      *                               the quality of the sample.
3769      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
3770      *                               squared second (m/s^2).
3771      * @param measurements           list of body kinematics measurements taken at a given position with
3772      *                               different unknown orientations and containing the standard deviations
3773      *                               of accelerometer and gyroscope measurements.
3774      * @param method                 robust estimator method.
3775      * @return a robust accelerometer calibrator.
3776      * @throws IllegalArgumentException if provided gravity norm value is negative or
3777      *                                  if provided quality scores length is
3778      *                                  smaller than 13 samples.
3779      */
3780     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
3781             final double[] qualityScores, final Double groundTruthGravityNorm,
3782             final List<StandardDeviationBodyKinematics> measurements, final RobustEstimatorMethod method) {
3783         return switch (method) {
3784             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3785                     groundTruthGravityNorm, measurements);
3786             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3787                     groundTruthGravityNorm, measurements);
3788             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3789                     groundTruthGravityNorm, measurements);
3790             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3791                     qualityScores, groundTruthGravityNorm, measurements);
3792             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3793                     qualityScores, groundTruthGravityNorm, measurements);
3794         };
3795     }
3796 
3797     /**
3798      * Creates a robust accelerometer calibrator.
3799      *
3800      * @param qualityScores          quality scores corresponding to each provided
3801      *                               measurement. The larger the score value the better
3802      *                               the quality of the sample.
3803      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
3804      *                               squared second (m/s^2).
3805      * @param measurements           list of body kinematics measurements taken at a given position with
3806      *                               different unknown orientations and containing the standard deviations
3807      *                               of accelerometer and gyroscope measurements.
3808      * @param listener               listener to be notified of events such as when estimation
3809      *                               starts, ends or its progress significantly changes.
3810      * @param method                 robust estimator method.
3811      * @return a robust accelerometer calibrator.
3812      * @throws IllegalArgumentException if provided gravity norm value is negative or
3813      *                                  if provided quality scores length is
3814      *                                  smaller than 13 samples.
3815      */
3816     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
3817             final double[] qualityScores, final Double groundTruthGravityNorm,
3818             final List<StandardDeviationBodyKinematics> measurements,
3819             final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener,
3820             final RobustEstimatorMethod method) {
3821         return switch (method) {
3822             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3823                     groundTruthGravityNorm, measurements, listener);
3824             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3825                     groundTruthGravityNorm, measurements, listener);
3826             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3827                     groundTruthGravityNorm, measurements, listener);
3828             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3829                     qualityScores, groundTruthGravityNorm, measurements, listener);
3830             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3831                     qualityScores, groundTruthGravityNorm, measurements, listener);
3832         };
3833     }
3834 
3835     /**
3836      * Creates a robust accelerometer calibrator.
3837      *
3838      * @param qualityScores          quality scores corresponding to each provided
3839      *                               measurement. The larger the score value the better
3840      *                               the quality of the sample.
3841      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
3842      *                               squared second (m/s^2).
3843      * @param measurements           list of body kinematics measurements taken at a given position with
3844      *                               different unknown orientations and containing the standard deviations
3845      *                               of accelerometer and gyroscope measurements.
3846      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
3847      *                               accelerometer and gyroscope.
3848      * @param method                 robust estimator method.
3849      * @return a robust accelerometer calibrator.
3850      * @throws IllegalArgumentException if provided gravity norm value is negative or
3851      *                                  if provided quality scores length is
3852      *                                  smaller than 10 or 13 samples.
3853      */
3854     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
3855             final double[] qualityScores, final Double groundTruthGravityNorm,
3856             final List<StandardDeviationBodyKinematics> measurements, final boolean commonAxisUsed,
3857             final RobustEstimatorMethod method) {
3858         return switch (method) {
3859             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3860                     groundTruthGravityNorm, measurements, commonAxisUsed);
3861             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3862                     groundTruthGravityNorm, measurements, commonAxisUsed);
3863             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3864                     groundTruthGravityNorm, measurements, commonAxisUsed);
3865             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3866                     qualityScores, groundTruthGravityNorm, measurements, commonAxisUsed);
3867             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3868                     qualityScores, groundTruthGravityNorm, measurements, commonAxisUsed);
3869         };
3870     }
3871 
3872     /**
3873      * Creates a robust accelerometer calibrator.
3874      *
3875      * @param qualityScores          quality scores corresponding to each provided
3876      *                               measurement. The larger the score value the better
3877      *                               the quality of the sample.
3878      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
3879      *                               squared second (m/s^2).
3880      * @param measurements           list of body kinematics measurements taken at a given position with
3881      *                               different unknown orientations and containing the standard deviations
3882      *                               of accelerometer and gyroscope measurements.
3883      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
3884      *                               accelerometer and gyroscope.
3885      * @param listener               listener to be notified of events such as when estimation
3886      *                               starts, ends or its progress significantly changes.
3887      * @param method                 robust estimator method.
3888      * @return a robust accelerometer calibrator.
3889      * @throws IllegalArgumentException if provided gravity norm value is negative or
3890      *                                  if provided quality scores length is
3891      *                                  smaller than 10 or 13 samples.
3892      */
3893     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
3894             final double[] qualityScores,
3895             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
3896             final boolean commonAxisUsed, final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener,
3897             final RobustEstimatorMethod method) {
3898         return switch (method) {
3899             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3900                     groundTruthGravityNorm, measurements, commonAxisUsed, listener);
3901             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3902                     groundTruthGravityNorm, measurements, commonAxisUsed, listener);
3903             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3904                     groundTruthGravityNorm, measurements, commonAxisUsed, listener);
3905             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3906                     qualityScores, groundTruthGravityNorm, measurements, commonAxisUsed, listener);
3907             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3908                     qualityScores, groundTruthGravityNorm, measurements, commonAxisUsed, listener);
3909         };
3910     }
3911 
3912     /**
3913      * Creates a robust accelerometer calibrator.
3914      *
3915      * @param qualityScores          quality scores corresponding to each provided
3916      *                               measurement. The larger the score value the better
3917      *                               the quality of the sample.
3918      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
3919      *                               squared second (m/s^2).
3920      * @param measurements           collection of body kinematics measurements with standard
3921      *                               deviations taken at the same position with zero velocity
3922      *                               and unknown different orientations.
3923      * @param bias                   known accelerometer bias. This must have length 3 and is expressed
3924      *                               in meters per squared second (m/s^2).
3925      * @param method                 robust estimator method.
3926      * @return a robust accelerometer calibrator.
3927      * @throws IllegalArgumentException if provided bias array does not have length 3 or
3928      *                                  if provided gravity norm value is negative or
3929      *                                  if provided quality scores length is
3930      *                                  smaller than 13 samples.
3931      */
3932     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
3933             final double[] qualityScores, final Double groundTruthGravityNorm,
3934             final List<StandardDeviationBodyKinematics> measurements, final double[] bias,
3935             final RobustEstimatorMethod method) {
3936         return switch (method) {
3937             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3938                     groundTruthGravityNorm, measurements, bias);
3939             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3940                     groundTruthGravityNorm, measurements, bias);
3941             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3942                     groundTruthGravityNorm, measurements, bias);
3943             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3944                     qualityScores, groundTruthGravityNorm, measurements, bias);
3945             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3946                     qualityScores, groundTruthGravityNorm, measurements, bias);
3947         };
3948     }
3949 
3950     /**
3951      * Creates a robust accelerometer calibrator.
3952      *
3953      * @param qualityScores          quality scores corresponding to each provided
3954      *                               measurement. The larger the score value the better
3955      *                               the quality of the sample.
3956      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
3957      *                               squared second (m/s^2).
3958      * @param measurements           collection of body kinematics measurements with standard
3959      *                               deviations taken at the same position with zero velocity
3960      *                               and unknown different orientations.
3961      * @param bias                   known accelerometer bias. This must have length 3 and is expressed
3962      *                               in meters per squared second (m/s^2).
3963      * @param listener               listener to handle events raised by this calibrator.
3964      * @param method                 robust estimator method.
3965      * @return a robust accelerometer calibrator.
3966      * @throws IllegalArgumentException if provided bias array does not have length 3 or
3967      *                                  if provided gravity norm value is negative or
3968      *                                  if provided quality scores length is
3969      *                                  smaller than 13 samples.
3970      */
3971     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
3972             final double[] qualityScores, final Double groundTruthGravityNorm,
3973             final List<StandardDeviationBodyKinematics> measurements, final double[] bias,
3974             final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener,
3975             final RobustEstimatorMethod method) {
3976         return switch (method) {
3977             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3978                     groundTruthGravityNorm, measurements, bias, listener);
3979             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3980                     groundTruthGravityNorm, measurements, bias, listener);
3981             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3982                     groundTruthGravityNorm, measurements, bias, listener);
3983             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3984                     qualityScores, groundTruthGravityNorm, measurements, bias, listener);
3985             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
3986                     qualityScores, groundTruthGravityNorm, measurements, bias, listener);
3987         };
3988     }
3989 
3990     /**
3991      * Creates a robust accelerometer calibrator.
3992      *
3993      * @param qualityScores          quality scores corresponding to each provided
3994      *                               measurement. The larger the score value the better
3995      *                               the quality of the sample.
3996      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
3997      *                               squared second (m/s^2).
3998      * @param measurements           collection of body kinematics measurements with standard
3999      *                               deviations taken at the same position with zero velocity
4000      *                               and unknown different orientations.
4001      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
4002      *                               accelerometer and gyroscope.
4003      * @param bias                   known accelerometer bias. This must have length 3 and is expressed
4004      *                               in meters per squared second (m/s^2).
4005      * @param method                 robust estimator method.
4006      * @return a robust accelerometer calibrator.
4007      * @throws IllegalArgumentException if provided bias array does not have length 3 or
4008      *                                  if provided gravity norm value is negative or
4009      *                                  if provided quality scores length is
4010      *                                  smaller than 10 or 13 samples.
4011      */
4012     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
4013             final double[] qualityScores, final Double groundTruthGravityNorm,
4014             final List<StandardDeviationBodyKinematics> measurements, final boolean commonAxisUsed,
4015             final double[] bias, final RobustEstimatorMethod method) {
4016         return switch (method) {
4017             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4018                     groundTruthGravityNorm, measurements, commonAxisUsed, bias);
4019             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4020                     groundTruthGravityNorm, measurements, commonAxisUsed, bias);
4021             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4022                     groundTruthGravityNorm, measurements, commonAxisUsed, bias);
4023             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4024                     qualityScores, groundTruthGravityNorm, measurements, commonAxisUsed, bias);
4025             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4026                     qualityScores, groundTruthGravityNorm, measurements, commonAxisUsed, bias);
4027         };
4028     }
4029 
4030     /**
4031      * Creates a robust accelerometer calibrator.
4032      *
4033      * @param qualityScores          quality scores corresponding to each provided
4034      *                               measurement. The larger the score value the better
4035      *                               the quality of the sample.
4036      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
4037      *                               squared second (m/s^2).
4038      * @param measurements           collection of body kinematics measurements with standard
4039      *                               deviations taken at the same position with zero velocity
4040      *                               and unknown different orientations.
4041      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
4042      *                               accelerometer and gyroscope.
4043      * @param bias                   known accelerometer bias. This must have length 3 and is expressed
4044      *                               in meters per squared second (m/s^2).
4045      * @param listener               listener to handle events raised by this calibrator.
4046      * @param method                 robust estimator method.
4047      * @return a robust accelerometer calibrator.
4048      * @throws IllegalArgumentException if provided bias array does not have length 3 or
4049      *                                  if provided gravity norm value is negative or
4050      *                                  if provided quality scores length is
4051      *                                  smaller than 10 or 13 samples.
4052      */
4053     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
4054             final double[] qualityScores, final Double groundTruthGravityNorm,
4055             final List<StandardDeviationBodyKinematics> measurements, final boolean commonAxisUsed,
4056             final double[] bias, final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener,
4057             final RobustEstimatorMethod method) {
4058         return switch (method) {
4059             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4060                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, listener);
4061             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4062                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, listener);
4063             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4064                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, listener);
4065             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4066                     qualityScores, groundTruthGravityNorm, measurements, commonAxisUsed, bias, listener);
4067             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4068                     qualityScores, groundTruthGravityNorm, measurements, commonAxisUsed, bias, listener);
4069         };
4070     }
4071 
4072     /**
4073      * Creates a robust accelerometer calibrator.
4074      *
4075      * @param qualityScores          quality scores corresponding to each provided
4076      *                               measurement. The larger the score value the better
4077      *                               the quality of the sample.
4078      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
4079      *                               squared second (m/s^2).
4080      * @param measurements           collection of body kinematics measurements with standard
4081      *                               deviations taken at the same position with zero velocity
4082      *                               and unknown different orientations.
4083      * @param bias                   known accelerometer bias.
4084      * @param method                 robust estimator method.
4085      * @return a robust accelerometer calibrator.
4086      * @throws IllegalArgumentException if provided bias array does not have length 3 or
4087      *                                  if provided gravity norm value is negative or
4088      *                                  if provided quality scores length is
4089      *                                  smaller than 13 samples.
4090      */
4091     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
4092             final double[] qualityScores, final Double groundTruthGravityNorm,
4093             final List<StandardDeviationBodyKinematics> measurements, final Matrix bias,
4094             final RobustEstimatorMethod method) {
4095         return switch (method) {
4096             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4097                     groundTruthGravityNorm, measurements, bias);
4098             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4099                     groundTruthGravityNorm, measurements, bias);
4100             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4101                     groundTruthGravityNorm, measurements, bias);
4102             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4103                     qualityScores, groundTruthGravityNorm, measurements, bias);
4104             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4105                     qualityScores, groundTruthGravityNorm, measurements, bias);
4106         };
4107     }
4108 
4109     /**
4110      * Creates a robust accelerometer calibrator.
4111      *
4112      * @param qualityScores          quality scores corresponding to each provided
4113      *                               measurement. The larger the score value the better
4114      *                               the quality of the sample.
4115      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
4116      *                               squared second (m/s^2).
4117      * @param measurements           collection of body kinematics measurements with standard
4118      *                               deviations taken at the same position with zero velocity
4119      *                               and unknown different orientations.
4120      * @param bias                   known accelerometer bias.
4121      * @param listener               listener to handle events raised by this calibrator.
4122      * @param method                 robust estimator method.
4123      * @return a robust accelerometer calibrator.
4124      * @throws IllegalArgumentException if provided bias matrix is not 3x1 or
4125      *                                  if provided gravity norm value is negative or
4126      *                                  if provided quality scores length is
4127      *                                  smaller than 13 samples.
4128      */
4129     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
4130             final double[] qualityScores, final Double groundTruthGravityNorm,
4131             final List<StandardDeviationBodyKinematics> measurements, final Matrix bias,
4132             final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener,
4133             final RobustEstimatorMethod method) {
4134         return switch (method) {
4135             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4136                     groundTruthGravityNorm, measurements, bias, listener);
4137             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4138                     groundTruthGravityNorm, measurements, bias, listener);
4139             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4140                     groundTruthGravityNorm, measurements, bias, listener);
4141             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4142                     qualityScores, groundTruthGravityNorm, measurements, bias, listener);
4143             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4144                     qualityScores, groundTruthGravityNorm, measurements, bias, listener);
4145         };
4146     }
4147 
4148     /**
4149      * Creates a robust accelerometer calibrator.
4150      *
4151      * @param qualityScores          quality scores corresponding to each provided
4152      *                               measurement. The larger the score value the better
4153      *                               the quality of the sample.
4154      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
4155      *                               squared second (m/s^2).
4156      * @param measurements           collection of body kinematics measurements with standard
4157      *                               deviations taken at the same position with zero velocity
4158      *                               and unknown different orientations.
4159      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
4160      *                               accelerometer and gyroscope.
4161      * @param bias                   known accelerometer bias.
4162      * @param method                 robust estimator method.
4163      * @return a robust accelerometer calibrator.
4164      * @throws IllegalArgumentException if provided bias matrix is not 3x1 or
4165      *                                  if provided gravity norm value is negative or
4166      *                                  if provided quality scores length is
4167      *                                  smaller than 10 or 13 samples.
4168      */
4169     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
4170             final double[] qualityScores, final Double groundTruthGravityNorm,
4171             final List<StandardDeviationBodyKinematics> measurements, final boolean commonAxisUsed, final Matrix bias,
4172             final RobustEstimatorMethod method) {
4173         return switch (method) {
4174             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4175                     groundTruthGravityNorm, measurements, commonAxisUsed, bias);
4176             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4177                     groundTruthGravityNorm, measurements, commonAxisUsed, bias);
4178             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4179                     groundTruthGravityNorm, measurements, commonAxisUsed, bias);
4180             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4181                     qualityScores, groundTruthGravityNorm, measurements, commonAxisUsed, bias);
4182             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4183                     qualityScores, groundTruthGravityNorm, measurements, commonAxisUsed, bias);
4184         };
4185     }
4186 
4187     /**
4188      * Creates a robust accelerometer calibrator.
4189      *
4190      * @param qualityScores          quality scores corresponding to each provided
4191      *                               measurement. The larger the score value the better
4192      *                               the quality of the sample.
4193      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
4194      *                               squared second (m/s^2).
4195      * @param measurements           collection of body kinematics measurements with standard
4196      *                               deviations taken at the same position with zero velocity
4197      *                               and unknown different orientations.
4198      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
4199      *                               accelerometer and gyroscope.
4200      * @param bias                   known accelerometer bias.
4201      * @param listener               listener to handle events raised by this calibrator.
4202      * @param method                 robust estimator method.
4203      * @return a robust accelerometer calibrator.
4204      * @throws IllegalArgumentException if provided bias matrix is not 3x1 or
4205      *                                  if provided gravity norm value is negative or
4206      *                                  if provided quality scores length is
4207      *                                  smaller than 10 or 13 samples.
4208      */
4209     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
4210             final double[] qualityScores, final Double groundTruthGravityNorm,
4211             final List<StandardDeviationBodyKinematics> measurements, final boolean commonAxisUsed, final Matrix bias,
4212             final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener,
4213             final RobustEstimatorMethod method) {
4214         return switch (method) {
4215             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4216                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, listener);
4217             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4218                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, listener);
4219             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4220                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, listener);
4221             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4222                     qualityScores, groundTruthGravityNorm, measurements, commonAxisUsed, bias, listener);
4223             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4224                     qualityScores, groundTruthGravityNorm, measurements, commonAxisUsed, bias, listener);
4225         };
4226     }
4227 
4228     /**
4229      * Creates a robust accelerometer calibrator.
4230      *
4231      * @param qualityScores          quality scores corresponding to each provided
4232      *                               measurement. The larger the score value the better
4233      *                               the quality of the sample.
4234      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
4235      *                               squared second (m/s^2).
4236      * @param measurements           collection of body kinematics measurements with standard
4237      *                               deviations taken at the same position with zero velocity
4238      *                               and unknown different orientations.
4239      * @param bias                   known accelerometer bias.
4240      * @param initialMa              initial scale factors and cross coupling errors matrix.
4241      * @param method                 robust estimator method.
4242      * @return a robust accelerometer calibrator.
4243      * @throws IllegalArgumentException if either provided bias matrix is not 3x1 or
4244      *                                  scaling and coupling error matrix is not 3x3 or
4245      *                                  if provided gravity norm value is negative or
4246      *                                  if provided quality scores length is
4247      *                                  smaller than 13 samples.
4248      */
4249     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
4250             final double[] qualityScores, final Double groundTruthGravityNorm,
4251             final List<StandardDeviationBodyKinematics> measurements, final Matrix bias, final Matrix initialMa,
4252             final RobustEstimatorMethod method) {
4253         return switch (method) {
4254             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4255                     groundTruthGravityNorm, measurements, bias, initialMa);
4256             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4257                     groundTruthGravityNorm, measurements, bias, initialMa);
4258             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4259                     groundTruthGravityNorm, measurements, bias, initialMa);
4260             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4261                     qualityScores, groundTruthGravityNorm, measurements, bias, initialMa);
4262             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4263                     qualityScores, groundTruthGravityNorm, measurements, bias, initialMa);
4264         };
4265     }
4266 
4267     /**
4268      * Creates a robust accelerometer calibrator.
4269      *
4270      * @param qualityScores          quality scores corresponding to each provided
4271      *                               measurement. The larger the score value the better
4272      *                               the quality of the sample.
4273      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
4274      *                               squared second (m/s^2).
4275      * @param measurements           collection of body kinematics measurements with standard
4276      *                               deviations taken at the same position with zero velocity
4277      *                               and unknown different orientations.
4278      * @param bias                   known accelerometer bias.
4279      * @param initialMa              initial scale factors and cross coupling errors matrix.
4280      * @param listener               listener to handle events raised by this calibrator.
4281      * @param method                 robust estimator method.
4282      * @return a robust accelerometer calibrator.
4283      * @throws IllegalArgumentException if either provided bias matrix is not 3x1 or
4284      *                                  scaling and coupling error matrix is not 3x3 or
4285      *                                  if provided gravity norm value is negative or
4286      *                                  if provided quality scores length is
4287      *                                  smaller than 13 samples.
4288      */
4289     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
4290             final double[] qualityScores, final Double groundTruthGravityNorm,
4291             final List<StandardDeviationBodyKinematics> measurements, final Matrix bias, final Matrix initialMa,
4292             final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener,
4293             final RobustEstimatorMethod method) {
4294         return switch (method) {
4295             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4296                     groundTruthGravityNorm, measurements, bias, initialMa, listener);
4297             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4298                     groundTruthGravityNorm, measurements, bias, initialMa, listener);
4299             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4300                     groundTruthGravityNorm, measurements, bias, initialMa, listener);
4301             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4302                     qualityScores, groundTruthGravityNorm, measurements, bias, initialMa, listener);
4303             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4304                     qualityScores, groundTruthGravityNorm, measurements, bias, initialMa, listener);
4305         };
4306     }
4307 
4308     /**
4309      * Creates a robust accelerometer calibrator.
4310      *
4311      * @param qualityScores          quality scores corresponding to each provided
4312      *                               measurement. The larger the score value the better
4313      *                               the quality of the sample.
4314      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
4315      *                               squared second (m/s^2).
4316      * @param measurements           collection of body kinematics measurements with standard
4317      *                               deviations taken at the same position with zero velocity
4318      *                               and unknown different orientations.
4319      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
4320      *                               accelerometer and gyroscope.
4321      * @param bias                   known accelerometer bias.
4322      * @param initialMa              initial scale factors and cross coupling errors matrix.
4323      * @param method                 robust estimator method.
4324      * @return a robust accelerometer calibrator.
4325      * @throws IllegalArgumentException if either provided bias matrix is not 3x1 or
4326      *                                  scaling and coupling error matrix is not 3x3 or
4327      *                                  if provided gravity norm value is negative or
4328      *                                  if provided quality scores length is
4329      *                                  smaller than 10 or 13 samples.
4330      */
4331     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
4332             final double[] qualityScores, final Double groundTruthGravityNorm,
4333             final List<StandardDeviationBodyKinematics> measurements, final boolean commonAxisUsed, final Matrix bias,
4334             final Matrix initialMa, final RobustEstimatorMethod method) {
4335         return switch (method) {
4336             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4337                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, initialMa);
4338             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4339                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, initialMa);
4340             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4341                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, initialMa);
4342             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4343                     qualityScores, groundTruthGravityNorm, measurements, commonAxisUsed, bias, initialMa);
4344             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4345                     qualityScores, groundTruthGravityNorm, measurements, commonAxisUsed, bias, initialMa);
4346         };
4347     }
4348 
4349     /**
4350      * Creates a robust accelerometer calibrator.
4351      *
4352      * @param qualityScores          quality scores corresponding to each provided
4353      *                               measurement. The larger the score value the better
4354      *                               the quality of the sample.
4355      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
4356      *                               squared second (m/s^2).
4357      * @param measurements           collection of body kinematics measurements with standard
4358      *                               deviations taken at the same position with zero velocity
4359      *                               and unknown different orientations.
4360      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
4361      *                               accelerometer and gyroscope.
4362      * @param bias                   known accelerometer bias.
4363      * @param initialMa              initial scale factors and cross coupling errors matrix.
4364      * @param listener               listener to handle events raised by this calibrator.
4365      * @param method                 robust estimator method.
4366      * @return a robust accelerometer calibrator.
4367      * @throws IllegalArgumentException if either provided bias matrix is not 3x1 or
4368      *                                  scaling and coupling error matrix is not 3x3 or
4369      *                                  if provided gravity norm value is negative or
4370      *                                  if provided quality scores length is
4371      *                                  smaller than 10 or 13 samples.
4372      */
4373     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
4374             final double[] qualityScores, final Double groundTruthGravityNorm,
4375             final List<StandardDeviationBodyKinematics> measurements, final boolean commonAxisUsed, final Matrix bias,
4376             final Matrix initialMa, final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener,
4377             final RobustEstimatorMethod method) {
4378         return switch (method) {
4379             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4380                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, initialMa, listener);
4381             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4382                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, initialMa, listener);
4383             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4384                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, initialMa, listener);
4385             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4386                     qualityScores, groundTruthGravityNorm, measurements, commonAxisUsed, bias, initialMa, listener);
4387             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4388                     qualityScores, groundTruthGravityNorm, measurements, commonAxisUsed, bias, initialMa, listener);
4389         };
4390     }
4391 
4392     /**
4393      * Creates a robust accelerometer calibrator.
4394      *
4395      * @param qualityScores          quality scores corresponding to each provided
4396      *                               measurement. The larger the score value the better
4397      *                               the quality of the sample.
4398      * @param groundTruthGravityNorm ground truth gravity norm.
4399      * @param method                 robust estimator method.
4400      * @return a robust accelerometer calibrator.
4401      * @throws IllegalArgumentException if provided gravity norm value is negative or
4402      *                                  if provided quality scores length is smaller
4403      *                                  than 13 samples.
4404      */
4405     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
4406             final double[] qualityScores, final Acceleration groundTruthGravityNorm,
4407             final RobustEstimatorMethod method) {
4408         return switch (method) {
4409             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(groundTruthGravityNorm);
4410             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(groundTruthGravityNorm);
4411             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(groundTruthGravityNorm);
4412             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4413                     qualityScores, groundTruthGravityNorm);
4414             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4415                     qualityScores, groundTruthGravityNorm);
4416         };
4417     }
4418 
4419     /**
4420      * Creates a robust accelerometer calibrator.
4421      *
4422      * @param qualityScores          quality scores corresponding to each provided
4423      *                               measurement. The larger the score value the better
4424      *                               the quality of the sample.
4425      * @param groundTruthGravityNorm ground truth gravity norm.
4426      * @param measurements           list of body kinematics measurements taken at a given position with
4427      *                               different unknown orientations and containing the standard deviations
4428      *                               of accelerometer and gyroscope measurements.
4429      * @param method                 robust estimator method.
4430      * @return a robust accelerometer calibrator.
4431      * @throws IllegalArgumentException if provided gravity norm value is negative or
4432      *                                  if provided quality scores length is smaller
4433      *                                  than 13 samples.
4434      */
4435     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
4436             final double[] qualityScores, final Acceleration groundTruthGravityNorm,
4437             final List<StandardDeviationBodyKinematics> measurements, final RobustEstimatorMethod method) {
4438         return switch (method) {
4439             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4440                     groundTruthGravityNorm, measurements);
4441             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4442                     groundTruthGravityNorm, measurements);
4443             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4444                     groundTruthGravityNorm, measurements);
4445             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4446                     qualityScores, groundTruthGravityNorm, measurements);
4447             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4448                     qualityScores, groundTruthGravityNorm, measurements);
4449         };
4450     }
4451 
4452     /**
4453      * Creates a robust accelerometer calibrator.
4454      *
4455      * @param qualityScores          quality scores corresponding to each provided
4456      *                               measurement. The larger the score value the better
4457      *                               the quality of the sample.
4458      * @param groundTruthGravityNorm ground truth gravity norm.
4459      * @param measurements           list of body kinematics measurements taken at a given position with
4460      *                               different unknown orientations and containing the standard deviations
4461      *                               of accelerometer and gyroscope measurements.
4462      * @param listener               listener to be notified of events such as when estimation
4463      *                               starts, ends or its progress significantly changes.
4464      * @param method                 robust estimator method.
4465      * @return a robust accelerometer calibrator.
4466      * @throws IllegalArgumentException if provided gravity norm value is negative or
4467      *                                  if provided quality scores length is smaller
4468      *                                  than 13 samples.
4469      */
4470     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
4471             final double[] qualityScores, final Acceleration groundTruthGravityNorm,
4472             final List<StandardDeviationBodyKinematics> measurements,
4473             final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener,
4474             final RobustEstimatorMethod method) {
4475         return switch (method) {
4476             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4477                     groundTruthGravityNorm, measurements, listener);
4478             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4479                     groundTruthGravityNorm, measurements, listener);
4480             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4481                     groundTruthGravityNorm, measurements, listener);
4482             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4483                     qualityScores, groundTruthGravityNorm, measurements, listener);
4484             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4485                     qualityScores, groundTruthGravityNorm, measurements, listener);
4486         };
4487     }
4488 
4489     /**
4490      * Creates a robust accelerometer calibrator.
4491      *
4492      * @param qualityScores          quality scores corresponding to each provided
4493      *                               measurement. The larger the score value the better
4494      *                               the quality of the sample.
4495      * @param groundTruthGravityNorm ground truth gravity norm.
4496      * @param measurements           list of body kinematics measurements taken at a given position with
4497      *                               different unknown orientations and containing the standard deviations
4498      *                               of accelerometer and gyroscope measurements.
4499      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
4500      *                               accelerometer and gyroscope.
4501      * @param method                 robust estimator method.
4502      * @return a robust accelerometer calibrator.
4503      * @throws IllegalArgumentException if provided gravity norm value is negative or
4504      *                                  if provided quality scores length is smaller
4505      *                                  than 10 or 13 samples.
4506      */
4507     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
4508             final double[] qualityScores, final Acceleration groundTruthGravityNorm,
4509             final List<StandardDeviationBodyKinematics> measurements, final boolean commonAxisUsed,
4510             final RobustEstimatorMethod method) {
4511         return switch (method) {
4512             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4513                     groundTruthGravityNorm, measurements, commonAxisUsed);
4514             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4515                     groundTruthGravityNorm, measurements, commonAxisUsed);
4516             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4517                     groundTruthGravityNorm, measurements, commonAxisUsed);
4518             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4519                     qualityScores, groundTruthGravityNorm, measurements, commonAxisUsed);
4520             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4521                     qualityScores, groundTruthGravityNorm, measurements, commonAxisUsed);
4522         };
4523     }
4524 
4525     /**
4526      * Creates a robust accelerometer calibrator.
4527      *
4528      * @param qualityScores          quality scores corresponding to each provided
4529      *                               measurement. The larger the score value the better
4530      *                               the quality of the sample.
4531      * @param groundTruthGravityNorm ground truth gravity norm.
4532      * @param measurements           list of body kinematics measurements taken at a given position with
4533      *                               different unknown orientations and containing the standard deviations
4534      *                               of accelerometer and gyroscope measurements.
4535      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
4536      *                               accelerometer and gyroscope.
4537      * @param listener               listener to be notified of events such as when estimation
4538      *                               starts, ends or its progress significantly changes.
4539      * @param method                 robust estimator method.
4540      * @return a robust accelerometer calibrator.
4541      * @throws IllegalArgumentException if provided gravity norm value is negative or
4542      *                                  if provided quality scores length is smaller
4543      *                                  than 10 or 13 samples.
4544      */
4545     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
4546             final double[] qualityScores, final Acceleration groundTruthGravityNorm,
4547             final List<StandardDeviationBodyKinematics> measurements, final boolean commonAxisUsed,
4548             final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener,
4549             final RobustEstimatorMethod method) {
4550         return switch (method) {
4551             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4552                     groundTruthGravityNorm, measurements, commonAxisUsed, listener);
4553             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4554                     groundTruthGravityNorm, measurements, commonAxisUsed, listener);
4555             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4556                     groundTruthGravityNorm, measurements, commonAxisUsed, listener);
4557             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4558                     qualityScores, groundTruthGravityNorm, measurements, commonAxisUsed, listener);
4559             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4560                     qualityScores, groundTruthGravityNorm, measurements, commonAxisUsed, listener);
4561         };
4562     }
4563 
4564     /**
4565      * Creates a robust accelerometer calibrator.
4566      *
4567      * @param qualityScores          quality scores corresponding to each provided
4568      *                               measurement. The larger the score value the better
4569      *                               the quality of the sample.
4570      * @param groundTruthGravityNorm ground truth gravity norm.
4571      * @param measurements           collection of body kinematics measurements with standard
4572      *                               deviations taken at the same position with zero velocity
4573      *                               and unknown different orientations.
4574      * @param bias                   known accelerometer bias. This must have length 3 and is expressed
4575      *                               in meters per squared second (m/s^2).
4576      * @param method                 robust estimator method.
4577      * @return a robust accelerometer calibrator.
4578      * @throws IllegalArgumentException if provided bias array does not have length 3 or
4579      *                                  if provided gravity norm value is negative or
4580      *                                  if provided quality scores length is smaller
4581      *                                  than 13 samples.
4582      */
4583     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
4584             final double[] qualityScores, final Acceleration groundTruthGravityNorm,
4585             final List<StandardDeviationBodyKinematics> measurements, final double[] bias,
4586             final RobustEstimatorMethod method) {
4587         return switch (method) {
4588             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4589                     groundTruthGravityNorm, measurements, bias);
4590             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4591                     groundTruthGravityNorm, measurements, bias);
4592             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4593                     groundTruthGravityNorm, measurements, bias);
4594             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4595                     qualityScores, groundTruthGravityNorm, measurements, bias);
4596             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4597                     qualityScores, groundTruthGravityNorm, measurements, bias);
4598         };
4599     }
4600 
4601     /**
4602      * Creates a robust accelerometer calibrator.
4603      *
4604      * @param qualityScores          quality scores corresponding to each provided
4605      *                               measurement. The larger the score value the better
4606      *                               the quality of the sample.
4607      * @param groundTruthGravityNorm ground truth gravity norm.
4608      * @param measurements           collection of body kinematics measurements with standard
4609      *                               deviations taken at the same position with zero velocity
4610      *                               and unknown different orientations.
4611      * @param bias                   known accelerometer bias. This must have length 3 and is expressed
4612      *                               in meters per squared second (m/s^2).
4613      * @param listener               listener to handle events raised by this calibrator.
4614      * @param method                 robust estimator method.
4615      * @return a robust accelerometer calibrator.
4616      * @throws IllegalArgumentException if provided bias array does not have length 3 or
4617      *                                  if provided gravity norm value is negative or
4618      *                                  if provided quality scores length is smaller
4619      *                                  than 13 samples.
4620      */
4621     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
4622             final double[] qualityScores, final Acceleration groundTruthGravityNorm,
4623             final List<StandardDeviationBodyKinematics> measurements, final double[] bias,
4624             final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener,
4625             final RobustEstimatorMethod method) {
4626         return switch (method) {
4627             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4628                     groundTruthGravityNorm, measurements, bias, listener);
4629             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4630                     groundTruthGravityNorm, measurements, bias, listener);
4631             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4632                     groundTruthGravityNorm, measurements, bias, listener);
4633             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4634                     qualityScores, groundTruthGravityNorm, measurements, bias, listener);
4635             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4636                     qualityScores, groundTruthGravityNorm, measurements, bias, listener);
4637         };
4638     }
4639 
4640     /**
4641      * Creates a robust accelerometer calibrator.
4642      *
4643      * @param qualityScores          quality scores corresponding to each provided
4644      *                               measurement. The larger the score value the better
4645      *                               the quality of the sample.
4646      * @param groundTruthGravityNorm ground truth gravity norm.
4647      * @param measurements           collection of body kinematics measurements with standard
4648      *                               deviations taken at the same position with zero velocity
4649      *                               and unknown different orientations.
4650      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
4651      *                               accelerometer and gyroscope.
4652      * @param bias                   known accelerometer bias. This must have length 3 and is expressed
4653      *                               in meters per squared second (m/s^2).
4654      * @param method                 robust estimator method.
4655      * @return a robust accelerometer calibrator.
4656      * @throws IllegalArgumentException if provided bias array does not have length 3 or
4657      *                                  if provided gravity norm value is negative or
4658      *                                  if provided quality scores length is smaller
4659      *                                  than 10 or 13 samples.
4660      */
4661     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
4662             final double[] qualityScores, final Acceleration groundTruthGravityNorm,
4663             final List<StandardDeviationBodyKinematics> measurements, final boolean commonAxisUsed, final double[] bias,
4664             final RobustEstimatorMethod method) {
4665         return switch (method) {
4666             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4667                     groundTruthGravityNorm, measurements, commonAxisUsed, bias);
4668             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4669                     groundTruthGravityNorm, measurements, commonAxisUsed, bias);
4670             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4671                     groundTruthGravityNorm, measurements, commonAxisUsed, bias);
4672             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4673                     qualityScores, groundTruthGravityNorm, measurements, commonAxisUsed, bias);
4674             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4675                     qualityScores, groundTruthGravityNorm, measurements, commonAxisUsed, bias);
4676         };
4677     }
4678 
4679     /**
4680      * Creates a robust accelerometer calibrator.
4681      *
4682      * @param qualityScores          quality scores corresponding to each provided
4683      *                               measurement. The larger the score value the better
4684      *                               the quality of the sample.
4685      * @param groundTruthGravityNorm ground truth gravity norm.
4686      * @param measurements           collection of body kinematics measurements with standard
4687      *                               deviations taken at the same position with zero velocity
4688      *                               and unknown different orientations.
4689      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
4690      *                               accelerometer and gyroscope.
4691      * @param bias                   known accelerometer bias. This must have length 3 and is expressed
4692      *                               in meters per squared second (m/s^2).
4693      * @param listener               listener to handle events raised by this calibrator.
4694      * @param method                 robust estimator method.
4695      * @return a robust accelerometer calibrator.
4696      * @throws IllegalArgumentException if provided bias array does not have length 3 or
4697      *                                  if provided gravity norm value is negative or
4698      *                                  if provided quality scores length is smaller
4699      *                                  than 10 or 13 samples.
4700      */
4701     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
4702             final double[] qualityScores, final Acceleration groundTruthGravityNorm,
4703             final List<StandardDeviationBodyKinematics> measurements,
4704             final boolean commonAxisUsed, final double[] bias,
4705             final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener,
4706             final RobustEstimatorMethod method) {
4707         return switch (method) {
4708             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4709                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, listener);
4710             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4711                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, listener);
4712             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4713                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, listener);
4714             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4715                     qualityScores, groundTruthGravityNorm, measurements, commonAxisUsed, bias, listener);
4716             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4717                     qualityScores, groundTruthGravityNorm, measurements, commonAxisUsed, bias, listener);
4718         };
4719     }
4720 
4721     /**
4722      * Creates a robust accelerometer calibrator.
4723      *
4724      * @param qualityScores          quality scores corresponding to each provided
4725      *                               measurement. The larger the score value the better
4726      *                               the quality of the sample.
4727      * @param groundTruthGravityNorm ground truth gravity norm.
4728      * @param measurements           collection of body kinematics measurements with standard
4729      *                               deviations taken at the same position with zero velocity
4730      *                               and unknown different orientations.
4731      * @param bias                   known accelerometer bias.
4732      * @param method                 robust estimator method.
4733      * @return a robust accelerometer calibrator.
4734      * @throws IllegalArgumentException if provided bias matrix is not 3x1 or
4735      *                                  if provided gravity norm value is negative or
4736      *                                  if provided quality scores length is smaller
4737      *                                  than 13 samples.
4738      */
4739     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
4740             final double[] qualityScores, final Acceleration groundTruthGravityNorm,
4741             final List<StandardDeviationBodyKinematics> measurements, final Matrix bias,
4742             final RobustEstimatorMethod method) {
4743         return switch (method) {
4744             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4745                     groundTruthGravityNorm, measurements, bias);
4746             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4747                     groundTruthGravityNorm, measurements, bias);
4748             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4749                     groundTruthGravityNorm, measurements, bias);
4750             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4751                     qualityScores, groundTruthGravityNorm, measurements, bias);
4752             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4753                     qualityScores, groundTruthGravityNorm, measurements, bias);
4754         };
4755     }
4756 
4757     /**
4758      * Creates a robust accelerometer calibrator.
4759      *
4760      * @param qualityScores          quality scores corresponding to each provided
4761      *                               measurement. The larger the score value the better
4762      *                               the quality of the sample.
4763      * @param groundTruthGravityNorm ground truth gravity norm.
4764      * @param measurements           collection of body kinematics measurements with standard
4765      *                               deviations taken at the same position with zero velocity
4766      *                               and unknown different orientations.
4767      * @param bias                   known accelerometer bias.
4768      * @param listener               listener to handle events raised by this calibrator.
4769      * @param method                 robust estimator method.
4770      * @return a robust accelerometer calibrator.
4771      * @throws IllegalArgumentException if provided bias matrix is not 3x1 or
4772      *                                  if provided gravity norm value is negative or
4773      *                                  if provided quality scores length is smaller
4774      *                                  than 13 samples.
4775      */
4776     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
4777             final double[] qualityScores, final Acceleration groundTruthGravityNorm,
4778             final List<StandardDeviationBodyKinematics> measurements, final Matrix bias,
4779             final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener,
4780             final RobustEstimatorMethod method) {
4781         return switch (method) {
4782             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4783                     groundTruthGravityNorm, measurements, bias, listener);
4784             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4785                     groundTruthGravityNorm, measurements, bias, listener);
4786             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4787                     groundTruthGravityNorm, measurements, bias, listener);
4788             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4789                     qualityScores, groundTruthGravityNorm, measurements, bias, listener);
4790             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4791                     qualityScores, groundTruthGravityNorm, measurements, bias, listener);
4792         };
4793     }
4794 
4795     /**
4796      * Creates a robust accelerometer calibrator.
4797      *
4798      * @param qualityScores          quality scores corresponding to each provided
4799      *                               measurement. The larger the score value the better
4800      *                               the quality of the sample.
4801      * @param groundTruthGravityNorm ground truth gravity norm.
4802      * @param measurements           collection of body kinematics measurements with standard
4803      *                               deviations taken at the same position with zero velocity
4804      *                               and unknown different orientations.
4805      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
4806      *                               accelerometer and gyroscope.
4807      * @param bias                   known accelerometer bias.
4808      * @param method                 robust estimator method.
4809      * @return a robust accelerometer calibrator.
4810      * @throws IllegalArgumentException if provided bias matrix is not 3x1 or
4811      *                                  if provided gravity norm value is negative or
4812      *                                  if provided quality scores length is smaller
4813      *                                  than 10 or 13 samples.
4814      */
4815     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
4816             final double[] qualityScores, final Acceleration groundTruthGravityNorm,
4817             final List<StandardDeviationBodyKinematics> measurements, final boolean commonAxisUsed, final Matrix bias,
4818             final RobustEstimatorMethod method) {
4819         return switch (method) {
4820             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4821                     groundTruthGravityNorm, measurements, commonAxisUsed, bias);
4822             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4823                     groundTruthGravityNorm, measurements, commonAxisUsed, bias);
4824             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4825                     groundTruthGravityNorm, measurements, commonAxisUsed, bias);
4826             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4827                     qualityScores, groundTruthGravityNorm, measurements, commonAxisUsed, bias);
4828             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4829                     qualityScores, groundTruthGravityNorm, measurements, commonAxisUsed, bias);
4830         };
4831     }
4832 
4833     /**
4834      * Creates a robust accelerometer calibrator.
4835      *
4836      * @param qualityScores          quality scores corresponding to each provided
4837      *                               measurement. The larger the score value the better
4838      *                               the quality of the sample.
4839      * @param groundTruthGravityNorm ground truth gravity norm.
4840      * @param measurements           collection of body kinematics measurements with standard
4841      *                               deviations taken at the same position with zero velocity
4842      *                               and unknown different orientations.
4843      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
4844      *                               accelerometer and gyroscope.
4845      * @param bias                   known accelerometer bias.
4846      * @param listener               listener to handle events raised by this calibrator.
4847      * @param method                 robust estimator method.
4848      * @return a robust accelerometer calibrator.
4849      * @throws IllegalArgumentException if provided bias matrix is not 3x1 or
4850      *                                  if provided gravity norm value is negative or
4851      *                                  if provided quality scores length is smaller
4852      *                                  than 10 or 13 samples.
4853      */
4854     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
4855             final double[] qualityScores, final Acceleration groundTruthGravityNorm,
4856             final List<StandardDeviationBodyKinematics> measurements, final boolean commonAxisUsed, final Matrix bias,
4857             final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener,
4858             final RobustEstimatorMethod method) {
4859         return switch (method) {
4860             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4861                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, listener);
4862             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4863                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, listener);
4864             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4865                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, listener);
4866             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4867                     qualityScores, groundTruthGravityNorm, measurements, commonAxisUsed, bias, listener);
4868             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4869                     qualityScores, groundTruthGravityNorm, measurements, commonAxisUsed, bias, listener);
4870         };
4871     }
4872 
4873     /**
4874      * Creates a robust accelerometer calibrator.
4875      *
4876      * @param qualityScores          quality scores corresponding to each provided
4877      *                               measurement. The larger the score value the better
4878      *                               the quality of the sample.
4879      * @param groundTruthGravityNorm ground truth gravity norm.
4880      * @param measurements           collection of body kinematics measurements with standard
4881      *                               deviations taken at the same position with zero velocity
4882      *                               and unknown different orientations.
4883      * @param bias                   known accelerometer bias.
4884      * @param initialMa              initial scale factors and cross coupling errors matrix.
4885      * @param method                 robust estimator method.
4886      * @return a robust accelerometer calibrator.
4887      * @throws IllegalArgumentException if either provided bias matrix is not 3x1 or
4888      *                                  scaling and coupling error matrix is not 3x3 or
4889      *                                  if provided gravity norm value is negative or
4890      *                                  if provided quality scores length is smaller
4891      *                                  than 13 samples.
4892      */
4893     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
4894             final double[] qualityScores, final Acceleration groundTruthGravityNorm,
4895             final List<StandardDeviationBodyKinematics> measurements, final Matrix bias, final Matrix initialMa,
4896             final RobustEstimatorMethod method) {
4897         return switch (method) {
4898             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4899                     groundTruthGravityNorm, measurements, bias, initialMa);
4900             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4901                     groundTruthGravityNorm, measurements, bias, initialMa);
4902             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4903                     groundTruthGravityNorm, measurements, bias, initialMa);
4904             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4905                     qualityScores, groundTruthGravityNorm, measurements, bias, initialMa);
4906             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4907                     qualityScores, groundTruthGravityNorm, measurements, bias, initialMa);
4908         };
4909     }
4910 
4911     /**
4912      * Creates a robust accelerometer calibrator.
4913      *
4914      * @param qualityScores          quality scores corresponding to each provided
4915      *                               measurement. The larger the score value the better
4916      *                               the quality of the sample.
4917      * @param groundTruthGravityNorm ground truth gravity norm.
4918      * @param measurements           collection of body kinematics measurements with standard
4919      *                               deviations taken at the same position with zero velocity
4920      *                               and unknown different orientations.
4921      * @param bias                   known accelerometer bias.
4922      * @param initialMa              initial scale factors and cross coupling errors matrix.
4923      * @param listener               listener to handle events raised by this calibrator.
4924      * @param method                 robust estimator method.
4925      * @return a robust accelerometer calibrator.
4926      * @throws IllegalArgumentException if either provided bias matrix is not 3x1 or
4927      *                                  scaling and coupling error matrix is not 3x3 or
4928      *                                  if provided gravity norm value is negative or
4929      *                                  if provided quality scores length is smaller
4930      *                                  than 13 samples.
4931      */
4932     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
4933             final double[] qualityScores, final Acceleration groundTruthGravityNorm,
4934             final List<StandardDeviationBodyKinematics> measurements, final Matrix bias, final Matrix initialMa,
4935             final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener,
4936             final RobustEstimatorMethod method) {
4937         return switch (method) {
4938             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4939                     groundTruthGravityNorm, measurements, bias, initialMa, listener);
4940             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4941                     groundTruthGravityNorm, measurements, bias, initialMa, listener);
4942             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4943                     groundTruthGravityNorm, measurements, bias, initialMa, listener);
4944             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4945                     qualityScores, groundTruthGravityNorm, measurements, bias, initialMa, listener);
4946             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4947                     qualityScores, groundTruthGravityNorm, measurements, bias, initialMa, listener);
4948         };
4949     }
4950 
4951     /**
4952      * Creates a robust accelerometer calibrator.
4953      *
4954      * @param qualityScores          quality scores corresponding to each provided
4955      *                               measurement. The larger the score value the better
4956      *                               the quality of the sample.
4957      * @param groundTruthGravityNorm ground truth gravity norm.
4958      * @param measurements           collection of body kinematics measurements with standard
4959      *                               deviations taken at the same position with zero velocity
4960      *                               and unknown different orientations.
4961      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
4962      *                               accelerometer and gyroscope.
4963      * @param bias                   known accelerometer bias.
4964      * @param initialMa              initial scale factors and cross coupling errors matrix.
4965      * @param method                 robust estimator method.
4966      * @return a robust accelerometer calibrator.
4967      * @throws IllegalArgumentException if either provided bias matrix is not 3x1 or
4968      *                                  scaling and coupling error matrix is not 3x3 or
4969      *                                  if provided gravity norm value is negative.
4970      */
4971     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
4972             final double[] qualityScores, final Acceleration groundTruthGravityNorm,
4973             final List<StandardDeviationBodyKinematics> measurements, final boolean commonAxisUsed, final Matrix bias,
4974             final Matrix initialMa, final RobustEstimatorMethod method) {
4975         return switch (method) {
4976             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4977                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, initialMa);
4978             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4979                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, initialMa);
4980             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4981                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, initialMa);
4982             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4983                     qualityScores, groundTruthGravityNorm, measurements, commonAxisUsed, bias, initialMa);
4984             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
4985                     qualityScores, groundTruthGravityNorm, measurements, commonAxisUsed, bias, initialMa);
4986         };
4987     }
4988 
4989     /**
4990      * Creates a robust accelerometer calibrator.
4991      *
4992      * @param qualityScores          quality scores corresponding to each provided
4993      *                               measurement. The larger the score value the better
4994      *                               the quality of the sample.
4995      * @param groundTruthGravityNorm ground truth gravity norm.
4996      * @param measurements           collection of body kinematics measurements with standard
4997      *                               deviations taken at the same position with zero velocity
4998      *                               and unknown different orientations.
4999      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
5000      *                               accelerometer and gyroscope.
5001      * @param bias                   known accelerometer bias.
5002      * @param initialMa              initial scale factors and cross coupling errors matrix.
5003      * @param listener               listener to handle events raised by this calibrator.
5004      * @param method                 robust estimator method.
5005      * @return a robust accelerometer calibrator.
5006      * @throws IllegalArgumentException if either provided bias matrix is not 3x1 or
5007      *                                  scaling and coupling error matrix is not 3x3 or
5008      *                                  if provided gravity norm value is negative or
5009      *                                  if provided quality scores length is smaller
5010      *                                  than 10 or 13 samples.
5011      */
5012     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
5013             final double[] qualityScores, final Acceleration groundTruthGravityNorm,
5014             final List<StandardDeviationBodyKinematics> measurements, final boolean commonAxisUsed, final Matrix bias,
5015             final Matrix initialMa, final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener,
5016             final RobustEstimatorMethod method) {
5017         return switch (method) {
5018             case RANSAC -> new RANSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
5019                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, initialMa, listener);
5020             case LMEDS -> new LMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
5021                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, initialMa, listener);
5022             case MSAC -> new MSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
5023                     groundTruthGravityNorm, measurements, commonAxisUsed, bias, initialMa, listener);
5024             case PROSAC -> new PROSACRobustKnownBiasAndGravityNormAccelerometerCalibrator(
5025                     qualityScores, groundTruthGravityNorm, measurements, commonAxisUsed, bias, initialMa, listener);
5026             default -> new PROMedSRobustKnownBiasAndGravityNormAccelerometerCalibrator(
5027                     qualityScores, groundTruthGravityNorm, measurements, commonAxisUsed, bias, initialMa, listener);
5028         };
5029     }
5030 
5031     /**
5032      * Creates a robust accelerometer calibrator using default robust method.
5033      *
5034      * @return a robust accelerometer calibrator.
5035      */
5036     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create() {
5037         return create(DEFAULT_ROBUST_METHOD);
5038     }
5039 
5040     /**
5041      * Creates a robust accelerometer calibrator using default robust method.
5042      *
5043      * @param listener listener to be notified of events such as when estimation
5044      *                 starts, ends or its progress significantly changes.
5045      * @return a robust accelerometer calibrator.
5046      */
5047     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
5048             final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener) {
5049         return create(listener, DEFAULT_ROBUST_METHOD);
5050     }
5051 
5052     /**
5053      * Creates a robust accelerometer calibrator using default robust method.
5054      *
5055      * @param measurements collection of body kinematics measurements with standard
5056      *                     deviations taken at the same position with zero velocity
5057      *                     and unknown different orientations.
5058      * @return a robust accelerometer calibrator.
5059      */
5060     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
5061             final List<StandardDeviationBodyKinematics> measurements) {
5062         return create(measurements, DEFAULT_ROBUST_METHOD);
5063     }
5064 
5065 
5066     /**
5067      * Creates a robust accelerometer calibrator using default robust method.
5068      *
5069      * @param commonAxisUsed indicates whether z-axis is assumed to be common for
5070      *                       accelerometer and gyroscope.
5071      * @return a robust accelerometer calibrator.
5072      */
5073     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(final boolean commonAxisUsed) {
5074         return create(commonAxisUsed, DEFAULT_ROBUST_METHOD);
5075     }
5076 
5077     /**
5078      * Creates a robust accelerometer calibrator using default robust method.
5079      *
5080      * @param bias known accelerometer bias. This must have length 3 and is expressed
5081      *             in meters per squared second (m/s^2).
5082      * @return a robust accelerometer calibrator.
5083      * @throws IllegalArgumentException if provided bias array does not have length 3.
5084      */
5085     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(final double[] bias) {
5086         return create(bias, DEFAULT_ROBUST_METHOD);
5087     }
5088 
5089     /**
5090      * Creates a robust accelerometer calibrator using default robust method.
5091      *
5092      * @param bias known accelerometer bias.
5093      * @return a robust accelerometer calibrator.
5094      * @throws IllegalArgumentException if provided bias matrix is not 3x1.
5095      */
5096     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(final Matrix bias) {
5097         return create(bias, DEFAULT_ROBUST_METHOD);
5098     }
5099 
5100     /**
5101      * Creates a robust accelerometer calibrator using default robust method.
5102      *
5103      * @param bias      known accelerometer bias.
5104      * @param initialMa initial scale factors and cross coupling errors matrix.
5105      * @return a robust accelerometer calibrator.
5106      * @throws IllegalArgumentException if either provided bias matrix is not 3x1 or
5107      *                                  scaling and coupling error matrix is not 3x3.
5108      */
5109     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
5110             final Matrix bias, final Matrix initialMa) {
5111         return create(bias, initialMa, DEFAULT_ROBUST_METHOD);
5112     }
5113 
5114     /**
5115      * Creates a robust accelerometer calibrator using default robust method.
5116      *
5117      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
5118      *                               squared second (m/s^2).
5119      * @return a robust accelerometer calibrator.
5120      * @throws IllegalArgumentException if provided gravity norm value is negative.
5121      */
5122     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(final Double groundTruthGravityNorm) {
5123         return create(groundTruthGravityNorm, DEFAULT_ROBUST_METHOD);
5124     }
5125 
5126     /**
5127      * Creates a robust accelerometer calibrator using default robust method.
5128      *
5129      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
5130      *                               squared second (m/s^2).
5131      * @param measurements           list of body kinematics measurements taken at a given position with
5132      *                               different unknown orientations and containing the standard deviations
5133      *                               of accelerometer and gyroscope measurements.
5134      * @return a robust accelerometer calibrator.
5135      * @throws IllegalArgumentException if provided gravity norm value is negative.
5136      */
5137     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
5138             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements) {
5139         return create(groundTruthGravityNorm, measurements, DEFAULT_ROBUST_METHOD);
5140     }
5141 
5142     /**
5143      * Creates a robust accelerometer calibrator using default robust method.
5144      *
5145      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
5146      *                               squared second (m/s^2).
5147      * @param measurements           list of body kinematics measurements taken at a given position with
5148      *                               different unknown orientations and containing the standard deviations
5149      *                               of accelerometer and gyroscope measurements.
5150      * @param listener               listener to be notified of events such as when estimation
5151      *                               starts, ends or its progress significantly changes.
5152      * @return a robust accelerometer calibrator.
5153      * @throws IllegalArgumentException if provided gravity norm value is negative.
5154      */
5155     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
5156             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
5157             final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener) {
5158         return create(groundTruthGravityNorm, measurements, listener, DEFAULT_ROBUST_METHOD);
5159     }
5160 
5161     /**
5162      * Creates a robust accelerometer calibrator using default robust method.
5163      *
5164      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
5165      *                               squared second (m/s^2).
5166      * @param measurements           list of body kinematics measurements taken at a given position with
5167      *                               different unknown orientations and containing the standard deviations
5168      *                               of accelerometer and gyroscope measurements.
5169      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
5170      *                               accelerometer and gyroscope.
5171      * @return a robust accelerometer calibrator.
5172      * @throws IllegalArgumentException if provided gravity norm value is negative.
5173      */
5174     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
5175             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
5176             final boolean commonAxisUsed) {
5177         return create(groundTruthGravityNorm, measurements, commonAxisUsed, DEFAULT_ROBUST_METHOD);
5178     }
5179 
5180     /**
5181      * Creates a robust accelerometer calibrator using default robust method.
5182      *
5183      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
5184      *                               squared second (m/s^2).
5185      * @param measurements           list of body kinematics measurements taken at a given position with
5186      *                               different unknown orientations and containing the standard deviations
5187      *                               of accelerometer and gyroscope measurements.
5188      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
5189      *                               accelerometer and gyroscope.
5190      * @param listener               listener to be notified of events such as when estimation
5191      *                               starts, ends or its progress significantly changes.
5192      * @return a robust accelerometer calibrator.
5193      * @throws IllegalArgumentException if provided gravity norm value is negative.
5194      */
5195     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
5196             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
5197             final boolean commonAxisUsed, final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener) {
5198         return create(groundTruthGravityNorm, measurements, commonAxisUsed, listener, DEFAULT_ROBUST_METHOD);
5199     }
5200 
5201     /**
5202      * Creates a robust accelerometer calibrator using default robust method.
5203      *
5204      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
5205      *                               squared second (m/s^2).
5206      * @param measurements           collection of body kinematics measurements with standard
5207      *                               deviations taken at the same position with zero velocity
5208      *                               and unknown different orientations.
5209      * @param bias                   known accelerometer bias. This must have length 3 and is expressed
5210      *                               in meters per squared second (m/s^2).
5211      * @return a robust accelerometer calibrator.
5212      * @throws IllegalArgumentException if provided bias array does not have length 3 or
5213      *                                  if provided gravity norm value is negative.
5214      */
5215     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
5216             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
5217             final double[] bias) {
5218         return create(groundTruthGravityNorm, measurements, bias, DEFAULT_ROBUST_METHOD);
5219     }
5220 
5221     /**
5222      * Creates a robust accelerometer calibrator using default robust method.
5223      *
5224      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
5225      *                               squared second (m/s^2).
5226      * @param measurements           collection of body kinematics measurements with standard
5227      *                               deviations taken at the same position with zero velocity
5228      *                               and unknown different orientations.
5229      * @param bias                   known accelerometer bias. This must have length 3 and is expressed
5230      *                               in meters per squared second (m/s^2).
5231      * @param listener               listener to handle events raised by this calibrator.
5232      * @return a robust accelerometer calibrator.
5233      * @throws IllegalArgumentException if provided bias array does not have length 3 or
5234      *                                  if provided gravity norm value is negative.
5235      */
5236     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
5237             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
5238             final double[] bias, final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener) {
5239         return create(groundTruthGravityNorm, measurements, bias, listener, DEFAULT_ROBUST_METHOD);
5240     }
5241 
5242     /**
5243      * Creates a robust accelerometer calibrator using default robust method.
5244      *
5245      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
5246      *                               squared second (m/s^2).
5247      * @param measurements           collection of body kinematics measurements with standard
5248      *                               deviations taken at the same position with zero velocity
5249      *                               and unknown different orientations.
5250      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
5251      *                               accelerometer and gyroscope.
5252      * @param bias                   known accelerometer bias. This must have length 3 and is expressed
5253      *                               in meters per squared second (m/s^2).
5254      * @return a robust accelerometer calibrator.
5255      * @throws IllegalArgumentException if provided bias array does not have length 3 or
5256      *                                  if provided gravity norm value is negative.
5257      */
5258     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
5259             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
5260             final boolean commonAxisUsed, final double[] bias) {
5261         return create(groundTruthGravityNorm, measurements, commonAxisUsed, bias, DEFAULT_ROBUST_METHOD);
5262     }
5263 
5264     /**
5265      * Creates a robust accelerometer calibrator using default robust method.
5266      *
5267      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
5268      *                               squared second (m/s^2).
5269      * @param measurements           collection of body kinematics measurements with standard
5270      *                               deviations taken at the same position with zero velocity
5271      *                               and unknown different orientations.
5272      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
5273      *                               accelerometer and gyroscope.
5274      * @param bias                   known accelerometer bias. This must have length 3 and is expressed
5275      *                               in meters per squared second (m/s^2).
5276      * @param listener               listener to handle events raised by this calibrator.
5277      * @return a robust accelerometer calibrator.
5278      * @throws IllegalArgumentException if provided bias array does not have length 3 or
5279      *                                  if provided gravity norm value is negative.
5280      */
5281     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
5282             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
5283             final boolean commonAxisUsed, final double[] bias,
5284             final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener) {
5285         return create(groundTruthGravityNorm, measurements, commonAxisUsed, bias, listener, DEFAULT_ROBUST_METHOD);
5286     }
5287 
5288     /**
5289      * Creates a robust accelerometer calibrator using default robust method.
5290      *
5291      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
5292      *                               squared second (m/s^2).
5293      * @param measurements           collection of body kinematics measurements with standard
5294      *                               deviations taken at the same position with zero velocity
5295      *                               and unknown different orientations.
5296      * @param bias                   known accelerometer bias.
5297      * @return a robust accelerometer calibrator.
5298      * @throws IllegalArgumentException if provided bias matrix is not 3x1 or
5299      *                                  if provided gravity norm value is negative.
5300      */
5301     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
5302             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
5303             final Matrix bias) {
5304         return create(groundTruthGravityNorm, measurements, bias, DEFAULT_ROBUST_METHOD);
5305     }
5306 
5307     /**
5308      * Creates a robust accelerometer calibrator using default robust method.
5309      *
5310      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
5311      *                               squared second (m/s^2).
5312      * @param measurements           collection of body kinematics measurements with standard
5313      *                               deviations taken at the same position with zero velocity
5314      *                               and unknown different orientations.
5315      * @param bias                   known accelerometer bias.
5316      * @param listener               listener to handle events raised by this calibrator.
5317      * @return a robust accelerometer calibrator.
5318      * @throws IllegalArgumentException if provided bias matrix is not 3x1 or
5319      *                                  if provided gravity norm value is negative.
5320      */
5321     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
5322             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
5323             final Matrix bias, final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener) {
5324         return create(groundTruthGravityNorm, measurements, bias, listener, DEFAULT_ROBUST_METHOD);
5325     }
5326 
5327     /**
5328      * Creates a robust accelerometer calibrator using default robust method.
5329      *
5330      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
5331      *                               squared second (m/s^2).
5332      * @param measurements           collection of body kinematics measurements with standard
5333      *                               deviations taken at the same position with zero velocity
5334      *                               and unknown different orientations.
5335      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
5336      *                               accelerometer and gyroscope.
5337      * @param bias                   known accelerometer bias.
5338      * @return a robust accelerometer calibrator.
5339      * @throws IllegalArgumentException if provided bias matrix is not 3x1 or
5340      *                                  if provided gravity norm value is negative.
5341      */
5342     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
5343             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
5344             final boolean commonAxisUsed, final Matrix bias) {
5345         return create(groundTruthGravityNorm, measurements, commonAxisUsed, bias, DEFAULT_ROBUST_METHOD);
5346     }
5347 
5348     /**
5349      * Creates a robust accelerometer calibrator using default robust method.
5350      *
5351      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
5352      *                               squared second (m/s^2).
5353      * @param measurements           collection of body kinematics measurements with standard
5354      *                               deviations taken at the same position with zero velocity
5355      *                               and unknown different orientations.
5356      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
5357      *                               accelerometer and gyroscope.
5358      * @param bias                   known accelerometer bias.
5359      * @param listener               listener to handle events raised by this calibrator.
5360      * @return a robust accelerometer calibrator.
5361      * @throws IllegalArgumentException if provided bias matrix is not 3x1 or
5362      *                                  if provided gravity norm value is negative.
5363      */
5364     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
5365             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
5366             final boolean commonAxisUsed, final Matrix bias,
5367             final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener) {
5368         return create(groundTruthGravityNorm, measurements, commonAxisUsed, bias, listener, DEFAULT_ROBUST_METHOD);
5369     }
5370 
5371     /**
5372      * Creates a robust accelerometer calibrator using default robust method.
5373      *
5374      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
5375      *                               squared second (m/s^2).
5376      * @param measurements           collection of body kinematics measurements with standard
5377      *                               deviations taken at the same position with zero velocity
5378      *                               and unknown different orientations.
5379      * @param bias                   known accelerometer bias.
5380      * @param initialMa              initial scale factors and cross coupling errors matrix.
5381      * @return a robust accelerometer calibrator.
5382      * @throws IllegalArgumentException if either provided bias matrix is not 3x1 or
5383      *                                  scaling and coupling error matrix is not 3x3 or
5384      *                                  if provided gravity norm value is negative.
5385      */
5386     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
5387             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
5388             final Matrix bias, final Matrix initialMa) {
5389         return create(groundTruthGravityNorm, measurements, bias, initialMa, DEFAULT_ROBUST_METHOD);
5390     }
5391 
5392     /**
5393      * Creates a robust accelerometer calibrator using default robust method.
5394      *
5395      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
5396      *                               squared second (m/s^2).
5397      * @param measurements           collection of body kinematics measurements with standard
5398      *                               deviations taken at the same position with zero velocity
5399      *                               and unknown different orientations.
5400      * @param bias                   known accelerometer bias.
5401      * @param initialMa              initial scale factors and cross coupling errors matrix.
5402      * @param listener               listener to handle events raised by this calibrator.
5403      * @return a robust accelerometer calibrator.
5404      * @throws IllegalArgumentException if either provided bias matrix is not 3x1 or
5405      *                                  scaling and coupling error matrix is not 3x3 or
5406      *                                  if provided gravity norm value is negative.
5407      */
5408     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
5409             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
5410             final Matrix bias, final Matrix initialMa,
5411             final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener) {
5412         return create(groundTruthGravityNorm, measurements, bias, initialMa, listener, DEFAULT_ROBUST_METHOD);
5413     }
5414 
5415     /**
5416      * Creates a robust accelerometer calibrator using default robust method.
5417      *
5418      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
5419      *                               squared second (m/s^2).
5420      * @param measurements           collection of body kinematics measurements with standard
5421      *                               deviations taken at the same position with zero velocity
5422      *                               and unknown different orientations.
5423      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
5424      *                               accelerometer and gyroscope.
5425      * @param bias                   known accelerometer bias.
5426      * @param initialMa              initial scale factors and cross coupling errors matrix.
5427      * @return a robust accelerometer calibrator.
5428      * @throws IllegalArgumentException if either provided bias matrix is not 3x1 or
5429      *                                  scaling and coupling error matrix is not 3x3 or
5430      *                                  if provided gravity norm value is negative.
5431      */
5432     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
5433             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
5434             final boolean commonAxisUsed, final Matrix bias, final Matrix initialMa) {
5435         return create(groundTruthGravityNorm, measurements, commonAxisUsed, bias, initialMa, DEFAULT_ROBUST_METHOD);
5436     }
5437 
5438     /**
5439      * Creates a robust accelerometer calibrator using default robust method.
5440      *
5441      * @param groundTruthGravityNorm ground truth gravity norm expressed in meters per
5442      *                               squared second (m/s^2).
5443      * @param measurements           collection of body kinematics measurements with standard
5444      *                               deviations taken at the same position with zero velocity
5445      *                               and unknown different orientations.
5446      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
5447      *                               accelerometer and gyroscope.
5448      * @param bias                   known accelerometer bias.
5449      * @param initialMa              initial scale factors and cross coupling errors matrix.
5450      * @param listener               listener to handle events raised by this calibrator.
5451      * @return a robust accelerometer calibrator.
5452      * @throws IllegalArgumentException if either provided bias matrix is not 3x1 or
5453      *                                  scaling and coupling error matrix is not 3x3 or
5454      *                                  if provided gravity norm value is negative.
5455      */
5456     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
5457             final Double groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
5458             final boolean commonAxisUsed, final Matrix bias, final Matrix initialMa,
5459             final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener) {
5460         return create(groundTruthGravityNorm, measurements, commonAxisUsed, bias, initialMa, listener,
5461                 DEFAULT_ROBUST_METHOD);
5462     }
5463 
5464     /**
5465      * Creates a robust accelerometer calibrator using default robust method.
5466      *
5467      * @param groundTruthGravityNorm ground truth gravity norm.
5468      * @return a robust accelerometer calibrator.
5469      * @throws IllegalArgumentException if provided gravity norm value is negative.
5470      */
5471     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
5472             final Acceleration groundTruthGravityNorm) {
5473         return create(groundTruthGravityNorm, DEFAULT_ROBUST_METHOD);
5474     }
5475 
5476     /**
5477      * Creates a robust accelerometer calibrator using default robust method.
5478      *
5479      * @param groundTruthGravityNorm ground truth gravity norm.
5480      * @param measurements           list of body kinematics measurements taken at a given position with
5481      *                               different unknown orientations and containing the standard deviations
5482      *                               of accelerometer and gyroscope measurements.
5483      * @return a robust accelerometer calibrator.
5484      * @throws IllegalArgumentException if provided gravity norm value is negative.
5485      */
5486     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
5487             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements) {
5488         return create(groundTruthGravityNorm, measurements, DEFAULT_ROBUST_METHOD);
5489     }
5490 
5491     /**
5492      * Creates a robust accelerometer calibrator using default robust method.
5493      *
5494      * @param groundTruthGravityNorm ground truth gravity norm.
5495      * @param measurements           list of body kinematics measurements taken at a given position with
5496      *                               different unknown orientations and containing the standard deviations
5497      *                               of accelerometer and gyroscope measurements.
5498      * @param listener               listener to be notified of events such as when estimation
5499      *                               starts, ends or its progress significantly changes.
5500      * @return a robust accelerometer calibrator.
5501      * @throws IllegalArgumentException if provided gravity norm value is negative.
5502      */
5503     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
5504             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
5505             final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener) {
5506         return create(groundTruthGravityNorm, measurements, listener, DEFAULT_ROBUST_METHOD);
5507     }
5508 
5509     /**
5510      * Creates a robust accelerometer calibrator using default robust method.
5511      *
5512      * @param groundTruthGravityNorm ground truth gravity norm.
5513      * @param measurements           list of body kinematics measurements taken at a given position with
5514      *                               different unknown orientations and containing the standard deviations
5515      *                               of accelerometer and gyroscope measurements.
5516      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
5517      *                               accelerometer and gyroscope.
5518      * @return a robust accelerometer calibrator.
5519      * @throws IllegalArgumentException if provided gravity norm value is negative.
5520      */
5521     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
5522             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
5523             final boolean commonAxisUsed) {
5524         return create(groundTruthGravityNorm, measurements, commonAxisUsed, DEFAULT_ROBUST_METHOD);
5525     }
5526 
5527     /**
5528      * Creates a robust accelerometer calibrator using default robust method.
5529      *
5530      * @param groundTruthGravityNorm ground truth gravity norm.
5531      * @param measurements           list of body kinematics measurements taken at a given position with
5532      *                               different unknown orientations and containing the standard deviations
5533      *                               of accelerometer and gyroscope measurements.
5534      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
5535      *                               accelerometer and gyroscope.
5536      * @param listener               listener to be notified of events such as when estimation
5537      *                               starts, ends or its progress significantly changes.
5538      * @return a robust accelerometer calibrator.
5539      * @throws IllegalArgumentException if provided gravity norm value is negative.
5540      */
5541     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
5542             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
5543             final boolean commonAxisUsed, final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener) {
5544         return create(groundTruthGravityNorm, measurements, commonAxisUsed, listener, DEFAULT_ROBUST_METHOD);
5545     }
5546 
5547     /**
5548      * Creates a robust accelerometer calibrator using default robust method.
5549      *
5550      * @param groundTruthGravityNorm ground truth gravity norm.
5551      * @param measurements           collection of body kinematics measurements with standard
5552      *                               deviations taken at the same position with zero velocity
5553      *                               and unknown different orientations.
5554      * @param bias                   known accelerometer bias. This must have length 3 and is expressed
5555      *                               in meters per squared second (m/s^2).
5556      * @return a robust accelerometer calibrator.
5557      * @throws IllegalArgumentException if provided bias array does not have length 3 or
5558      *                                  if provided gravity norm value is negative.
5559      */
5560     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
5561             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
5562             final double[] bias) {
5563         return create(groundTruthGravityNorm, measurements, bias, DEFAULT_ROBUST_METHOD);
5564     }
5565 
5566     /**
5567      * Creates a robust accelerometer calibrator using default robust method.
5568      *
5569      * @param groundTruthGravityNorm ground truth gravity norm.
5570      * @param measurements           collection of body kinematics measurements with standard
5571      *                               deviations taken at the same position with zero velocity
5572      *                               and unknown different orientations.
5573      * @param bias                   known accelerometer bias. This must have length 3 and is expressed
5574      *                               in meters per squared second (m/s^2).
5575      * @param listener               listener to handle events raised by this calibrator.
5576      * @return a robust accelerometer calibrator.
5577      * @throws IllegalArgumentException if provided bias array does not have length 3 or
5578      *                                  if provided gravity norm value is negative.
5579      */
5580     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
5581             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
5582             final double[] bias, final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener) {
5583         return create(groundTruthGravityNorm, measurements, bias, listener, DEFAULT_ROBUST_METHOD);
5584     }
5585 
5586     /**
5587      * Creates a robust accelerometer calibrator using default robust method.
5588      *
5589      * @param groundTruthGravityNorm ground truth gravity norm.
5590      * @param measurements           collection of body kinematics measurements with standard
5591      *                               deviations taken at the same position with zero velocity
5592      *                               and unknown different orientations.
5593      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
5594      *                               accelerometer and gyroscope.
5595      * @param initialBias            initial accelerometer bias to be used to find a solution.
5596      *                               This must have length 3 and is expressed in meters per
5597      *                               squared second (m/s^2).
5598      * @return a robust accelerometer calibrator.
5599      * @throws IllegalArgumentException if provided bias array does not have length 3 or
5600      *                                  if provided gravity norm value is negative.
5601      */
5602     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
5603             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
5604             final boolean commonAxisUsed, final double[] initialBias) {
5605         return create(groundTruthGravityNorm, measurements, commonAxisUsed, initialBias, DEFAULT_ROBUST_METHOD);
5606     }
5607 
5608     /**
5609      * Creates a robust accelerometer calibrator using default robust method.
5610      *
5611      * @param groundTruthGravityNorm ground truth gravity norm.
5612      * @param measurements           collection of body kinematics measurements with standard
5613      *                               deviations taken at the same position with zero velocity
5614      *                               and unknown different orientations.
5615      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
5616      *                               accelerometer and gyroscope.
5617      * @param bias                   known accelerometer bias. This must have length 3 and is expressed
5618      *                               in meters per squared second (m/s^2).
5619      * @param listener               listener to handle events raised by this calibrator.
5620      * @return a robust accelerometer calibrator.
5621      * @throws IllegalArgumentException if provided bias array does not have length 3 or
5622      *                                  if provided gravity norm value is negative.
5623      */
5624     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
5625             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
5626             final boolean commonAxisUsed, final double[] bias,
5627             final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener) {
5628         return create(groundTruthGravityNorm, measurements, commonAxisUsed, bias, listener, DEFAULT_ROBUST_METHOD);
5629     }
5630 
5631     /**
5632      * Creates a robust accelerometer calibrator using default robust method.
5633      *
5634      * @param groundTruthGravityNorm ground truth gravity norm.
5635      * @param measurements           collection of body kinematics measurements with standard
5636      *                               deviations taken at the same position with zero velocity
5637      *                               and unknown different orientations.
5638      * @param bias                   known accelerometer bias.
5639      * @return a robust accelerometer calibrator.
5640      * @throws IllegalArgumentException if provided bias matrix is not 3x1 or
5641      *                                  if provided gravity norm value is negative.
5642      */
5643     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
5644             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
5645             final Matrix bias) {
5646         return create(groundTruthGravityNorm, measurements, bias, DEFAULT_ROBUST_METHOD);
5647     }
5648 
5649     /**
5650      * Creates a robust accelerometer calibrator using default robust method.
5651      *
5652      * @param groundTruthGravityNorm ground truth gravity norm.
5653      * @param measurements           collection of body kinematics measurements with standard
5654      *                               deviations taken at the same position with zero velocity
5655      *                               and unknown different orientations.
5656      * @param bias                   known accelerometer bias.
5657      * @param listener               listener to handle events raised by this calibrator.
5658      * @return a robust accelerometer calibrator.
5659      * @throws IllegalArgumentException if provided bias matrix is not 3x1 or
5660      *                                  if provided gravity norm value is negative.
5661      */
5662     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
5663             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
5664             final Matrix bias, final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener) {
5665         return create(groundTruthGravityNorm, measurements, bias, listener, DEFAULT_ROBUST_METHOD);
5666     }
5667 
5668     /**
5669      * Creates a robust accelerometer calibrator using default robust method.
5670      *
5671      * @param groundTruthGravityNorm ground truth gravity norm.
5672      * @param measurements           collection of body kinematics measurements with standard
5673      *                               deviations taken at the same position with zero velocity
5674      *                               and unknown different orientations.
5675      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
5676      *                               accelerometer and gyroscope.
5677      * @param bias                   known accelerometer bias.
5678      * @return a robust accelerometer calibrator.
5679      * @throws IllegalArgumentException if provided bias matrix is not 3x1 or
5680      *                                  if provided gravity norm value is negative.
5681      */
5682     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
5683             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
5684             final boolean commonAxisUsed, final Matrix bias) {
5685         return create(groundTruthGravityNorm, measurements, commonAxisUsed, bias, DEFAULT_ROBUST_METHOD);
5686     }
5687 
5688     /**
5689      * Creates a robust accelerometer calibrator using default robust method.
5690      *
5691      * @param groundTruthGravityNorm ground truth gravity norm.
5692      * @param measurements           collection of body kinematics measurements with standard
5693      *                               deviations taken at the same position with zero velocity
5694      *                               and unknown different orientations.
5695      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
5696      *                               accelerometer and gyroscope.
5697      * @param bias                   known accelerometer bias.
5698      * @param listener               listener to handle events raised by this calibrator.
5699      * @return a robust accelerometer calibrator.
5700      * @throws IllegalArgumentException if provided bias matrix is not 3x1 or
5701      *                                  if provided gravity norm value is negative.
5702      */
5703     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
5704             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
5705             final boolean commonAxisUsed, final Matrix bias,
5706             final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener) {
5707         return create(groundTruthGravityNorm, measurements, commonAxisUsed, bias, listener, DEFAULT_ROBUST_METHOD);
5708     }
5709 
5710     /**
5711      * Creates a robust accelerometer calibrator using default robust method.
5712      *
5713      * @param groundTruthGravityNorm ground truth gravity norm.
5714      * @param measurements           collection of body kinematics measurements with standard
5715      *                               deviations taken at the same position with zero velocity
5716      *                               and unknown different orientations.
5717      * @param bias                   known accelerometer bias.
5718      * @param initialMa              initial scale factors and cross coupling errors matrix.
5719      * @return a robust accelerometer calibrator.
5720      * @throws IllegalArgumentException if either provided bias matrix is not 3x1 or
5721      *                                  scaling and coupling error matrix is not 3x3 or
5722      *                                  if provided gravity norm value is negative.
5723      */
5724     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
5725             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
5726             final Matrix bias, final Matrix initialMa) {
5727         return create(groundTruthGravityNorm, measurements, bias, initialMa, DEFAULT_ROBUST_METHOD);
5728     }
5729 
5730     /**
5731      * Creates a robust accelerometer calibrator using default robust method.
5732      *
5733      * @param groundTruthGravityNorm ground truth gravity norm.
5734      * @param measurements           collection of body kinematics measurements with standard
5735      *                               deviations taken at the same position with zero velocity
5736      *                               and unknown different orientations.
5737      * @param bias                   known accelerometer bias.
5738      * @param initialMa              initial scale factors and cross coupling errors matrix.
5739      * @param listener               listener to handle events raised by this calibrator.
5740      * @return a robust accelerometer calibrator.
5741      * @throws IllegalArgumentException if either provided bias matrix is not 3x1 or
5742      *                                  scaling and coupling error matrix is not 3x3 or
5743      *                                  if provided gravity norm value is negative.
5744      */
5745     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
5746             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
5747             final Matrix bias, final Matrix initialMa,
5748             final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener) {
5749         return create(groundTruthGravityNorm, measurements, bias, initialMa, listener, DEFAULT_ROBUST_METHOD);
5750     }
5751 
5752     /**
5753      * Creates a robust accelerometer calibrator using default robust method.
5754      *
5755      * @param groundTruthGravityNorm ground truth gravity norm.
5756      * @param measurements           collection of body kinematics measurements with standard
5757      *                               deviations taken at the same position with zero velocity
5758      *                               and unknown different orientations.
5759      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
5760      *                               accelerometer and gyroscope.
5761      * @param bias                   known accelerometer bias.
5762      * @param initialMa              initial scale factors and cross coupling errors matrix.
5763      * @return a robust accelerometer calibrator.
5764      * @throws IllegalArgumentException if either provided bias matrix is not 3x1 or
5765      *                                  scaling and coupling error matrix is not 3x3 or
5766      *                                  if provided gravity norm value is negative.
5767      */
5768     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
5769             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
5770             final boolean commonAxisUsed, final Matrix bias, final Matrix initialMa) {
5771         return create(groundTruthGravityNorm, measurements, commonAxisUsed, bias, initialMa, DEFAULT_ROBUST_METHOD);
5772     }
5773 
5774     /**
5775      * Creates a robust accelerometer calibrator using default robust method.
5776      *
5777      * @param groundTruthGravityNorm ground truth gravity norm.
5778      * @param measurements           collection of body kinematics measurements with standard
5779      *                               deviations taken at the same position with zero velocity
5780      *                               and unknown different orientations.
5781      * @param commonAxisUsed         indicates whether z-axis is assumed to be common for
5782      *                               accelerometer and gyroscope.
5783      * @param bias                   known accelerometer bias.
5784      * @param initialMa              initial scale factors and cross coupling errors matrix.
5785      * @param listener               listener to handle events raised by this calibrator.
5786      * @return a robust accelerometer calibrator.
5787      * @throws IllegalArgumentException if either provided bias matrix is not 3x1 or
5788      *                                  scaling and coupling error matrix is not 3x3 or
5789      *                                  if provided gravity norm value is negative.
5790      */
5791     public static RobustKnownBiasAndGravityNormAccelerometerCalibrator create(
5792             final Acceleration groundTruthGravityNorm, final List<StandardDeviationBodyKinematics> measurements,
5793             final boolean commonAxisUsed, final Matrix bias, final Matrix initialMa,
5794             final RobustKnownBiasAndGravityNormAccelerometerCalibratorListener listener) {
5795         return create(groundTruthGravityNorm, measurements, commonAxisUsed, bias, initialMa, listener,
5796                 DEFAULT_ROBUST_METHOD);
5797     }
5798 
5799     /**
5800      * Computes error of preliminary result respect a given measurement for current gravity norm.
5801      *
5802      * @param measurement       a measurement.
5803      * @param preliminaryResult a preliminary result.
5804      * @return computed error.
5805      */
5806     protected double computeError(
5807             final StandardDeviationBodyKinematics measurement, final PreliminaryResult preliminaryResult) {
5808 
5809         try {
5810             // We know that measured specific force is:
5811             // fmeas = ba + (I + Ma) * ftrue
5812 
5813             // fmeas - ba = (I + Ma) * ftrue
5814 
5815             // ftrue = (I + Ma)^-1 * (fmeas - ba)
5816 
5817             // We know that ||ftrue|| should be equal to the gravity value at current Earth
5818             // position
5819             // ||ftrue|| = g ~ 9.81 m/s^2
5820 
5821             final var estMa = preliminaryResult.estimatedMa;
5822 
5823             if (identity == null) {
5824                 identity = Matrix.identity(BodyKinematics.COMPONENTS, BodyKinematics.COMPONENTS);
5825             }
5826 
5827             if (tmp1 == null) {
5828                 tmp1 = new Matrix(BodyKinematics.COMPONENTS, BodyKinematics.COMPONENTS);
5829             }
5830 
5831             if (tmp2 == null) {
5832                 tmp2 = new Matrix(BodyKinematics.COMPONENTS, BodyKinematics.COMPONENTS);
5833             }
5834 
5835             if (tmp3 == null) {
5836                 tmp3 = new Matrix(BodyKinematics.COMPONENTS, 1);
5837             }
5838 
5839             if (tmp4 == null) {
5840                 tmp4 = new Matrix(BodyKinematics.COMPONENTS, 1);
5841             }
5842 
5843             identity.add(estMa, tmp1);
5844 
5845             Utils.inverse(tmp1, tmp2);
5846 
5847             final var kinematics = measurement.getKinematics();
5848             final var fmeasX = kinematics.getFx();
5849             final var fmeasY = kinematics.getFy();
5850             final var fmeasZ = kinematics.getFz();
5851 
5852             tmp3.setElementAtIndex(0, fmeasX - biasX);
5853             tmp3.setElementAtIndex(1, fmeasY - biasY);
5854             tmp3.setElementAtIndex(2, fmeasZ - biasZ);
5855 
5856             tmp2.multiply(tmp3, tmp4);
5857 
5858             final var norm = Utils.normF(tmp4);
5859             final var diff = groundTruthGravityNorm - norm;
5860 
5861             return diff * diff;
5862 
5863         } catch (final AlgebraException e) {
5864             return Double.MAX_VALUE;
5865         }
5866     }
5867 
5868     /**
5869      * Computes a preliminary solution for a subset of samples picked by a robust estimator.
5870      *
5871      * @param samplesIndices indices of samples picked by the robust estimator.
5872      * @param solutions      list where estimated preliminary solution will be stored.
5873      */
5874     protected void computePreliminarySolutions(final int[] samplesIndices, final List<PreliminaryResult> solutions) {
5875 
5876         final var meas = new ArrayList<StandardDeviationBodyKinematics>();
5877 
5878         for (final var samplesIndex : samplesIndices) {
5879             meas.add(measurements.get(samplesIndex));
5880         }
5881 
5882         try {
5883             final var result = new PreliminaryResult();
5884             result.estimatedMa = getInitialMa();
5885 
5886             innerCalibrator.setBiasCoordinates(biasX, biasY, biasZ);
5887             innerCalibrator.setInitialMa(result.estimatedMa);
5888             innerCalibrator.setCommonAxisUsed(commonAxisUsed);
5889             innerCalibrator.setGroundTruthGravityNorm(groundTruthGravityNorm);
5890             innerCalibrator.setMeasurements(meas);
5891             innerCalibrator.calibrate();
5892 
5893             result.estimatedMa = innerCalibrator.getEstimatedMa();
5894 
5895             if (keepCovariance) {
5896                 result.covariance = innerCalibrator.getEstimatedCovariance();
5897             } else {
5898                 result.covariance = null;
5899             }
5900 
5901             result.estimatedMse = innerCalibrator.getEstimatedMse();
5902             result.estimatedChiSq = innerCalibrator.getEstimatedChiSq();
5903             result.estimatedChiSqDegreesOfFreedom = innerCalibrator.getEstimatedChiSqDegreesOfFreedom();
5904             result.estimatedReducedChiSq = innerCalibrator.getEstimatedReducedChiSq();
5905             result.estimatedP = innerCalibrator.getEstimatedP();
5906             result.estimatedQ = innerCalibrator.getEstimatedQ();
5907 
5908             solutions.add(result);
5909 
5910         } catch (final LockedException | CalibrationException | NotReadyException e) {
5911             solutions.clear();
5912         }
5913     }
5914 
5915     /**
5916      * Attempts to refine calibration parameters if refinement is requested.
5917      * This method returns a refined solution or provided input if refinement is not
5918      * requested or has failed.
5919      * If refinement is enabled and it is requested to keep covariance, this method
5920      * will also keep covariance of refined position.
5921      *
5922      * @param preliminaryResult a preliminary result.
5923      */
5924     protected void attemptRefine(final PreliminaryResult preliminaryResult) {
5925         if (refineResult && inliersData != null) {
5926             final var inliers = inliersData.getInliers();
5927             final var nSamples = measurements.size();
5928 
5929             final var inlierMeasurements = new ArrayList<StandardDeviationBodyKinematics>();
5930             for (var i = 0; i < nSamples; i++) {
5931                 if (inliers.get(i)) {
5932                     // sample is inlier
5933                     inlierMeasurements.add(measurements.get(i));
5934                 }
5935             }
5936 
5937             try {
5938                 innerCalibrator.setBiasCoordinates(biasX, biasY, biasZ);
5939                 innerCalibrator.setInitialMa(preliminaryResult.estimatedMa);
5940                 innerCalibrator.setCommonAxisUsed(commonAxisUsed);
5941                 innerCalibrator.setGroundTruthGravityNorm(groundTruthGravityNorm);
5942                 innerCalibrator.setMeasurements(inlierMeasurements);
5943                 innerCalibrator.calibrate();
5944 
5945                 estimatedMa = innerCalibrator.getEstimatedMa();
5946                 estimatedMse = innerCalibrator.getEstimatedMse();
5947                 estimatedChiSq = innerCalibrator.getEstimatedChiSq();
5948                 estimatedChiSqDegreesOfFreedom = innerCalibrator.getEstimatedChiSqDegreesOfFreedom();
5949                 estimatedReducedChiSq = innerCalibrator.getEstimatedReducedChiSq();
5950                 estimatedP = innerCalibrator.getEstimatedP();
5951                 estimatedQ = innerCalibrator.getEstimatedQ();
5952 
5953                 if (keepCovariance) {
5954                     estimatedCovariance = innerCalibrator.getEstimatedCovariance();
5955                 } else {
5956                     estimatedCovariance = null;
5957                 }
5958             } catch (final LockedException | CalibrationException | NotReadyException e) {
5959                 estimatedCovariance = preliminaryResult.covariance;
5960                 estimatedMa = preliminaryResult.estimatedMa;
5961                 estimatedMse = preliminaryResult.estimatedMse;
5962                 estimatedChiSq = preliminaryResult.estimatedChiSq;
5963                 estimatedChiSqDegreesOfFreedom = preliminaryResult.estimatedChiSqDegreesOfFreedom;
5964                 estimatedReducedChiSq = preliminaryResult.estimatedReducedChiSq;
5965                 estimatedP = preliminaryResult.estimatedP;
5966                 estimatedQ = preliminaryResult.estimatedQ;
5967             }
5968         } else {
5969             estimatedCovariance = preliminaryResult.covariance;
5970             estimatedMa = preliminaryResult.estimatedMa;
5971             estimatedMse = preliminaryResult.estimatedMse;
5972             estimatedChiSq = preliminaryResult.estimatedChiSq;
5973             estimatedChiSqDegreesOfFreedom = preliminaryResult.estimatedChiSqDegreesOfFreedom;
5974             estimatedReducedChiSq = preliminaryResult.estimatedReducedChiSq;
5975             estimatedP = preliminaryResult.estimatedP;
5976             estimatedQ = preliminaryResult.estimatedQ;
5977         }
5978     }
5979 
5980     /**
5981      * Internally sets ground truth gravity norm to be expected at location where
5982      * measurements have been made, expressed in meters per squared second
5983      * (m/s^2).
5984      *
5985      * @param groundTruthGravityNorm ground truth gravity norm or null if
5986      *                               undefined.
5987      * @throws IllegalArgumentException if provided value is negative.
5988      */
5989     private void internalSetGroundTruthGravityNorm(final Double groundTruthGravityNorm) {
5990         if (groundTruthGravityNorm != null && groundTruthGravityNorm < 0.0) {
5991             throw new IllegalArgumentException();
5992         }
5993         this.groundTruthGravityNorm = groundTruthGravityNorm;
5994     }
5995 
5996     /**
5997      * Converts acceleration value and unit to meters per squared second.
5998      *
5999      * @param value acceleration value.
6000      * @param unit  unit of acceleration value.
6001      * @return converted value.
6002      */
6003     private static double convertAcceleration(final double value, final AccelerationUnit unit) {
6004         return AccelerationConverter.convert(value, unit, AccelerationUnit.METERS_PER_SQUARED_SECOND);
6005     }
6006 
6007     /**
6008      * Converts acceleration instance to meters per squared second.
6009      *
6010      * @param acceleration acceleration instance to be converted.
6011      * @return converted value.
6012      */
6013     private static double convertAcceleration(final Acceleration acceleration) {
6014         return convertAcceleration(acceleration.getValue().doubleValue(), acceleration.getUnit());
6015     }
6016 
6017     /**
6018      * Internal class containing estimated preliminary result.
6019      */
6020     protected static class PreliminaryResult {
6021         /**
6022          * Estimated accelerometer scale factors and cross coupling errors.
6023          * This is the product of matrix Ta containing cross coupling errors and Ka
6024          * containing scaling factors.
6025          * So tat:
6026          * <pre>
6027          *     Ma = [sx    mxy  mxz] = Ta*Ka
6028          *          [myx   sy   myz]
6029          *          [mzx   mzy  sz ]
6030          * </pre>
6031          * Where:
6032          * <pre>
6033          *     Ka = [sx 0   0 ]
6034          *          [0  sy  0 ]
6035          *          [0  0   sz]
6036          * </pre>
6037          * and
6038          * <pre>
6039          *     Ta = [1          -alphaXy    alphaXz ]
6040          *          [alphaYx    1           -alphaYz]
6041          *          [-alphaZx   alphaZy     1       ]
6042          * </pre>
6043          * Hence:
6044          * <pre>
6045          *     Ma = [sx    mxy  mxz] = Ta*Ka =  [sx             -sy * alphaXy   sz * alphaXz ]
6046          *          [myx   sy   myz]            [sx * alphaYx   sy              -sz * alphaYz]
6047          *          [mzx   mzy  sz ]            [-sx * alphaZx  sy * alphaZy    sz           ]
6048          * </pre>
6049          * This instance allows any 3x3 matrix however, typically alphaYx, alphaZx and alphaZy
6050          * are considered to be zero if the accelerometer z-axis is assumed to be the same
6051          * as the body z-axis. When this is assumed, myx = mzx = mzy = 0 and the Ma matrix
6052          * becomes upper diagonal:
6053          * <pre>
6054          *     Ma = [sx    mxy  mxz]
6055          *          [0     sy   myz]
6056          *          [0     0    sz ]
6057          * </pre>
6058          * Values of this matrix are unit-less.
6059          */
6060         private Matrix estimatedMa;
6061 
6062         /**
6063          * Estimated covariance matrix.
6064          */
6065         private Matrix covariance;
6066 
6067         /**
6068          * Estimated MSE (Mean Square Error).
6069          */
6070         private double estimatedMse;
6071 
6072         /**
6073          * Estimated chi square value.
6074          */
6075         private double estimatedChiSq;
6076 
6077         /**
6078          * Estimated degrees of freedom of chi square value. Degrees of freedom is equal to the number of sampled data
6079          * minus the number of estimated parameters.
6080          */
6081         private int estimatedChiSqDegreesOfFreedom;
6082 
6083         /**
6084          * Estimated reduced chi square value. This is equal to estimated chi square value divided by its degrees of
6085          * freedom. Ideally this value should be close to 1.0.
6086          */
6087         private double estimatedReducedChiSq;
6088 
6089         /**
6090          * Estimated probability of finding a smaller chi square value expressed as a value between 0.0 and 1.0. The smaller
6091          * the found chi square value is, the better the fit of the estimated parameters to the actual parameter. Thus, the
6092          * smaller the chance of finding a smaller chi square value, then the better the estimated fit is.
6093          */
6094         private double estimatedP;
6095 
6096         /**
6097          * Estimated measure of quality of estimated fit as a value between 0.0 and 1.0. The larger the quality value is,
6098          * the better the fit that has been estimated.
6099          */
6100         private double estimatedQ;
6101     }
6102 }