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.gyroscope;
17  
18  import com.irurueta.algebra.AlgebraException;
19  import com.irurueta.algebra.Matrix;
20  import com.irurueta.navigation.LockedException;
21  import com.irurueta.navigation.NotReadyException;
22  import com.irurueta.navigation.inertial.calibration.BodyKinematicsSequence;
23  import com.irurueta.navigation.inertial.calibration.CalibrationException;
24  import com.irurueta.navigation.inertial.calibration.StandardDeviationTimedBodyKinematics;
25  import com.irurueta.numerical.robust.PROSACRobustEstimator;
26  import com.irurueta.numerical.robust.PROSACRobustEstimatorListener;
27  import com.irurueta.numerical.robust.RobustEstimator;
28  import com.irurueta.numerical.robust.RobustEstimatorException;
29  import com.irurueta.numerical.robust.RobustEstimatorMethod;
30  
31  import java.util.List;
32  
33  /**
34   * Robustly estimates gyroscope cross couplings and scaling factors
35   * along with G-dependent cross biases introduced on the gyroscope by the
36   * specific forces sensed by the accelerometer using PROSAC robust estimator.
37   * <p>
38   * This calibrator assumes that the IMU is at a more or less fixed location on
39   * Earth, and evaluates sequences of measured body kinematics to perform
40   * calibration for unknown orientations on those provided sequences.
41   * Each provided sequence will be preceded by a static period where mean
42   * specific force will be measured to determine gravity (and hence partial
43   * body attitude).
44   * <p>
45   * Measured gyroscope angular rates is assumed to follow the model shown below:
46   * <pre>
47   *     Ωmeas = bg + (I + Mg) * Ωtrue + Gg * ftrue + w
48   * </pre>
49   * Where:
50   * - Ωmeas is the measured gyroscope angular rates. This is a 3x1 vector.
51   * - bg is the gyroscope bias. Ideally, on a perfect gyroscope, this should be a
52   * 3x1 zero vector.
53   * - I is the 3x3 identity matrix.
54   * - Mg is the 3x3 matrix containing cross-couplings and scaling factors. Ideally, on
55   * a perfect gyroscope, this should be a 3x3 zero matrix.
56   * - Ωtrue is ground-truth gyroscope angular rates.
57   * - Gg is the G-dependent cross biases introduced by the specific forces sensed
58   * by the accelerometer. Ideally, on a perfect gyroscope, this should be a 3x3
59   * zero matrix.
60   * - ftrue is ground-truth specific force. This is a 3x1 vector.
61   * - w is measurement noise. This is a 3x1 vector.
62   */
63  public class PROSACRobustKnownBiasEasyGyroscopeCalibrator extends RobustKnownBiasEasyGyroscopeCalibrator {
64  
65      /**
66       * Constant defining default threshold to determine whether samples are inliers or not.
67       */
68      public static final double DEFAULT_THRESHOLD = 1e-3;
69  
70      /**
71       * Minimum value that can be set as threshold.
72       * Threshold must be strictly greater than 0.0.
73       */
74      public static final double MIN_THRESHOLD = 0.0;
75  
76      /**
77       * Indicates that by default inliers will only be computed but not kept.
78       */
79      public static final boolean DEFAULT_COMPUTE_AND_KEEP_INLIERS = false;
80  
81      /**
82       * Indicates that by default residuals will only be computed but not kept.
83       */
84      public static final boolean DEFAULT_COMPUTE_AND_KEEP_RESIDUALS = false;
85  
86      /**
87       * Threshold to determine whether samples are inliers or not when testing possible solutions.
88       * The threshold refers to the amount of error between integrated rotations
89       * of sequences.
90       */
91      private double threshold = DEFAULT_THRESHOLD;
92  
93      /**
94       * Indicates whether inliers must be computed and kept.
95       */
96      private boolean computeAndKeepInliers = DEFAULT_COMPUTE_AND_KEEP_INLIERS;
97  
98      /**
99       * Indicates whether residuals must be computed and kept.
100      */
101     private boolean computeAndKeepResiduals = DEFAULT_COMPUTE_AND_KEEP_RESIDUALS;
102 
103     /**
104      * Quality scores corresponding to each provided sample.
105      * The larger the score value the better the quality of the sample.
106      */
107     private double[] qualityScores;
108 
109     /**
110      * Constructor.
111      */
112     public PROSACRobustKnownBiasEasyGyroscopeCalibrator() {
113         super();
114     }
115 
116     /**
117      * Constructor.
118      *
119      * @param sequences collection of sequences containing timestamped body
120      *                  kinematics measurements.
121      * @param bias      gyroscope known bias. This must be 3x1 and is
122      *                  expressed in radians per second (rad/s).
123      * @param initialMg initial gyroscope scale factors and cross coupling
124      *                  errors matrix. Must be 3x3.
125      * @param initialGg initial gyroscope G-dependent cross biases
126      *                  introduced on the gyroscope by the specific forces
127      *                  sensed by the accelerometer. Must be 3x3.
128      * @throws IllegalArgumentException if any of the provided values does
129      *                                  not have proper size.
130      */
131     public PROSACRobustKnownBiasEasyGyroscopeCalibrator(
132             final List<BodyKinematicsSequence<StandardDeviationTimedBodyKinematics>> sequences, final Matrix bias,
133             final Matrix initialMg, final Matrix initialGg) {
134         super(sequences, bias, initialMg, initialGg);
135     }
136 
137     /**
138      * Constructor.
139      *
140      * @param sequences collection of sequences containing timestamped body
141      *                  kinematics measurements.
142      * @param bias      gyroscope known bias. This must be 3x1 and is
143      *                  expressed in radians per second (rad/s).
144      * @param initialMg initial gyroscope scale factors and cross coupling
145      *                  errors matrix. Must be 3x3.
146      * @param initialGg initial gyroscope G-dependent cross biases
147      *                  introduced on the gyroscope by the specific forces
148      *                  sensed by the accelerometer. Must be 3x3.
149      * @param listener  listener to handle events raised by this
150      *                  calibrator.
151      * @throws IllegalArgumentException if any of the provided values does
152      *                                  not have proper size.
153      */
154     public PROSACRobustKnownBiasEasyGyroscopeCalibrator(
155             final List<BodyKinematicsSequence<StandardDeviationTimedBodyKinematics>> sequences, final Matrix bias,
156             final Matrix initialMg, final Matrix initialGg,
157             final RobustKnownBiasEasyGyroscopeCalibratorListener listener) {
158         super(sequences, bias, initialMg, initialGg, listener);
159     }
160 
161     /**
162      * Constructor.
163      *
164      * @param sequences collection of sequences containing timestamped body
165      *                  kinematics measurements.
166      * @param bias      gyroscope known bias. This must have length 3 and is
167      *                  expressed in radians per second (rad/s).
168      * @param initialMg initial gyroscope scale factors and cross coupling
169      *                  errors matrix. Must be 3x3.
170      * @param initialGg initial gyroscope G-dependent cross biases
171      *                  introduced on the gyroscope by the specific forces
172      *                  sensed by the accelerometer. Must be 3x3.
173      * @throws IllegalArgumentException if any of the provided values does
174      *                                  not have proper size.
175      */
176     public PROSACRobustKnownBiasEasyGyroscopeCalibrator(
177             final List<BodyKinematicsSequence<StandardDeviationTimedBodyKinematics>> sequences, final double[] bias,
178             final Matrix initialMg, final Matrix initialGg) {
179         super(sequences, bias, initialMg, initialGg);
180     }
181 
182     /**
183      * Constructor.
184      *
185      * @param sequences collection of sequences containing timestamped body
186      *                  kinematics measurements.
187      * @param bias      gyroscope known bias. This must have length 3 and is
188      *                  expressed in radians per second (rad/s).
189      * @param initialMg initial gyroscope scale factors and cross coupling
190      *                  errors matrix. Must be 3x3.
191      * @param initialGg initial gyroscope G-dependent cross biases
192      *                  introduced on the gyroscope by the specific forces
193      *                  sensed by the accelerometer. Must be 3x3.
194      * @param listener  listener to handle events raised by this
195      *                  calibrator.
196      * @throws IllegalArgumentException if any of the provided values does
197      *                                  not have proper size.
198      */
199     public PROSACRobustKnownBiasEasyGyroscopeCalibrator(
200             final List<BodyKinematicsSequence<StandardDeviationTimedBodyKinematics>> sequences, final double[] bias,
201             final Matrix initialMg, final Matrix initialGg,
202             final RobustKnownBiasEasyGyroscopeCalibratorListener listener) {
203         super(sequences, bias, initialMg, initialGg, listener);
204     }
205 
206     /**
207      * Constructor.
208      *
209      * @param sequences         collection of sequences containing timestamped body
210      *                          kinematics measurements.
211      * @param bias              gyroscope known bias. This must have length 3 and is
212      *                          expressed in radians per second (rad/s).
213      * @param initialMg         initial gyroscope scale factors and cross coupling
214      *                          errors matrix. Must be 3x3.
215      * @param initialGg         initial gyroscope G-dependent cross biases
216      *                          introduced on the gyroscope by the specific forces
217      *                          sensed by the accelerometer. Must be 3x3.
218      * @param accelerometerBias known accelerometer bias. This must
219      *                          have length 3 and is expressed in
220      *                          meters per squared second
221      *                          (m/s^2).
222      * @param accelerometerMa   known accelerometer scale factors and
223      *                          cross coupling matrix. Must be 3x3.
224      * @throws IllegalArgumentException if any of the provided values does
225      *                                  not have proper size.
226      */
227     public PROSACRobustKnownBiasEasyGyroscopeCalibrator(
228             final List<BodyKinematicsSequence<StandardDeviationTimedBodyKinematics>> sequences,
229             final double[] bias, final Matrix initialMg, final Matrix initialGg,
230             final double[] accelerometerBias, final Matrix accelerometerMa) {
231         super(sequences, bias, initialMg, initialGg, accelerometerBias, accelerometerMa);
232     }
233 
234     /**
235      * Constructor.
236      *
237      * @param sequences         collection of sequences containing timestamped body
238      *                          kinematics measurements.
239      * @param bias              gyroscope known bias. This must have length 3 and is
240      *                          expressed in radians per second (rad/s).
241      * @param initialMg         initial gyroscope scale factors and cross coupling
242      *                          errors matrix. Must be 3x3.
243      * @param initialGg         initial gyroscope G-dependent cross biases
244      *                          introduced on the gyroscope by the specific forces
245      *                          sensed by the accelerometer. Must be 3x3.
246      * @param accelerometerBias known accelerometer bias. This must
247      *                          have length 3 and is expressed in
248      *                          meters per squared second
249      *                          (m/s^2).
250      * @param accelerometerMa   known accelerometer scale factors and
251      *                          cross coupling matrix. Must be 3x3.
252      * @param listener          listener to handle events raised by this
253      *                          calibrator.
254      * @throws IllegalArgumentException if any of the provided values does
255      *                                  not have proper size.
256      */
257     public PROSACRobustKnownBiasEasyGyroscopeCalibrator(
258             final List<BodyKinematicsSequence<StandardDeviationTimedBodyKinematics>> sequences,
259             final double[] bias, final Matrix initialMg, final Matrix initialGg, final double[] accelerometerBias,
260             final Matrix accelerometerMa, final RobustKnownBiasEasyGyroscopeCalibratorListener listener) {
261         super(sequences, bias, initialMg, initialGg, accelerometerBias, accelerometerMa, listener);
262     }
263 
264     /**
265      * Constructor.
266      *
267      * @param sequences         collection of sequences containing timestamped body
268      *                          kinematics measurements.
269      * @param bias              gyroscope known bias. This must be 3x1 and is
270      *                          expressed in radians per second (rad/s).
271      * @param initialMg         initial gyroscope scale factors and cross coupling
272      *                          errors matrix. Must be 3x3.
273      * @param initialGg         initial gyroscope G-dependent cross biases
274      *                          introduced on the gyroscope by the specific forces
275      *                          sensed by the accelerometer. Must be 3x3.
276      * @param accelerometerBias known accelerometer bias. This must be 3x1
277      *                          and is expressed in meters per squared
278      *                          second (m/s^2).
279      * @param accelerometerMa   known accelerometer scale factors and
280      *                          cross coupling matrix. Must be 3x3.
281      * @throws IllegalArgumentException if any of the provided values does
282      *                                  not have proper size.
283      */
284     public PROSACRobustKnownBiasEasyGyroscopeCalibrator(
285             final List<BodyKinematicsSequence<StandardDeviationTimedBodyKinematics>> sequences, final Matrix bias,
286             final Matrix initialMg, final Matrix initialGg, final Matrix accelerometerBias,
287             final Matrix accelerometerMa) {
288         super(sequences, bias, initialMg, initialGg, accelerometerBias, accelerometerMa);
289     }
290 
291     /**
292      * Constructor.
293      *
294      * @param sequences         collection of sequences containing timestamped body
295      *                          kinematics measurements.
296      * @param bias              gyroscope known bias. This must be 3x1 and is
297      *                          expressed in radians per second (rad/s).
298      * @param initialMg         initial gyroscope scale factors and cross coupling
299      *                          errors matrix. Must be 3x3.
300      * @param initialGg         initial gyroscope G-dependent cross biases
301      *                          introduced on the gyroscope by the specific forces
302      *                          sensed by the accelerometer. Must be 3x3.
303      * @param accelerometerBias known accelerometer bias. This must be 3x1
304      *                          and is expressed in meters per squared
305      *                          second (m/s^2).
306      * @param accelerometerMa   known accelerometer scale factors and
307      *                          cross coupling matrix. Must be 3x3.
308      * @param listener          listener to handle events raised by this
309      *                          calibrator.
310      * @throws IllegalArgumentException if any of the provided values does
311      *                                  not have proper size.
312      */
313     public PROSACRobustKnownBiasEasyGyroscopeCalibrator(
314             final List<BodyKinematicsSequence<StandardDeviationTimedBodyKinematics>> sequences, final Matrix bias,
315             final Matrix initialMg, final Matrix initialGg, final Matrix accelerometerBias,
316             final Matrix accelerometerMa, final RobustKnownBiasEasyGyroscopeCalibratorListener listener) {
317         super(sequences, bias, initialMg, initialGg, accelerometerBias, accelerometerMa, listener);
318     }
319 
320     /**
321      * Constructor.
322      *
323      * @param sequences                     collection of sequences containing timestamped body
324      *                                      kinematics measurements.
325      * @param commonAxisUsed                indicates whether z-axis is
326      *                                      assumed to be common for
327      *                                      accelerometer and gyroscope.
328      * @param estimateGDependentCrossBiases true if G-dependent cross biases
329      *                                      will be estimated, false
330      *                                      otherwise.
331      * @param bias                          gyroscope known bias. This must be 3x1 and is
332      *                                      expressed in radians per second (rad/s).
333      * @param initialMg                     initial gyroscope scale factors and cross coupling
334      *                                      errors matrix. Must be 3x3.
335      * @param initialGg                     initial gyroscope G-dependent cross biases
336      *                                      introduced on the gyroscope by the specific forces
337      *                                      sensed by the accelerometer. Must be 3x3.
338      * @throws IllegalArgumentException if any of the provided values does
339      *                                  not have proper size.
340      */
341     public PROSACRobustKnownBiasEasyGyroscopeCalibrator(
342             final List<BodyKinematicsSequence<StandardDeviationTimedBodyKinematics>> sequences,
343             final boolean commonAxisUsed, final boolean estimateGDependentCrossBiases,
344             final Matrix bias, final Matrix initialMg, final Matrix initialGg) {
345         super(sequences, commonAxisUsed, estimateGDependentCrossBiases, bias, initialMg, initialGg);
346     }
347 
348     /**
349      * Constructor.
350      *
351      * @param sequences                     collection of sequences containing timestamped body
352      *                                      kinematics measurements.
353      * @param commonAxisUsed                indicates whether z-axis is
354      *                                      assumed to be common for
355      *                                      accelerometer and gyroscope.
356      * @param estimateGDependentCrossBiases true if G-dependent cross biases
357      *                                      will be estimated, false
358      *                                      otherwise.
359      * @param bias                          gyroscope known bias. This must be 3x1 and is
360      *                                      expressed in radians per second (rad/s).
361      * @param initialMg                     initial gyroscope scale factors and cross coupling
362      *                                      errors matrix. Must be 3x3.
363      * @param initialGg                     initial gyroscope G-dependent cross biases
364      *                                      introduced on the gyroscope by the specific forces
365      *                                      sensed by the accelerometer. Must be 3x3.
366      * @param listener                      listener to handle events raised by this
367      *                                      calibrator.
368      * @throws IllegalArgumentException if any of the provided values does
369      *                                  not have proper size.
370      */
371     public PROSACRobustKnownBiasEasyGyroscopeCalibrator(
372             final List<BodyKinematicsSequence<StandardDeviationTimedBodyKinematics>> sequences,
373             final boolean commonAxisUsed, final boolean estimateGDependentCrossBiases,
374             final Matrix bias, final Matrix initialMg, final Matrix initialGg,
375             final RobustKnownBiasEasyGyroscopeCalibratorListener listener) {
376         super(sequences, commonAxisUsed, estimateGDependentCrossBiases, bias, initialMg, initialGg, listener);
377     }
378 
379     /**
380      * Constructor.
381      *
382      * @param sequences                     collection of sequences containing timestamped body
383      *                                      kinematics measurements.
384      * @param commonAxisUsed                indicates whether z-axis is
385      *                                      assumed to be common for
386      *                                      accelerometer and gyroscope.
387      * @param estimateGDependentCrossBiases true if G-dependent cross biases
388      *                                      will be estimated, false
389      *                                      otherwise.
390      * @param bias                          gyroscope known bias. This must have length 3 and is
391      *                                      expressed in radians per second (rad/s).
392      * @param initialMg                     initial gyroscope scale factors and cross coupling
393      *                                      errors matrix. Must be 3x3.
394      * @param initialGg                     initial gyroscope G-dependent cross biases
395      *                                      introduced on the gyroscope by the specific forces
396      *                                      sensed by the accelerometer. Must be 3x3.
397      * @throws IllegalArgumentException if any of the provided values does
398      *                                  not have proper size.
399      */
400     public PROSACRobustKnownBiasEasyGyroscopeCalibrator(
401             final List<BodyKinematicsSequence<StandardDeviationTimedBodyKinematics>> sequences,
402             final boolean commonAxisUsed, final boolean estimateGDependentCrossBiases,
403             final double[] bias, final Matrix initialMg, final Matrix initialGg) {
404         super(sequences, commonAxisUsed, estimateGDependentCrossBiases, bias, initialMg, initialGg);
405     }
406 
407     /**
408      * Constructor.
409      *
410      * @param sequences                     collection of sequences containing timestamped body
411      *                                      kinematics measurements.
412      * @param commonAxisUsed                indicates whether z-axis is
413      *                                      assumed to be common for
414      *                                      accelerometer and gyroscope.
415      * @param estimateGDependentCrossBiases true if G-dependent cross biases
416      *                                      will be estimated, false
417      *                                      otherwise.
418      * @param bias                          gyroscope known bias. This must have length 3 and is
419      *                                      expressed in radians per second (rad/s).
420      * @param initialMg                     initial gyroscope scale factors and cross coupling
421      *                                      errors matrix. Must be 3x3.
422      * @param initialGg                     initial gyroscope G-dependent cross biases
423      *                                      introduced on the gyroscope by the specific forces
424      *                                      sensed by the accelerometer. Must be 3x3.
425      * @param listener                      listener to handle events raised by this
426      *                                      calibrator.
427      * @throws IllegalArgumentException if any of the provided values does
428      *                                  not have proper size.
429      */
430     public PROSACRobustKnownBiasEasyGyroscopeCalibrator(
431             final List<BodyKinematicsSequence<StandardDeviationTimedBodyKinematics>> sequences,
432             final boolean commonAxisUsed, final boolean estimateGDependentCrossBiases, final double[] bias,
433             final Matrix initialMg, final Matrix initialGg,
434             final RobustKnownBiasEasyGyroscopeCalibratorListener listener) {
435         super(sequences, commonAxisUsed, estimateGDependentCrossBiases, bias, initialMg, initialGg, listener);
436     }
437 
438     /**
439      * Constructor.
440      *
441      * @param sequences                     collection of sequences containing timestamped body
442      *                                      kinematics measurements.
443      * @param commonAxisUsed                indicates whether z-axis is
444      *                                      assumed to be common for
445      *                                      accelerometer and gyroscope.
446      * @param estimateGDependentCrossBiases true if G-dependent cross biases
447      *                                      will be estimated, false
448      *                                      otherwise.
449      * @param bias                          gyroscope known bias. This must have length 3 and is
450      *                                      expressed in radians per second (rad/s).
451      * @param initialMg                     initial gyroscope scale factors and cross coupling
452      *                                      errors matrix. Must be 3x3.
453      * @param initialGg                     initial gyroscope G-dependent cross biases
454      *                                      introduced on the gyroscope by the specific forces
455      *                                      sensed by the accelerometer. Must be 3x3.
456      * @param accelerometerBias             known accelerometer bias. This
457      *                                      must have length 3 and is
458      *                                      expressed in meters per squared
459      *                                      second (m/s^2).
460      * @param accelerometerMa               known accelerometer scale factors
461      *                                      and cross coupling matrix. Must
462      *                                      be 3x3.
463      * @throws IllegalArgumentException if any of the provided values does
464      *                                  not have proper size.
465      */
466     public PROSACRobustKnownBiasEasyGyroscopeCalibrator(
467             final List<BodyKinematicsSequence<StandardDeviationTimedBodyKinematics>> sequences,
468             final boolean commonAxisUsed, final boolean estimateGDependentCrossBiases, final double[] bias,
469             final Matrix initialMg, final Matrix initialGg, final double[] accelerometerBias,
470             final Matrix accelerometerMa) {
471         super(sequences, commonAxisUsed, estimateGDependentCrossBiases, bias, initialMg, initialGg, accelerometerBias,
472                 accelerometerMa);
473     }
474 
475     /**
476      * Constructor.
477      *
478      * @param sequences                     collection of sequences containing timestamped body
479      *                                      kinematics measurements.
480      * @param commonAxisUsed                indicates whether z-axis is
481      *                                      assumed to be common for
482      *                                      accelerometer and gyroscope.
483      * @param estimateGDependentCrossBiases true if G-dependent cross biases
484      *                                      will be estimated, false
485      *                                      otherwise.
486      * @param bias                          gyroscope known bias. This must have length 3 and is
487      *                                      expressed in radians per second (rad/s).
488      * @param initialMg                     initial gyroscope scale factors and cross coupling
489      *                                      errors matrix. Must be 3x3.
490      * @param initialGg                     initial gyroscope G-dependent cross biases
491      *                                      introduced on the gyroscope by the specific forces
492      *                                      sensed by the accelerometer. Must be 3x3.
493      * @param accelerometerBias             known accelerometer bias. This
494      *                                      must have length 3 and is
495      *                                      expressed in meters per squared
496      *                                      second (m/s^2).
497      * @param accelerometerMa               known accelerometer scale factors
498      *                                      and cross coupling matrix. Must
499      *                                      be 3x3.
500      * @param listener                      listener to handle events raised by this
501      *                                      calibrator.
502      * @throws IllegalArgumentException if any of the provided values does
503      *                                  not have proper size.
504      */
505     public PROSACRobustKnownBiasEasyGyroscopeCalibrator(
506             final List<BodyKinematicsSequence<StandardDeviationTimedBodyKinematics>> sequences,
507             final boolean commonAxisUsed, final boolean estimateGDependentCrossBiases, final double[] bias,
508             final Matrix initialMg, final Matrix initialGg, final double[] accelerometerBias,
509             final Matrix accelerometerMa, final RobustKnownBiasEasyGyroscopeCalibratorListener listener) {
510         super(sequences, commonAxisUsed, estimateGDependentCrossBiases, bias, initialMg, initialGg, accelerometerBias,
511                 accelerometerMa, listener);
512     }
513 
514     /**
515      * Constructor.
516      *
517      * @param sequences                     collection of sequences containing timestamped body
518      *                                      kinematics measurements.
519      * @param commonAxisUsed                indicates whether z-axis is
520      *                                      assumed to be common for
521      *                                      accelerometer and gyroscope.
522      * @param estimateGDependentCrossBiases true if G-dependent cross biases
523      *                                      will be estimated, false
524      *                                      otherwise.
525      * @param bias                          gyroscope known bias. This must be 3x1 and is
526      *                                      expressed in radians per second (rad/s).
527      * @param initialMg                     initial gyroscope scale factors and cross coupling
528      *                                      errors matrix. Must be 3x3.
529      * @param initialGg                     initial gyroscope G-dependent cross biases
530      *                                      introduced on the gyroscope by the specific forces
531      *                                      sensed by the accelerometer. Must be 3x3.
532      * @param accelerometerBias             known accelerometer bias. This
533      *                                      must have length 3 and is
534      *                                      expressed in meters per squared
535      *                                      second (m/s^2).
536      * @param accelerometerMa               known accelerometer scale factors
537      *                                      and cross coupling matrix. Must
538      *                                      be 3x3.
539      * @throws IllegalArgumentException if any of the provided values does
540      *                                  not have proper size.
541      */
542     public PROSACRobustKnownBiasEasyGyroscopeCalibrator(
543             final List<BodyKinematicsSequence<StandardDeviationTimedBodyKinematics>> sequences,
544             final boolean commonAxisUsed, final boolean estimateGDependentCrossBiases, final Matrix bias,
545             final Matrix initialMg, final Matrix initialGg, final Matrix accelerometerBias,
546             final Matrix accelerometerMa) {
547         super(sequences, commonAxisUsed, estimateGDependentCrossBiases, bias, initialMg, initialGg, accelerometerBias,
548                 accelerometerMa);
549     }
550 
551     /**
552      * Constructor.
553      *
554      * @param sequences                     collection of sequences containing timestamped body
555      *                                      kinematics measurements.
556      * @param commonAxisUsed                indicates whether z-axis is
557      *                                      assumed to be common for
558      *                                      accelerometer and gyroscope.
559      * @param estimateGDependentCrossBiases true if G-dependent cross biases
560      *                                      will be estimated, false
561      *                                      otherwise.
562      * @param bias                          gyroscope known bias. This must be 3x1 and is
563      *                                      expressed in radians per second (rad/s).
564      * @param initialMg                     initial gyroscope scale factors and cross coupling
565      *                                      errors matrix. Must be 3x3.
566      * @param initialGg                     initial gyroscope G-dependent cross biases
567      *                                      introduced on the gyroscope by the specific forces
568      *                                      sensed by the accelerometer. Must be 3x3.
569      * @param accelerometerBias             known accelerometer bias. This
570      *                                      must have length 3 and is
571      *                                      expressed in meters per squared
572      *                                      second (m/s^2).
573      * @param accelerometerMa               known accelerometer scale factors
574      *                                      and cross coupling matrix. Must
575      *                                      be 3x3.
576      * @param listener                      listener to handle events raised by this
577      *                                      calibrator.
578      * @throws IllegalArgumentException if any of the provided values does
579      *                                  not have proper size.
580      */
581     public PROSACRobustKnownBiasEasyGyroscopeCalibrator(
582             final List<BodyKinematicsSequence<StandardDeviationTimedBodyKinematics>> sequences,
583             final boolean commonAxisUsed, final boolean estimateGDependentCrossBiases, final Matrix bias,
584             final Matrix initialMg, final Matrix initialGg, final Matrix accelerometerBias,
585             final Matrix accelerometerMa, final RobustKnownBiasEasyGyroscopeCalibratorListener listener) {
586         super(sequences, commonAxisUsed, estimateGDependentCrossBiases, bias, initialMg, initialGg, accelerometerBias,
587                 accelerometerMa, listener);
588     }
589 
590     /**
591      * Constructor.
592      *
593      * @param qualityScores quality scores corresponding to each provided
594      *                      sequence. The larger the score value the better
595      *                      the quality of the sequence.
596      * @throws IllegalArgumentException if provided quality scores length
597      *                                  is smaller than 10.
598      */
599     public PROSACRobustKnownBiasEasyGyroscopeCalibrator(final double[] qualityScores) {
600         super();
601         internalSetQualityScores(qualityScores);
602     }
603 
604     /**
605      * Constructor.
606      *
607      * @param qualityScores quality scores corresponding to each provided
608      *                      sequence. The larger the score value the better
609      *                      the quality of the sequence.
610      * @param sequences     collection of sequences containing timestamped body
611      *                      kinematics measurements.
612      * @param bias          gyroscope known bias. This must be 3x1 and is
613      *                      expressed in radians per second (rad/s).
614      * @param initialMg     initial gyroscope scale factors and cross coupling
615      *                      errors matrix. Must be 3x3.
616      * @param initialGg     initial gyroscope G-dependent cross biases
617      *                      introduced on the gyroscope by the specific forces
618      *                      sensed by the accelerometer. Must be 3x3.
619      * @throws IllegalArgumentException if any of the provided values does
620      *                                  not have proper size or if provided
621      *                                  quality scores length is smaller
622      *                                  than 10.
623      */
624     public PROSACRobustKnownBiasEasyGyroscopeCalibrator(
625             final double[] qualityScores,
626             final List<BodyKinematicsSequence<StandardDeviationTimedBodyKinematics>> sequences, final Matrix bias,
627             final Matrix initialMg, final Matrix initialGg) {
628         super(sequences, bias, initialMg, initialGg);
629         internalSetQualityScores(qualityScores);
630     }
631 
632     /**
633      * Constructor.
634      *
635      * @param qualityScores quality scores corresponding to each provided
636      *                      sequence. The larger the score value the better
637      *                      the quality of the sequence.
638      * @param sequences     collection of sequences containing timestamped body
639      *                      kinematics measurements.
640      * @param bias          gyroscope known bias. This must be 3x1 and is
641      *                      expressed in radians per second (rad/s).
642      * @param initialMg     initial gyroscope scale factors and cross coupling
643      *                      errors matrix. Must be 3x3.
644      * @param initialGg     initial gyroscope G-dependent cross biases
645      *                      introduced on the gyroscope by the specific forces
646      *                      sensed by the accelerometer. Must be 3x3.
647      * @param listener      listener to handle events raised by this
648      *                      calibrator.
649      * @throws IllegalArgumentException if any of the provided values does
650      *                                  not have proper size or if provided
651      *                                  quality scores length is smaller
652      *                                  than 10.
653      */
654     public PROSACRobustKnownBiasEasyGyroscopeCalibrator(
655             final double[] qualityScores,
656             final List<BodyKinematicsSequence<StandardDeviationTimedBodyKinematics>> sequences, final Matrix bias,
657             final Matrix initialMg, final Matrix initialGg,
658             final RobustKnownBiasEasyGyroscopeCalibratorListener listener) {
659         super(sequences, bias, initialMg, initialGg, listener);
660         internalSetQualityScores(qualityScores);
661     }
662 
663     /**
664      * Constructor.
665      *
666      * @param qualityScores quality scores corresponding to each provided
667      *                      sequence. The larger the score value the better
668      *                      the quality of the sequence.
669      * @param sequences     collection of sequences containing timestamped body
670      *                      kinematics measurements.
671      * @param bias          gyroscope known bias. This must have length 3 and is
672      *                      expressed in radians per second (rad/s).
673      * @param initialMg     initial gyroscope scale factors and cross coupling
674      *                      errors matrix. Must be 3x3.
675      * @param initialGg     initial gyroscope G-dependent cross biases
676      *                      introduced on the gyroscope by the specific forces
677      *                      sensed by the accelerometer. Must be 3x3.
678      * @throws IllegalArgumentException if any of the provided values does
679      *                                  not have proper size or if provided
680      *                                  quality scores length is smaller
681      *                                  than 10.
682      */
683     public PROSACRobustKnownBiasEasyGyroscopeCalibrator(
684             final double[] qualityScores,
685             final List<BodyKinematicsSequence<StandardDeviationTimedBodyKinematics>> sequences, final double[] bias,
686             final Matrix initialMg, final Matrix initialGg) {
687         super(sequences, bias, initialMg, initialGg);
688         internalSetQualityScores(qualityScores);
689     }
690 
691     /**
692      * Constructor.
693      *
694      * @param qualityScores quality scores corresponding to each provided
695      *                      sequence. The larger the score value the better
696      *                      the quality of the sequence.
697      * @param sequences     collection of sequences containing timestamped body
698      *                      kinematics measurements.
699      * @param bias          gyroscope known bias. This must have length 3 and is
700      *                      expressed in radians per second (rad/s).
701      * @param initialMg     initial gyroscope scale factors and cross coupling
702      *                      errors matrix. Must be 3x3.
703      * @param initialGg     initial gyroscope G-dependent cross biases
704      *                      introduced on the gyroscope by the specific forces
705      *                      sensed by the accelerometer. Must be 3x3.
706      * @param listener      listener to handle events raised by this
707      *                      calibrator.
708      * @throws IllegalArgumentException if any of the provided values does
709      *                                  not have proper size or if provided
710      *                                  quality scores length is smaller
711      *                                  than 10.
712      */
713     public PROSACRobustKnownBiasEasyGyroscopeCalibrator(
714             final double[] qualityScores,
715             final List<BodyKinematicsSequence<StandardDeviationTimedBodyKinematics>> sequences, final double[] bias,
716             final Matrix initialMg, final Matrix initialGg,
717             final RobustKnownBiasEasyGyroscopeCalibratorListener listener) {
718         super(sequences, bias, initialMg, initialGg, listener);
719         internalSetQualityScores(qualityScores);
720     }
721 
722     /**
723      * Constructor.
724      *
725      * @param qualityScores     quality scores corresponding to each provided
726      *                          sequence. The larger the score value the better
727      *                          the quality of the sequence.
728      * @param sequences         collection of sequences containing timestamped body
729      *                          kinematics measurements.
730      * @param bias              gyroscope known bias. This must have length 3 and is
731      *                          expressed in radians per second (rad/s).
732      * @param initialMg         initial gyroscope scale factors and cross coupling
733      *                          errors matrix. Must be 3x3.
734      * @param initialGg         initial gyroscope G-dependent cross biases
735      *                          introduced on the gyroscope by the specific forces
736      *                          sensed by the accelerometer. Must be 3x3.
737      * @param accelerometerBias known accelerometer bias. This must
738      *                          have length 3 and is expressed in
739      *                          meters per squared second
740      *                          (m/s^2).
741      * @param accelerometerMa   known accelerometer scale factors and
742      *                          cross coupling matrix. Must be 3x3.
743      * @throws IllegalArgumentException if any of the provided values does
744      *                                  not have proper size or if provided
745      *                                  quality scores length is smaller
746      *                                  than 10.
747      */
748     public PROSACRobustKnownBiasEasyGyroscopeCalibrator(
749             final double[] qualityScores,
750             final List<BodyKinematicsSequence<StandardDeviationTimedBodyKinematics>> sequences, final double[] bias,
751             final Matrix initialMg, final Matrix initialGg, final double[] accelerometerBias,
752             final Matrix accelerometerMa) {
753         super(sequences, bias, initialMg, initialGg, accelerometerBias, accelerometerMa);
754         internalSetQualityScores(qualityScores);
755     }
756 
757     /**
758      * Constructor.
759      *
760      * @param qualityScores     quality scores corresponding to each provided
761      *                          sequence. The larger the score value the better
762      *                          the quality of the sequence.
763      * @param sequences         collection of sequences containing timestamped body
764      *                          kinematics measurements.
765      * @param bias              gyroscope known bias. This must have length 3 and is
766      *                          expressed in radians per second (rad/s).
767      * @param initialMg         initial gyroscope scale factors and cross coupling
768      *                          errors matrix. Must be 3x3.
769      * @param initialGg         initial gyroscope G-dependent cross biases
770      *                          introduced on the gyroscope by the specific forces
771      *                          sensed by the accelerometer. Must be 3x3.
772      * @param accelerometerBias known accelerometer bias. This must
773      *                          have length 3 and is expressed in
774      *                          meters per squared second
775      *                          (m/s^2).
776      * @param accelerometerMa   known accelerometer scale factors and
777      *                          cross coupling matrix. Must be 3x3.
778      * @param listener          listener to handle events raised by this
779      *                          calibrator.
780      * @throws IllegalArgumentException if any of the provided values does
781      *                                  not have proper size or if provided
782      *                                  quality scores length is smaller
783      *                                  than 10.
784      */
785     public PROSACRobustKnownBiasEasyGyroscopeCalibrator(
786             final double[] qualityScores,
787             final List<BodyKinematicsSequence<StandardDeviationTimedBodyKinematics>> sequences, final double[] bias,
788             final Matrix initialMg, final Matrix initialGg, final double[] accelerometerBias,
789             final Matrix accelerometerMa, final RobustKnownBiasEasyGyroscopeCalibratorListener listener) {
790         super(sequences, bias, initialMg, initialGg, accelerometerBias, accelerometerMa, listener);
791         internalSetQualityScores(qualityScores);
792     }
793 
794     /**
795      * Constructor.
796      *
797      * @param qualityScores     quality scores corresponding to each provided
798      *                          sequence. The larger the score value the better
799      *                          the quality of the sequence.
800      * @param sequences         collection of sequences containing timestamped body
801      *                          kinematics measurements.
802      * @param bias              gyroscope known bias. This must be 3x1 and is
803      *                          expressed in radians per second (rad/s).
804      * @param initialMg         initial gyroscope scale factors and cross coupling
805      *                          errors matrix. Must be 3x3.
806      * @param initialGg         initial gyroscope G-dependent cross biases
807      *                          introduced on the gyroscope by the specific forces
808      *                          sensed by the accelerometer. Must be 3x3.
809      * @param accelerometerBias known accelerometer bias. This must be 3x1
810      *                          and is expressed in meters per squared
811      *                          second (m/s^2).
812      * @param accelerometerMa   known accelerometer scale factors and
813      *                          cross coupling matrix. Must be 3x3.
814      * @throws IllegalArgumentException if any of the provided values does
815      *                                  not have proper size or if provided
816      *                                  quality scores length is smaller
817      *                                  than 10.
818      */
819     public PROSACRobustKnownBiasEasyGyroscopeCalibrator(
820             final double[] qualityScores,
821             final List<BodyKinematicsSequence<StandardDeviationTimedBodyKinematics>> sequences, final Matrix bias,
822             final Matrix initialMg, final Matrix initialGg, final Matrix accelerometerBias,
823             final Matrix accelerometerMa) {
824         super(sequences, bias, initialMg, initialGg, accelerometerBias, accelerometerMa);
825         internalSetQualityScores(qualityScores);
826     }
827 
828     /**
829      * Constructor.
830      *
831      * @param qualityScores     quality scores corresponding to each provided
832      *                          sequence. The larger the score value the better
833      *                          the quality of the sequence.
834      * @param sequences         collection of sequences containing timestamped body
835      *                          kinematics measurements.
836      * @param bias              gyroscope known bias. This must be 3x1 and is
837      *                          expressed in radians per second (rad/s).
838      * @param initialMg         initial gyroscope scale factors and cross coupling
839      *                          errors matrix. Must be 3x3.
840      * @param initialGg         initial gyroscope G-dependent cross biases
841      *                          introduced on the gyroscope by the specific forces
842      *                          sensed by the accelerometer. Must be 3x3.
843      * @param accelerometerBias known accelerometer bias. This must be 3x1
844      *                          and is expressed in meters per squared
845      *                          second (m/s^2).
846      * @param accelerometerMa   known accelerometer scale factors and
847      *                          cross coupling matrix. Must be 3x3.
848      * @param listener          listener to handle events raised by this
849      *                          calibrator.
850      * @throws IllegalArgumentException if any of the provided values does
851      *                                  not have proper size or if provided
852      *                                  quality scores length is smaller
853      *                                  than 10.
854      */
855     public PROSACRobustKnownBiasEasyGyroscopeCalibrator(
856             final double[] qualityScores,
857             final List<BodyKinematicsSequence<StandardDeviationTimedBodyKinematics>> sequences, final Matrix bias,
858             final Matrix initialMg, final Matrix initialGg, final Matrix accelerometerBias,
859             final Matrix accelerometerMa, final RobustKnownBiasEasyGyroscopeCalibratorListener listener) {
860         super(sequences, bias, initialMg, initialGg, accelerometerBias, accelerometerMa, listener);
861         internalSetQualityScores(qualityScores);
862     }
863 
864     /**
865      * Constructor.
866      *
867      * @param qualityScores                 quality scores corresponding to each provided
868      *                                      sequence. The larger the score value the better
869      *                                      the quality of the sequence.
870      * @param sequences                     collection of sequences containing timestamped body
871      *                                      kinematics measurements.
872      * @param commonAxisUsed                indicates whether z-axis is
873      *                                      assumed to be common for
874      *                                      accelerometer and gyroscope.
875      * @param estimateGDependentCrossBiases true if G-dependent cross biases
876      *                                      will be estimated, false
877      *                                      otherwise.
878      * @param bias                          gyroscope known bias. This must be 3x1 and is
879      *                                      expressed in radians per second (rad/s).
880      * @param initialMg                     initial gyroscope scale factors and cross coupling
881      *                                      errors matrix. Must be 3x3.
882      * @param initialGg                     initial gyroscope G-dependent cross biases
883      *                                      introduced on the gyroscope by the specific forces
884      *                                      sensed by the accelerometer. Must be 3x3.
885      * @throws IllegalArgumentException if any of the provided values does
886      *                                  not have proper size or if provided
887      *                                  quality scores length is smaller
888      *                                  than 10.
889      */
890     public PROSACRobustKnownBiasEasyGyroscopeCalibrator(
891             final double[] qualityScores,
892             final List<BodyKinematicsSequence<StandardDeviationTimedBodyKinematics>> sequences,
893             final boolean commonAxisUsed, final boolean estimateGDependentCrossBiases, final Matrix bias,
894             final Matrix initialMg, final Matrix initialGg) {
895         super(sequences, commonAxisUsed, estimateGDependentCrossBiases, bias, initialMg, initialGg);
896         internalSetQualityScores(qualityScores);
897     }
898 
899     /**
900      * Constructor.
901      *
902      * @param qualityScores                 quality scores corresponding to each provided
903      *                                      sequence. The larger the score value the better
904      *                                      the quality of the sequence.
905      * @param sequences                     collection of sequences containing timestamped body
906      *                                      kinematics measurements.
907      * @param commonAxisUsed                indicates whether z-axis is
908      *                                      assumed to be common for
909      *                                      accelerometer and gyroscope.
910      * @param estimateGDependentCrossBiases true if G-dependent cross biases
911      *                                      will be estimated, false
912      *                                      otherwise.
913      * @param bias                          gyroscope known bias. This must be 3x1 and is
914      *                                      expressed in radians per second (rad/s).
915      * @param initialMg                     initial gyroscope scale factors and cross coupling
916      *                                      errors matrix. Must be 3x3.
917      * @param initialGg                     initial gyroscope G-dependent cross biases
918      *                                      introduced on the gyroscope by the specific forces
919      *                                      sensed by the accelerometer. Must be 3x3.
920      * @param listener                      listener to handle events raised by this
921      *                                      calibrator.
922      * @throws IllegalArgumentException if any of the provided values does
923      *                                  not have proper size or if provided
924      *                                  quality scores length is smaller
925      *                                  than 10.
926      */
927     public PROSACRobustKnownBiasEasyGyroscopeCalibrator(
928             final double[] qualityScores,
929             final List<BodyKinematicsSequence<StandardDeviationTimedBodyKinematics>> sequences,
930             final boolean commonAxisUsed, final boolean estimateGDependentCrossBiases, final Matrix bias,
931             final Matrix initialMg, final Matrix initialGg,
932             final RobustKnownBiasEasyGyroscopeCalibratorListener listener) {
933         super(sequences, commonAxisUsed, estimateGDependentCrossBiases, bias, initialMg, initialGg, listener);
934         internalSetQualityScores(qualityScores);
935     }
936 
937     /**
938      * Constructor.
939      *
940      * @param qualityScores                 quality scores corresponding to each provided
941      *                                      sequence. The larger the score value the better
942      *                                      the quality of the sequence.
943      * @param sequences                     collection of sequences containing timestamped body
944      *                                      kinematics measurements.
945      * @param commonAxisUsed                indicates whether z-axis is
946      *                                      assumed to be common for
947      *                                      accelerometer and gyroscope.
948      * @param estimateGDependentCrossBiases true if G-dependent cross biases
949      *                                      will be estimated, false
950      *                                      otherwise.
951      * @param bias                          gyroscope known bias. This must have length 3 and is
952      *                                      expressed in radians per second (rad/s).
953      * @param initialMg                     initial gyroscope scale factors and cross coupling
954      *                                      errors matrix. Must be 3x3.
955      * @param initialGg                     initial gyroscope G-dependent cross biases
956      *                                      introduced on the gyroscope by the specific forces
957      *                                      sensed by the accelerometer. Must be 3x3.
958      * @throws IllegalArgumentException if any of the provided values does
959      *                                  not have proper size or if provided
960      *                                  quality scores length is smaller
961      *                                  than 10.
962      */
963     public PROSACRobustKnownBiasEasyGyroscopeCalibrator(
964             final double[] qualityScores,
965             final List<BodyKinematicsSequence<StandardDeviationTimedBodyKinematics>> sequences,
966             final boolean commonAxisUsed, final boolean estimateGDependentCrossBiases, final double[] bias,
967             final Matrix initialMg, final Matrix initialGg) {
968         super(sequences, commonAxisUsed, estimateGDependentCrossBiases, bias, initialMg, initialGg);
969         internalSetQualityScores(qualityScores);
970     }
971 
972     /**
973      * Constructor.
974      *
975      * @param qualityScores                 quality scores corresponding to each provided
976      *                                      sequence. The larger the score value the better
977      *                                      the quality of the sequence.
978      * @param sequences                     collection of sequences containing timestamped body
979      *                                      kinematics measurements.
980      * @param commonAxisUsed                indicates whether z-axis is
981      *                                      assumed to be common for
982      *                                      accelerometer and gyroscope.
983      * @param estimateGDependentCrossBiases true if G-dependent cross biases
984      *                                      will be estimated, false
985      *                                      otherwise.
986      * @param bias                          gyroscope known bias. This must have length 3 and is
987      *                                      expressed in radians per second (rad/s).
988      * @param initialMg                     initial gyroscope scale factors and cross coupling
989      *                                      errors matrix. Must be 3x3.
990      * @param initialGg                     initial gyroscope G-dependent cross biases
991      *                                      introduced on the gyroscope by the specific forces
992      *                                      sensed by the accelerometer. Must be 3x3.
993      * @param listener                      listener to handle events raised by this
994      *                                      calibrator.
995      * @throws IllegalArgumentException if any of the provided values does
996      *                                  not have proper size or if provided
997      *                                  quality scores length is smaller
998      *                                  than 10.
999      */
1000     public PROSACRobustKnownBiasEasyGyroscopeCalibrator(
1001             final double[] qualityScores,
1002             final List<BodyKinematicsSequence<StandardDeviationTimedBodyKinematics>> sequences,
1003             final boolean commonAxisUsed, final boolean estimateGDependentCrossBiases, final double[] bias,
1004             final Matrix initialMg, final Matrix initialGg,
1005             final RobustKnownBiasEasyGyroscopeCalibratorListener listener) {
1006         super(sequences, commonAxisUsed, estimateGDependentCrossBiases, bias, initialMg, initialGg, listener);
1007         internalSetQualityScores(qualityScores);
1008     }
1009 
1010     /**
1011      * Constructor.
1012      *
1013      * @param qualityScores                 quality scores corresponding to each provided
1014      *                                      sequence. The larger the score value the better
1015      *                                      the quality of the sequence.
1016      * @param sequences                     collection of sequences containing timestamped body
1017      *                                      kinematics measurements.
1018      * @param commonAxisUsed                indicates whether z-axis is
1019      *                                      assumed to be common for
1020      *                                      accelerometer and gyroscope.
1021      * @param estimateGDependentCrossBiases true if G-dependent cross biases
1022      *                                      will be estimated, false
1023      *                                      otherwise.
1024      * @param bias                          gyroscope known bias. This must have length 3 and is
1025      *                                      expressed in radians per second (rad/s).
1026      * @param initialMg                     initial gyroscope scale factors and cross coupling
1027      *                                      errors matrix. Must be 3x3.
1028      * @param initialGg                     initial gyroscope G-dependent cross biases
1029      *                                      introduced on the gyroscope by the specific forces
1030      *                                      sensed by the accelerometer. Must be 3x3.
1031      * @param accelerometerBias             known accelerometer bias. This
1032      *                                      must have length 3 and is
1033      *                                      expressed in meters per squared
1034      *                                      second (m/s^2).
1035      * @param accelerometerMa               known accelerometer scale factors
1036      *                                      and cross coupling matrix. Must
1037      *                                      be 3x3.
1038      * @throws IllegalArgumentException if any of the provided values does
1039      *                                  not have proper size or if provided
1040      *                                  quality scores length is smaller
1041      *                                  than 10.
1042      */
1043     public PROSACRobustKnownBiasEasyGyroscopeCalibrator(
1044             final double[] qualityScores,
1045             final List<BodyKinematicsSequence<StandardDeviationTimedBodyKinematics>> sequences,
1046             final boolean commonAxisUsed, final boolean estimateGDependentCrossBiases, final double[] bias,
1047             final Matrix initialMg, final Matrix initialGg, final double[] accelerometerBias,
1048             final Matrix accelerometerMa) {
1049         super(sequences, commonAxisUsed, estimateGDependentCrossBiases, bias, initialMg, initialGg, accelerometerBias,
1050                 accelerometerMa);
1051         internalSetQualityScores(qualityScores);
1052     }
1053 
1054     /**
1055      * Constructor.
1056      *
1057      * @param qualityScores                 quality scores corresponding to each provided
1058      *                                      sequence. The larger the score value the better
1059      *                                      the quality of the sequence.
1060      * @param sequences                     collection of sequences containing timestamped body
1061      *                                      kinematics measurements.
1062      * @param commonAxisUsed                indicates whether z-axis is
1063      *                                      assumed to be common for
1064      *                                      accelerometer and gyroscope.
1065      * @param estimateGDependentCrossBiases true if G-dependent cross biases
1066      *                                      will be estimated, false
1067      *                                      otherwise.
1068      * @param bias                          gyroscope known bias. This must have length 3 and is
1069      *                                      expressed in radians per second (rad/s).
1070      * @param initialMg                     initial gyroscope scale factors and cross coupling
1071      *                                      errors matrix. Must be 3x3.
1072      * @param initialGg                     initial gyroscope G-dependent cross biases
1073      *                                      introduced on the gyroscope by the specific forces
1074      *                                      sensed by the accelerometer. Must be 3x3.
1075      * @param accelerometerBias             known accelerometer bias. This
1076      *                                      must have length 3 and is
1077      *                                      expressed in meters per squared
1078      *                                      second (m/s^2).
1079      * @param accelerometerMa               known accelerometer scale factors
1080      *                                      and cross coupling matrix. Must
1081      *                                      be 3x3.
1082      * @param listener                      listener to handle events raised by this
1083      *                                      calibrator.
1084      * @throws IllegalArgumentException if any of the provided values does
1085      *                                  not have proper size or if provided
1086      *                                  quality scores length is smaller
1087      *                                  than 10.
1088      */
1089     public PROSACRobustKnownBiasEasyGyroscopeCalibrator(
1090             final double[] qualityScores,
1091             final List<BodyKinematicsSequence<StandardDeviationTimedBodyKinematics>> sequences,
1092             final boolean commonAxisUsed, final boolean estimateGDependentCrossBiases, final double[] bias,
1093             final Matrix initialMg, final Matrix initialGg, final double[] accelerometerBias,
1094             final Matrix accelerometerMa, final RobustKnownBiasEasyGyroscopeCalibratorListener listener) {
1095         super(sequences, commonAxisUsed, estimateGDependentCrossBiases, bias, initialMg, initialGg, accelerometerBias,
1096                 accelerometerMa, listener);
1097         internalSetQualityScores(qualityScores);
1098     }
1099 
1100     /**
1101      * Constructor.
1102      *
1103      * @param qualityScores                 quality scores corresponding to each provided
1104      *                                      sequence. The larger the score value the better
1105      *                                      the quality of the sequence.
1106      * @param sequences                     collection of sequences containing timestamped body
1107      *                                      kinematics measurements.
1108      * @param commonAxisUsed                indicates whether z-axis is
1109      *                                      assumed to be common for
1110      *                                      accelerometer and gyroscope.
1111      * @param estimateGDependentCrossBiases true if G-dependent cross biases
1112      *                                      will be estimated, false
1113      *                                      otherwise.
1114      * @param bias                          gyroscope known bias. This must be 3x1 and is
1115      *                                      expressed in radians per second (rad/s).
1116      * @param initialMg                     initial gyroscope scale factors and cross coupling
1117      *                                      errors matrix. Must be 3x3.
1118      * @param initialGg                     initial gyroscope G-dependent cross biases
1119      *                                      introduced on the gyroscope by the specific forces
1120      *                                      sensed by the accelerometer. Must be 3x3.
1121      * @param accelerometerBias             known accelerometer bias. This
1122      *                                      must have length 3 and is
1123      *                                      expressed in meters per squared
1124      *                                      second (m/s^2).
1125      * @param accelerometerMa               known accelerometer scale factors
1126      *                                      and cross coupling matrix. Must
1127      *                                      be 3x3.
1128      * @throws IllegalArgumentException if any of the provided values does
1129      *                                  not have proper size or if provided
1130      *                                  quality scores length is smaller
1131      *                                  than 10.
1132      */
1133     public PROSACRobustKnownBiasEasyGyroscopeCalibrator(
1134             final double[] qualityScores,
1135             final List<BodyKinematicsSequence<StandardDeviationTimedBodyKinematics>> sequences,
1136             final boolean commonAxisUsed, final boolean estimateGDependentCrossBiases, final Matrix bias,
1137             final Matrix initialMg, final Matrix initialGg, final Matrix accelerometerBias,
1138             final Matrix accelerometerMa) {
1139         super(sequences, commonAxisUsed, estimateGDependentCrossBiases, bias, initialMg, initialGg, accelerometerBias,
1140                 accelerometerMa);
1141         internalSetQualityScores(qualityScores);
1142     }
1143 
1144     /**
1145      * Constructor.
1146      *
1147      * @param qualityScores                 quality scores corresponding to each provided
1148      *                                      sequence. The larger the score value the better
1149      *                                      the quality of the sequence.
1150      * @param sequences                     collection of sequences containing timestamped body
1151      *                                      kinematics measurements.
1152      * @param commonAxisUsed                indicates whether z-axis is
1153      *                                      assumed to be common for
1154      *                                      accelerometer and gyroscope.
1155      * @param estimateGDependentCrossBiases true if G-dependent cross biases
1156      *                                      will be estimated, false
1157      *                                      otherwise.
1158      * @param bias                          gyroscope known bias. This must be 3x1 and is
1159      *                                      expressed in radians per second (rad/s).
1160      * @param initialMg                     initial gyroscope scale factors and cross coupling
1161      *                                      errors matrix. Must be 3x3.
1162      * @param initialGg                     initial gyroscope G-dependent cross biases
1163      *                                      introduced on the gyroscope by the specific forces
1164      *                                      sensed by the accelerometer. Must be 3x3.
1165      * @param accelerometerBias             known accelerometer bias. This
1166      *                                      must have length 3 and is
1167      *                                      expressed in meters per squared
1168      *                                      second (m/s^2).
1169      * @param accelerometerMa               known accelerometer scale factors
1170      *                                      and cross coupling matrix. Must
1171      *                                      be 3x3.
1172      * @param listener                      listener to handle events raised by this
1173      *                                      calibrator.
1174      * @throws IllegalArgumentException if any of the provided values does
1175      *                                  not have proper size or if provided
1176      *                                  quality scores length is smaller
1177      *                                  than 10.
1178      */
1179     public PROSACRobustKnownBiasEasyGyroscopeCalibrator(
1180             final double[] qualityScores,
1181             final List<BodyKinematicsSequence<StandardDeviationTimedBodyKinematics>> sequences,
1182             final boolean commonAxisUsed, final boolean estimateGDependentCrossBiases, final Matrix bias,
1183             final Matrix initialMg, final Matrix initialGg, final Matrix accelerometerBias,
1184             final Matrix accelerometerMa, final RobustKnownBiasEasyGyroscopeCalibratorListener listener) {
1185         super(sequences, commonAxisUsed, estimateGDependentCrossBiases, bias, initialMg, initialGg, accelerometerBias,
1186                 accelerometerMa, listener);
1187         internalSetQualityScores(qualityScores);
1188     }
1189 
1190     /**
1191      * Gets threshold to determine whether samples are inliers or not when testing possible solutions.
1192      * The threshold refers to the amount of error on norm between measured specific forces and the
1193      * ones generated with estimated calibration parameters provided for each sample.
1194      *
1195      * @return threshold to determine whether samples are inliers or not.
1196      */
1197     public double getThreshold() {
1198         return threshold;
1199     }
1200 
1201     /**
1202      * Sets threshold to determine whether samples are inliers or not when testing possible solutions.
1203      * The threshold refers to the amount of error on norm between measured specific forces and the
1204      * ones generated with estimated calibration parameters provided for each sample.
1205      *
1206      * @param threshold threshold to determine whether samples are inliers or not.
1207      * @throws IllegalArgumentException if provided value is equal or less than zero.
1208      * @throws LockedException          if calibrator is currently running.
1209      */
1210     public void setThreshold(final double threshold) throws LockedException {
1211         if (running) {
1212             throw new LockedException();
1213         }
1214         if (threshold <= MIN_THRESHOLD) {
1215             throw new IllegalArgumentException();
1216         }
1217         this.threshold = threshold;
1218     }
1219 
1220     /**
1221      * Returns quality scores corresponding to each provided sequence.
1222      * The larger the score value the better the quality of the sequence.
1223      *
1224      * @return quality scores corresponding to each sample.
1225      */
1226     @Override
1227     public double[] getQualityScores() {
1228         return qualityScores;
1229     }
1230 
1231     /**
1232      * Sets quality scores corresponding to each provided sequence.
1233      * The larger the score value the better the quality of the sequence.
1234      *
1235      * @param qualityScores quality scores corresponding to each sequence.
1236      * @throws IllegalArgumentException if provided quality scores length
1237      *                                  is smaller than minimum required samples.
1238      * @throws LockedException          if calibrator is currently running.
1239      */
1240     @Override
1241     public void setQualityScores(final double[] qualityScores) throws LockedException {
1242         if (running) {
1243             throw new LockedException();
1244         }
1245         internalSetQualityScores(qualityScores);
1246     }
1247 
1248     /**
1249      * Indicates whether calibrator is ready to find a solution.
1250      *
1251      * @return true if calibrator is ready, false otherwise.
1252      */
1253     @Override
1254     public boolean isReady() {
1255         return super.isReady() && qualityScores != null && qualityScores.length == sequences.size();
1256     }
1257 
1258     /**
1259      * Indicates whether inliers must be computed and kept.
1260      *
1261      * @return true if inliers must be computed and kept, false if inliers
1262      * only need to be computed but not kept.
1263      */
1264     public boolean isComputeAndKeepInliersEnabled() {
1265         return computeAndKeepInliers;
1266     }
1267 
1268     /**
1269      * Specifies whether inliers must be computed and kept.
1270      *
1271      * @param computeAndKeepInliers true if inliers must be computed and kept,
1272      *                              false if inliers only need to be computed but not kept.
1273      * @throws LockedException if calibrator is currently running.
1274      */
1275     public void setComputeAndKeepInliersEnabled(final boolean computeAndKeepInliers) throws LockedException {
1276         if (running) {
1277             throw new LockedException();
1278         }
1279         this.computeAndKeepInliers = computeAndKeepInliers;
1280     }
1281 
1282     /**
1283      * Indicates whether residuals must be computed and kept.
1284      *
1285      * @return true if residuals must be computed and kept, false if residuals
1286      * only need to be computed but not kept.
1287      */
1288     public boolean isComputeAndKeepResiduals() {
1289         return computeAndKeepResiduals;
1290     }
1291 
1292     /**
1293      * Specifies whether residuals must be computed and kept.
1294      *
1295      * @param computeAndKeepResiduals true if residuals must be computed and kept,
1296      *                                false if residuals only need to be computed but not kept.
1297      * @throws LockedException if calibrator is currently running.
1298      */
1299     public void setComputeAndKeepResidualsEnabled(final boolean computeAndKeepResiduals) throws LockedException {
1300         if (running) {
1301             throw new LockedException();
1302         }
1303         this.computeAndKeepResiduals = computeAndKeepResiduals;
1304     }
1305 
1306     /**
1307      * Estimates gyroscope calibration parameters containing scale factors,
1308      * cross-coupling errors and G-dependent coupling.
1309      *
1310      * @throws LockedException      if calibrator is currently running.
1311      * @throws NotReadyException    if calibrator is not ready.
1312      * @throws CalibrationException if estimation fails for numerical reasons.
1313      */
1314     @SuppressWarnings("DuplicatedCode")
1315     @Override
1316     public void calibrate() throws LockedException, NotReadyException, CalibrationException {
1317         if (running) {
1318             throw new LockedException();
1319         }
1320         if (!isReady()) {
1321             throw new NotReadyException();
1322         }
1323 
1324         final var innerEstimator = new PROSACRobustEstimator<>(new PROSACRobustEstimatorListener<PreliminaryResult>() {
1325             @Override
1326             public double[] getQualityScores() {
1327                 return qualityScores;
1328             }
1329 
1330             @Override
1331             public double getThreshold() {
1332                 return threshold;
1333             }
1334 
1335             @Override
1336             public int getTotalSamples() {
1337                 return sequences.size();
1338             }
1339 
1340             @Override
1341             public int getSubsetSize() {
1342                 return preliminarySubsetSize;
1343             }
1344 
1345             @Override
1346             public void estimatePreliminarSolutions(
1347                     final int[] samplesIndices, final List<PreliminaryResult> solutions) {
1348                 computePreliminarySolutions(samplesIndices, solutions);
1349             }
1350 
1351             @Override
1352             public double computeResidual(final PreliminaryResult currentEstimation, final int i) {
1353                 return computeError(sequences.get(i), currentEstimation);
1354             }
1355 
1356             @Override
1357             public boolean isReady() {
1358                 return PROSACRobustKnownBiasEasyGyroscopeCalibrator.this.isReady();
1359             }
1360 
1361             @Override
1362             public void onEstimateStart(final RobustEstimator<PreliminaryResult> estimator) {
1363                 // no action needed
1364             }
1365 
1366             @Override
1367             public void onEstimateEnd(final RobustEstimator<PreliminaryResult> estimator) {
1368                 // no action needed
1369             }
1370 
1371             @Override
1372             public void onEstimateNextIteration(
1373                     final RobustEstimator<PreliminaryResult> estimator, final int iteration) {
1374                 if (listener != null) {
1375                     listener.onCalibrateNextIteration(
1376                             PROSACRobustKnownBiasEasyGyroscopeCalibrator.this, iteration);
1377                 }
1378             }
1379 
1380             @Override
1381             public void onEstimateProgressChange(
1382                     final RobustEstimator<PreliminaryResult> estimator, final float progress) {
1383                 if (listener != null) {
1384                     listener.onCalibrateProgressChange(
1385                             PROSACRobustKnownBiasEasyGyroscopeCalibrator.this, progress);
1386                 }
1387             }
1388         });
1389 
1390         try {
1391             running = true;
1392 
1393             if (listener != null) {
1394                 listener.onCalibrateStart(this);
1395             }
1396 
1397             setupAccelerationFixer();
1398 
1399             inliersData = null;
1400             innerEstimator.setComputeAndKeepInliersEnabled(computeAndKeepInliers || refineResult);
1401             innerEstimator.setComputeAndKeepResidualsEnabled(computeAndKeepResiduals || refineResult);
1402             innerEstimator.setConfidence(confidence);
1403             innerEstimator.setMaxIterations(maxIterations);
1404             innerEstimator.setProgressDelta(progressDelta);
1405             final var preliminaryResult = innerEstimator.estimate();
1406             inliersData = innerEstimator.getInliersData();
1407 
1408             attemptRefine(preliminaryResult);
1409 
1410             if (listener != null) {
1411                 listener.onCalibrateEnd(this);
1412             }
1413 
1414         } catch (final com.irurueta.numerical.LockedException e) {
1415             throw new LockedException(e);
1416         } catch (final com.irurueta.numerical.NotReadyException e) {
1417             throw new NotReadyException(e);
1418         } catch (final RobustEstimatorException | AlgebraException e) {
1419             throw new CalibrationException(e);
1420         } finally {
1421             running = false;
1422         }
1423     }
1424 
1425     /**
1426      * Returns method being used for robust estimation.
1427      *
1428      * @return method being used for robust estimation.
1429      */
1430     @Override
1431     public RobustEstimatorMethod getMethod() {
1432         return RobustEstimatorMethod.PROSAC;
1433     }
1434 
1435     /**
1436      * Indicates whether this calibrator requires quality scores for each
1437      * measurement/sequence or not.
1438      *
1439      * @return true if quality scores are required, false otherwise.
1440      */
1441     @Override
1442     public boolean isQualityScoresRequired() {
1443         return true;
1444     }
1445 
1446     /**
1447      * Sets quality scores corresponding to each provided sample.
1448      * This method is used internally and does not check whether instance is
1449      * locked or not.
1450      *
1451      * @param qualityScores quality scores to be set.
1452      * @throws IllegalArgumentException if provided quality scores length
1453      *                                  is smaller than 4 samples.
1454      */
1455     private void internalSetQualityScores(final double[] qualityScores) {
1456         if (qualityScores == null || qualityScores.length < EasyGyroscopeCalibrator.MINIMUM_SEQUENCES_COMMON_Z_AXIS) {
1457             throw new IllegalArgumentException();
1458         }
1459 
1460         this.qualityScores = qualityScores;
1461     }
1462 }