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