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