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.navigation.LockedException;
20 import com.irurueta.navigation.NotReadyException;
21 import com.irurueta.navigation.inertial.calibration.CalibrationException;
22 import com.irurueta.navigation.inertial.calibration.StandardDeviationFrameBodyKinematics;
23 import com.irurueta.numerical.robust.PROMedSRobustEstimator;
24 import com.irurueta.numerical.robust.PROMedSRobustEstimatorListener;
25 import com.irurueta.numerical.robust.RobustEstimator;
26 import com.irurueta.numerical.robust.RobustEstimatorException;
27 import com.irurueta.numerical.robust.RobustEstimatorMethod;
28 import com.irurueta.units.AngularSpeed;
29
30 import java.util.List;
31
32 /**
33 * Robustly estimates gyroscope cross couplings and scaling factors
34 * along with G-dependent cross biases introduced on the gyroscope by the
35 * specific forces sensed by the accelerometer using a PROMedS algorithm to discard
36 * outliers.
37 * This estimator assumes that biases are known.
38 * <p>
39 * To use this calibrator at least 6 measurements at different known frames must
40 * be provided. In other words, accelerometer and gyroscope (i.e. body kinematics)
41 * samples must be obtained at 6 different positions, orientations and velocities
42 * (although typically velocities are always zero).
43 * <p>
44 * Measured gyroscope angular rates is assumed to follow the model shown below:
45 * <pre>
46 * Ωmeas = bg + (I + Mg) * Ωtrue + Gg * ftrue + w
47 * </pre>
48 * Where:
49 * - Ωmeas is the measured gyroscope angular rates. This is a 3x1 vector.
50 * - bg is the gyroscope bias. Ideally, on a perfect gyroscope, this should be a
51 * 3x1 zero vector.
52 * - I is the 3x3 identity matrix.
53 * - Mg is the 3x3 matrix containing cross-couplings and scaling factors. Ideally, on
54 * a perfect gyroscope, this should be a 3x3 zero matrix.
55 * - Ωtrue is ground-truth gyroscope angular rates.
56 * - Gg is the G-dependent cross biases introduced by the specific forces sensed
57 * by the accelerometer. Ideally, on a perfect gyroscope, this should be a 3x3
58 * zero matrix.
59 * - ftrue is ground-truth specific force. This is a 3x1 vector.
60 * - w is measurement noise. This is a 3x1 vector.
61 */
62 public class PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator extends RobustKnownBiasAndFrameGyroscopeCalibrator {
63
64 /**
65 * Default value to be used for stop threshold. Stop threshold can be used to
66 * avoid keeping the algorithm unnecessarily iterating in case that best
67 * estimated threshold using median of residuals is not small enough. Once a
68 * solution is found that generates a threshold below this value, the
69 * algorithm will stop.
70 * The stop threshold can be used to prevent the LMedS algorithm iterating
71 * too many times in cases where samples have a very similar accuracy.
72 * For instance, in cases where proportion of outliers is very small (close
73 * to 0%), and samples are very accurate (i.e. 1e-6), the algorithm would
74 * iterate for a long time trying to find the best solution when indeed
75 * there is no need to do that if a reasonable threshold has already been
76 * reached.
77 * Because of this behaviour the stop threshold can be set to a value much
78 * lower than the one typically used in RANSAC, and yet the algorithm could
79 * still produce even smaller thresholds in estimated results.
80 */
81 public static final double DEFAULT_STOP_THRESHOLD = 1e-5;
82
83 /**
84 * Minimum allowed stop threshold value.
85 */
86 public static final double MIN_STOP_THRESHOLD = 0.0;
87
88 /**
89 * Threshold to be used to keep the algorithm iterating in case that best
90 * estimated threshold using median of residuals is not small enough. Once
91 * a solution is found that generates a threshold below this value, the
92 * algorithm will stop.
93 * The stop threshold can be used to prevent the LMedS algorithm iterating
94 * too many times in cases where samples have a very similar accuracy.
95 * For instance, in cases where proportion of outliers is very small (close
96 * to 0%), and samples are very accurate (i.e. 1e-6), the algorithm would
97 * iterate for a long time trying to find the best solution when indeed
98 * there is no need to do that if a reasonable threshold has already been
99 * reached.
100 * Because of this behaviour the stop threshold can be set to a value much
101 * lower than the one typically used in RANSAC, and yet the algorithm could
102 * still produce even smaller thresholds in estimated results.
103 */
104 private double stopThreshold = DEFAULT_STOP_THRESHOLD;
105
106 /**
107 * Quality scores corresponding to each provided sample.
108 * The larger the score value the better the quality of the sample.
109 */
110 private double[] qualityScores;
111
112 /**
113 * Constructor.
114 */
115 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator() {
116 super();
117 }
118
119 /**
120 * Constructor.
121 *
122 * @param listener listener to be notified of events such as when estimation
123 * starts, ends or its progress significantly changes.
124 */
125 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
126 final RobustKnownBiasAndFrameGyroscopeCalibratorListener listener) {
127 super(listener);
128 }
129
130 /**
131 * Constructor.
132 *
133 * @param measurements list of body kinematics measurements with standard
134 * deviations taken at different frames (positions, orientations
135 * and velocities).
136 */
137 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
138 final List<StandardDeviationFrameBodyKinematics> measurements) {
139 super(measurements);
140 }
141
142 /**
143 * Constructor.
144 *
145 * @param measurements list of body kinematics measurements with standard
146 * deviations taken at different frames (positions, orientations
147 * and velocities).
148 * @param listener listener to handle events raised by this calibrator.
149 */
150 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
151 final List<StandardDeviationFrameBodyKinematics> measurements,
152 final RobustKnownBiasAndFrameGyroscopeCalibratorListener listener) {
153 super(measurements, listener);
154 }
155
156 /**
157 * Constructor.
158 *
159 * @param commonAxisUsed indicates whether z-axis is assumed to be common for
160 * accelerometer and gyroscope.
161 */
162 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(final boolean commonAxisUsed) {
163 super(commonAxisUsed);
164 }
165
166 /**
167 * Constructor.
168 *
169 * @param commonAxisUsed indicates whether z-axis is assumed to be common for
170 * accelerometer and gyroscope.
171 * @param listener listener to handle events raised by this calibrator.
172 */
173 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
174 final boolean commonAxisUsed, final RobustKnownBiasAndFrameGyroscopeCalibratorListener listener) {
175 super(commonAxisUsed, listener);
176 }
177
178 /**
179 * Constructor.
180 *
181 * @param measurements list of body kinematics measurements with standard
182 * deviations taken at different frames (positions, orientations
183 * and velocities).
184 * @param commonAxisUsed indicates whether z-axis is assumed to be common for
185 * accelerometer and gyroscope.
186 */
187 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
188 final List<StandardDeviationFrameBodyKinematics> measurements, final boolean commonAxisUsed) {
189 super(measurements, commonAxisUsed);
190 }
191
192 /**
193 * Constructor.
194 *
195 * @param measurements list of body kinematics measurements with standard
196 * deviations taken at different frames (positions, orientations
197 * and velocities).
198 * @param commonAxisUsed indicates whether z-axis is assumed to be common for
199 * accelerometer and gyroscope.
200 * @param listener listener to handle events raised by this calibrator.
201 */
202 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
203 final List<StandardDeviationFrameBodyKinematics> measurements, final boolean commonAxisUsed,
204 final RobustKnownBiasAndFrameGyroscopeCalibratorListener listener) {
205 super(measurements, commonAxisUsed, listener);
206 }
207
208 /**
209 * Constructor.
210 *
211 * @param biasX known x coordinate of gyroscope bias expressed in radians per
212 * second (rad/s).
213 * @param biasY known y coordinate of gyroscope bias expressed in radians per
214 * second (rad/s).
215 * @param biasZ known z coordinate of gyroscope bias expressed in radians per
216 * second (rad/s).
217 */
218 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
219 final double biasX, final double biasY, final double biasZ) {
220 super(biasX, biasY, biasZ);
221 }
222
223 /**
224 * Constructor.
225 *
226 * @param biasX known x coordinate of gyroscope bias expressed in radians per
227 * second (rad/s).
228 * @param biasY known y coordinate of gyroscope bias expressed in radians per
229 * second (rad/s).
230 * @param biasZ known z coordinate of gyroscope bias expressed in radians per
231 * second (rad/s).
232 * @param listener listener to be notified of events such as when estimation
233 * starts, ends or its progress significantly changes.
234 */
235 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
236 final double biasX, final double biasY, final double biasZ,
237 final RobustKnownBiasAndFrameGyroscopeCalibratorListener listener) {
238 super(biasX, biasY, biasZ, listener);
239 }
240
241 /**
242 * Constructor.
243 *
244 * @param measurements list of body kinematics measurements with standard
245 * deviations taken at different frames (positions, orientations
246 * and velocities).
247 * @param biasX known x coordinate of gyroscope bias expressed in radians per
248 * second (rad/s).
249 * @param biasY known y coordinate of gyroscope bias expressed in radians per
250 * second (rad/s).
251 * @param biasZ known z coordinate of gyroscope bias expressed in radians per
252 * second (rad/s).
253 */
254 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
255 final List<StandardDeviationFrameBodyKinematics> measurements,
256 final double biasX, final double biasY, final double biasZ) {
257 super(measurements, biasX, biasY, biasZ);
258 }
259
260 /**
261 * Constructor.
262 *
263 * @param measurements list of body kinematics measurements with standard
264 * deviations taken at different frames (positions, orientations
265 * and velocities).
266 * @param biasX known x coordinate of gyroscope bias expressed in radians per
267 * second (rad/s).
268 * @param biasY known y coordinate of gyroscope bias expressed in radians per
269 * second (rad/s).
270 * @param biasZ known z coordinate of gyroscope bias expressed in radians per
271 * second (rad/s).
272 * @param listener listener to handle events raised by this calibrator.
273 */
274 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
275 final List<StandardDeviationFrameBodyKinematics> measurements,
276 final double biasX, final double biasY, final double biasZ,
277 final RobustKnownBiasAndFrameGyroscopeCalibratorListener listener) {
278 super(measurements, biasX, biasY, biasZ, listener);
279 }
280
281 /**
282 * Constructor.
283 *
284 * @param biasX known x coordinate of gyroscope bias expressed in radians per
285 * second (rad/s).
286 * @param biasY known y coordinate of gyroscope bias expressed in radians per
287 * second (rad/s).
288 * @param biasZ known z coordinate of gyroscope bias expressed in radians per
289 * second (rad/s).
290 * @param commonAxisUsed indicates whether z-axis is assumed to be common for
291 * accelerometer and gyroscope.
292 */
293 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
294 final double biasX, final double biasY, final double biasZ, final boolean commonAxisUsed) {
295 super(biasX, biasY, biasZ, commonAxisUsed);
296 }
297
298 /**
299 * Constructor.
300 *
301 * @param biasX known x coordinate of gyroscope bias expressed in radians per
302 * second (rad/s).
303 * @param biasY known y coordinate of gyroscope bias expressed in radians per
304 * second (rad/s).
305 * @param biasZ known z coordinate of gyroscope bias expressed in radians per
306 * second (rad/s).
307 * @param commonAxisUsed indicates whether z-axis is assumed to be common for
308 * accelerometer and gyroscope.
309 * @param listener listener to handle events raised by this calibrator.
310 */
311 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
312 final double biasX, final double biasY, final double biasZ, final boolean commonAxisUsed,
313 final RobustKnownBiasAndFrameGyroscopeCalibratorListener listener) {
314 super(biasX, biasY, biasZ, commonAxisUsed, listener);
315 }
316
317 /**
318 * Constructor.
319 *
320 * @param measurements list of body kinematics measurements with standard
321 * deviations taken at different frames (positions, orientations
322 * and velocities).
323 * @param biasX known x coordinate of gyroscope bias expressed in radians per
324 * second (rad/s).
325 * @param biasY known y coordinate of gyroscope bias expressed in radians per
326 * second (rad/s).
327 * @param biasZ known z coordinate of gyroscope bias expressed in radians per
328 * second (rad/s).
329 * @param commonAxisUsed indicates whether z-axis is assumed to be common for
330 * accelerometer and gyroscope.
331 */
332 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
333 final List<StandardDeviationFrameBodyKinematics> measurements,
334 final double biasX, final double biasY, final double biasZ, final boolean commonAxisUsed) {
335 super(measurements, biasX, biasY, biasZ, commonAxisUsed);
336 }
337
338 /**
339 * Constructor.
340 *
341 * @param measurements list of body kinematics measurements with standard
342 * deviations taken at different frames (positions, orientations
343 * and velocities).
344 * @param biasX known x coordinate of gyroscope bias expressed in radians per
345 * second (rad/s).
346 * @param biasY known y coordinate of gyroscope bias expressed in radians per
347 * second (rad/s).
348 * @param biasZ known z coordinate of gyroscope bias expressed in radians per
349 * second (rad/s).
350 * @param commonAxisUsed indicates whether z-axis is assumed to be common for
351 * accelerometer and gyroscope.
352 * @param listener listener to handle events raised by this calibrator.
353 */
354 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
355 final List<StandardDeviationFrameBodyKinematics> measurements,
356 final double biasX, final double biasY, final double biasZ, final boolean commonAxisUsed,
357 final RobustKnownBiasAndFrameGyroscopeCalibratorListener listener) {
358 super(measurements, biasX, biasY, biasZ, commonAxisUsed, listener);
359 }
360
361 /**
362 * Constructor.
363 *
364 * @param biasX known x coordinate of gyroscope bias.
365 * @param biasY known y coordinate of gyroscope bias.
366 * @param biasZ known z coordinate of gyroscope bias.
367 */
368 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
369 final AngularSpeed biasX, final AngularSpeed biasY, final AngularSpeed biasZ) {
370 super(biasX, biasY, biasZ);
371 }
372
373 /**
374 * Constructor.
375 *
376 * @param biasX known x coordinate of gyroscope bias.
377 * @param biasY known y coordinate of gyroscope bias.
378 * @param biasZ known z coordinate of gyroscope bias.
379 * @param listener listener to be notified of events such as when estimation
380 * starts, ends or its progress significantly changes.
381 */
382 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
383 final AngularSpeed biasX, final AngularSpeed biasY, final AngularSpeed biasZ,
384 final RobustKnownBiasAndFrameGyroscopeCalibratorListener listener) {
385 super(biasX, biasY, biasZ, listener);
386 }
387
388 /**
389 * Constructor.
390 *
391 * @param measurements list of body kinematics measurements with standard
392 * deviations taken at different frames (positions, orientations
393 * and velocities).
394 * @param biasX known x coordinate of gyroscope bias.
395 * @param biasY known y coordinate of gyroscope bias.
396 * @param biasZ known z coordinate of gyroscope bias.
397 */
398 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
399 final List<StandardDeviationFrameBodyKinematics> measurements,
400 final AngularSpeed biasX, final AngularSpeed biasY, final AngularSpeed biasZ) {
401 super(measurements, biasX, biasY, biasZ);
402 }
403
404 /**
405 * Constructor.
406 *
407 * @param measurements list of body kinematics measurements with standard
408 * deviations taken at different frames (positions, orientations
409 * and velocities).
410 * @param biasX known x coordinate of gyroscope bias.
411 * @param biasY known y coordinate of gyroscope bias.
412 * @param biasZ known z coordinate of gyroscope bias.
413 * @param listener listener to handle events raised by this calibrator.
414 */
415 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
416 final List<StandardDeviationFrameBodyKinematics> measurements,
417 final AngularSpeed biasX, final AngularSpeed biasY, final AngularSpeed biasZ,
418 final RobustKnownBiasAndFrameGyroscopeCalibratorListener listener) {
419 super(measurements, biasX, biasY, biasZ, listener);
420 }
421
422 /**
423 * Constructor.
424 *
425 * @param biasX known x coordinate of gyroscope bias.
426 * @param biasY known y coordinate of gyroscope bias.
427 * @param biasZ known z coordinate of gyroscope bias.
428 * @param commonAxisUsed indicates whether z-axis is assumed to be common for
429 * accelerometer and gyroscope.
430 */
431 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
432 final AngularSpeed biasX, final AngularSpeed biasY, final AngularSpeed biasZ,
433 final boolean commonAxisUsed) {
434 super(biasX, biasY, biasZ, commonAxisUsed);
435 }
436
437 /**
438 * Constructor.
439 *
440 * @param biasX known x coordinate of gyroscope bias.
441 * @param biasY known y coordinate of gyroscope bias.
442 * @param biasZ known z coordinate of gyroscope bias.
443 * @param commonAxisUsed indicates whether z-axis is assumed to be common for
444 * accelerometer and gyroscope.
445 * @param listener listener to handle events raised by this calibrator.
446 */
447 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
448 final AngularSpeed biasX, final AngularSpeed biasY, final AngularSpeed biasZ, final boolean commonAxisUsed,
449 final RobustKnownBiasAndFrameGyroscopeCalibratorListener listener) {
450 super(biasX, biasY, biasZ, commonAxisUsed, listener);
451 }
452
453 /**
454 * Constructor.
455 *
456 * @param measurements list of body kinematics measurements with standard
457 * deviations taken at different frames (positions, orientations
458 * and velocities).
459 * @param biasX known x coordinate of gyroscope bias.
460 * @param biasY known y coordinate of gyroscope bias.
461 * @param biasZ known z coordinate of gyroscope bias.
462 * @param commonAxisUsed indicates whether z-axis is assumed to be common for
463 * accelerometer and gyroscope.
464 */
465 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
466 final List<StandardDeviationFrameBodyKinematics> measurements,
467 final AngularSpeed biasX, final AngularSpeed biasY, final AngularSpeed biasZ,
468 final boolean commonAxisUsed) {
469 super(measurements, biasX, biasY, biasZ, commonAxisUsed);
470 }
471
472 /**
473 * Constructor.
474 *
475 * @param measurements list of body kinematics measurements with standard
476 * deviations taken at different frames (positions, orientations
477 * and velocities).
478 * @param biasX known x coordinate of gyroscope bias.
479 * @param biasY known y coordinate of gyroscope bias.
480 * @param biasZ known z coordinate of gyroscope bias.
481 * @param commonAxisUsed indicates whether z-axis is assumed to be common for
482 * accelerometer and gyroscope.
483 * @param listener listener to handle events raised by this calibrator.
484 */
485 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
486 final List<StandardDeviationFrameBodyKinematics> measurements,
487 final AngularSpeed biasX, final AngularSpeed biasY, final AngularSpeed biasZ, final boolean commonAxisUsed,
488 final RobustKnownBiasAndFrameGyroscopeCalibratorListener listener) {
489 super(measurements, biasX, biasY, biasZ, commonAxisUsed, listener);
490 }
491
492 /**
493 * Constructor.
494 *
495 * @param bias known gyroscope bias.
496 * @throws IllegalArgumentException if provided array does not have length 3.
497 */
498 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(final double[] bias) {
499 super(bias);
500 }
501
502 /**
503 * Constructor.
504 *
505 * @param bias known gyroscope bias.
506 * @param listener listener to be notified of events such as when estimation
507 * starts, ends or its progress significantly changes.
508 * @throws IllegalArgumentException if provided array does not have length 3.
509 */
510 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
511 final double[] bias, final RobustKnownBiasAndFrameGyroscopeCalibratorListener listener) {
512 super(bias, listener);
513 }
514
515 /**
516 * Constructor.
517 *
518 * @param measurements list of body kinematics measurements with standard
519 * deviations taken at different frames (positions, orientations
520 * and velocities).
521 * @param bias known gyroscope bias.
522 * @throws IllegalArgumentException if provided array does not have length 3.
523 */
524 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
525 final List<StandardDeviationFrameBodyKinematics> measurements, final double[] bias) {
526 super(measurements, bias);
527 }
528
529 /**
530 * Constructor.
531 *
532 * @param measurements list of body kinematics measurements with standard
533 * deviations taken at different frames (positions, orientations
534 * and velocities).
535 * @param bias known gyroscope bias.
536 * @param listener listener to handle events raised by this calibrator.
537 * @throws IllegalArgumentException if provided array does not have length 3.
538 */
539 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
540 final List<StandardDeviationFrameBodyKinematics> measurements, final double[] bias,
541 final RobustKnownBiasAndFrameGyroscopeCalibratorListener listener) {
542 super(measurements, bias, listener);
543 }
544
545 /**
546 * Constructor.
547 *
548 * @param bias known gyroscope bias.
549 * @param commonAxisUsed indicates whether z-axis is assumed to be common for
550 * accelerometer and gyroscope.
551 * @throws IllegalArgumentException if provided array does not have length 3.
552 */
553 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(final double[] bias, final boolean commonAxisUsed) {
554 super(bias, commonAxisUsed);
555 }
556
557 /**
558 * Constructor.
559 *
560 * @param bias known gyroscope bias.
561 * @param commonAxisUsed indicates whether z-axis is assumed to be common for
562 * accelerometer and gyroscope.
563 * @param listener listener to handle events raised by this calibrator.
564 * @throws IllegalArgumentException if provided array does not have length 3.
565 */
566 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
567 final double[] bias, final boolean commonAxisUsed,
568 final RobustKnownBiasAndFrameGyroscopeCalibratorListener listener) {
569 super(bias, commonAxisUsed, listener);
570 }
571
572 /**
573 * Constructor.
574 *
575 * @param measurements list of body kinematics measurements with standard
576 * deviations taken at different frames (positions, orientations
577 * and velocities).
578 * @param bias known gyroscope bias.
579 * @param commonAxisUsed indicates whether z-axis is assumed to be common for
580 * accelerometer and gyroscope.
581 * @throws IllegalArgumentException if provided array does not have length 3.
582 */
583 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
584 final List<StandardDeviationFrameBodyKinematics> measurements, final double[] bias,
585 final boolean commonAxisUsed) {
586 super(measurements, bias, commonAxisUsed);
587 }
588
589 /**
590 * Constructor.
591 *
592 * @param measurements list of body kinematics measurements with standard
593 * deviations taken at different frames (positions, orientations
594 * and velocities).
595 * @param bias known gyroscope bias.
596 * @param commonAxisUsed indicates whether z-axis is assumed to be common for
597 * accelerometer and gyroscope.
598 * @param listener listener to handle events raised by this calibrator.
599 * @throws IllegalArgumentException if provided array does not have length 3.
600 */
601 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
602 final List<StandardDeviationFrameBodyKinematics> measurements,
603 final double[] bias, final boolean commonAxisUsed,
604 final RobustKnownBiasAndFrameGyroscopeCalibratorListener listener) {
605 super(measurements, bias, commonAxisUsed, listener);
606 }
607
608 /**
609 * Constructor.
610 *
611 * @param bias known gyroscope bias.
612 * @throws IllegalArgumentException if provided matrix is not 3x1.
613 */
614 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(final Matrix bias) {
615 super(bias);
616 }
617
618 /**
619 * Constructor.
620 *
621 * @param bias known gyroscope bias.
622 * @param listener listener to be notified of events such as when estimation
623 * starts, ends or its progress significantly changes.
624 * @throws IllegalArgumentException if provided matrix is not 3x1.
625 */
626 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
627 final Matrix bias, final RobustKnownBiasAndFrameGyroscopeCalibratorListener listener) {
628 super(bias, listener);
629 }
630
631 /**
632 * Constructor.
633 *
634 * @param measurements list of body kinematics measurements with standard
635 * deviations taken at different frames (positions, orientations
636 * and velocities).
637 * @param bias known gyroscope bias.
638 * @throws IllegalArgumentException if provided matrix is not 3x1.
639 */
640 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
641 final List<StandardDeviationFrameBodyKinematics> measurements, final Matrix bias) {
642 super(measurements, bias);
643 }
644
645 /**
646 * Constructor.
647 *
648 * @param measurements list of body kinematics measurements with standard
649 * deviations taken at different frames (positions, orientations
650 * and velocities).
651 * @param bias known gyroscope bias.
652 * @param listener listener to handle events raised by this calibrator.
653 * @throws IllegalArgumentException if provided matrix is not 3x1.
654 */
655 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
656 final List<StandardDeviationFrameBodyKinematics> measurements, final Matrix bias,
657 final RobustKnownBiasAndFrameGyroscopeCalibratorListener listener) {
658 super(measurements, bias, listener);
659 }
660
661 /**
662 * Constructor.
663 *
664 * @param bias known gyroscope bias.
665 * @param commonAxisUsed indicates whether z-axis is assumed to be common for
666 * accelerometer and gyroscope.
667 * @throws IllegalArgumentException if provided matrix is not 3x1.
668 */
669 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(final Matrix bias, final boolean commonAxisUsed) {
670 super(bias, commonAxisUsed);
671 }
672
673 /**
674 * Constructor.
675 *
676 * @param bias known gyroscope bias.
677 * @param commonAxisUsed indicates whether z-axis is assumed to be common for
678 * accelerometer and gyroscope.
679 * @param listener listener to handle events raised by this calibrator.
680 * @throws IllegalArgumentException if provided matrix is not 3x1.
681 */
682 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
683 final Matrix bias, final boolean commonAxisUsed,
684 final RobustKnownBiasAndFrameGyroscopeCalibratorListener listener) {
685 super(bias, commonAxisUsed, listener);
686 }
687
688 /**
689 * Constructor.
690 *
691 * @param measurements list of body kinematics measurements with standard
692 * deviations taken at different frames (positions, orientations
693 * and velocities).
694 * @param bias known gyroscope bias.
695 * @param commonAxisUsed indicates whether z-axis is assumed to be common for
696 * accelerometer and gyroscope.
697 * @throws IllegalArgumentException if provided matrix is not 3x1.
698 */
699 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
700 final List<StandardDeviationFrameBodyKinematics> measurements, final Matrix bias,
701 final boolean commonAxisUsed) {
702 super(measurements, bias, commonAxisUsed);
703 }
704
705 /**
706 * Constructor.
707 *
708 * @param measurements list of body kinematics measurements with standard
709 * deviations taken at different frames (positions, orientations
710 * and velocities).
711 * @param bias known gyroscope bias.
712 * @param commonAxisUsed indicates whether z-axis is assumed to be common for
713 * accelerometer and gyroscope.
714 * @param listener listener to handle events raised by this calibrator.
715 * @throws IllegalArgumentException if provided matrix is not 3x1.
716 */
717 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
718 final List<StandardDeviationFrameBodyKinematics> measurements,
719 final Matrix bias, final boolean commonAxisUsed,
720 final RobustKnownBiasAndFrameGyroscopeCalibratorListener listener) {
721 super(measurements, bias, commonAxisUsed, listener);
722 }
723
724 /**
725 * Constructor.
726 *
727 * @param qualityScores quality scores corresponding to each provided
728 * measurement. The larger the score value the better
729 * the quality of the sample.
730 * @param measurements list of body kinematics measurements with standard
731 * deviations taken at different frames (positions, orientations
732 * and velocities).
733 * @throws IllegalArgumentException if provided quality scores length
734 * is smaller than 6 samples.
735 */
736 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
737 final double[] qualityScores, final List<StandardDeviationFrameBodyKinematics> measurements) {
738 super(measurements);
739 internalSetQualityScores(qualityScores);
740 }
741
742 /**
743 * Constructor.
744 *
745 * @param qualityScores quality scores corresponding to each provided
746 * measurement. The larger the score value the better
747 * the quality of the sample.
748 * @param measurements list of body kinematics measurements with standard
749 * deviations taken at different frames (positions, orientations
750 * and velocities).
751 * @param listener listener to handle events raised by this calibrator.
752 * @throws IllegalArgumentException if provided quality scores length
753 * is smaller than 6 samples.
754 */
755 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
756 final double[] qualityScores, final List<StandardDeviationFrameBodyKinematics> measurements,
757 final RobustKnownBiasAndFrameGyroscopeCalibratorListener listener) {
758 super(measurements, listener);
759 internalSetQualityScores(qualityScores);
760 }
761
762 /**
763 * Constructor.
764 *
765 * @param qualityScores quality scores corresponding to each provided
766 * measurement. The larger the score value the better
767 * the quality of the sample.
768 * @param measurements list of body kinematics measurements with standard
769 * deviations taken at different frames (positions, orientations
770 * and velocities).
771 * @param commonAxisUsed indicates whether z-axis is assumed to be common for
772 * accelerometer and gyroscope.
773 * @throws IllegalArgumentException if provided quality scores length
774 * is smaller than 6 samples.
775 */
776 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
777 final double[] qualityScores, final List<StandardDeviationFrameBodyKinematics> measurements,
778 final boolean commonAxisUsed) {
779 super(measurements, commonAxisUsed);
780 internalSetQualityScores(qualityScores);
781 }
782
783 /**
784 * Constructor.
785 *
786 * @param qualityScores quality scores corresponding to each provided
787 * measurement. The larger the score value the better
788 * the quality of the sample.
789 * @param measurements list of body kinematics measurements with standard
790 * deviations taken at different frames (positions, orientations
791 * and velocities).
792 * @param commonAxisUsed indicates whether z-axis is assumed to be common for
793 * accelerometer and gyroscope.
794 * @param listener listener to handle events raised by this calibrator.
795 * @throws IllegalArgumentException if provided quality scores length
796 * is smaller than 6 samples.
797 */
798 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
799 final double[] qualityScores, final List<StandardDeviationFrameBodyKinematics> measurements,
800 final boolean commonAxisUsed, final RobustKnownBiasAndFrameGyroscopeCalibratorListener listener) {
801 super(measurements, commonAxisUsed, listener);
802 internalSetQualityScores(qualityScores);
803 }
804
805 /**
806 * Constructor.
807 *
808 * @param qualityScores quality scores corresponding to each provided
809 * measurement. The larger the score value the better
810 * the quality of the sample.
811 * @param biasX known x coordinate of gyroscope bias expressed in radians per
812 * second (rad/s).
813 * @param biasY known y coordinate of gyroscope bias expressed in radians per
814 * second (rad/s).
815 * @param biasZ known z coordinate of gyroscope bias expressed in radians per
816 * second (rad/s).
817 * @throws IllegalArgumentException if provided quality scores length
818 * is smaller than 6 samples.
819 */
820 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
821 final double[] qualityScores, final double biasX, final double biasY, final double biasZ) {
822 super(biasX, biasY, biasZ);
823 internalSetQualityScores(qualityScores);
824 }
825
826 /**
827 * Constructor.
828 *
829 * @param qualityScores quality scores corresponding to each provided
830 * measurement. The larger the score value the better
831 * the quality of the sample.
832 * @param biasX known x coordinate of gyroscope bias expressed in radians per
833 * second (rad/s).
834 * @param biasY known y coordinate of gyroscope bias expressed in radians per
835 * second (rad/s).
836 * @param biasZ known z coordinate of gyroscope bias expressed in radians per
837 * second (rad/s).
838 * @param listener listener to be notified of events such as when estimation
839 * starts, ends or its progress significantly changes.
840 * @throws IllegalArgumentException if provided quality scores length
841 * is smaller than 6 samples.
842 */
843 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
844 final double[] qualityScores, final double biasX, final double biasY, final double biasZ,
845 final RobustKnownBiasAndFrameGyroscopeCalibratorListener listener) {
846 super(biasX, biasY, biasZ, listener);
847 internalSetQualityScores(qualityScores);
848 }
849
850 /**
851 * Constructor.
852 *
853 * @param qualityScores quality scores corresponding to each provided
854 * measurement. The larger the score value the better
855 * the quality of the sample.
856 * @param measurements list of body kinematics measurements with standard
857 * deviations taken at different frames (positions, orientations
858 * and velocities).
859 * @param biasX known x coordinate of gyroscope bias expressed in radians per
860 * second (rad/s).
861 * @param biasY known y coordinate of gyroscope bias expressed in radians per
862 * second (rad/s).
863 * @param biasZ known z coordinate of gyroscope bias expressed in radians per
864 * second (rad/s).
865 * @throws IllegalArgumentException if provided quality scores length
866 * is smaller than 6 samples.
867 */
868 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
869 final double[] qualityScores, final List<StandardDeviationFrameBodyKinematics> measurements,
870 final double biasX, final double biasY, final double biasZ) {
871 super(measurements, biasX, biasY, biasZ);
872 internalSetQualityScores(qualityScores);
873 }
874
875 /**
876 * Constructor.
877 *
878 * @param qualityScores quality scores corresponding to each provided
879 * measurement. The larger the score value the better
880 * the quality of the sample.
881 * @param measurements list of body kinematics measurements with standard
882 * deviations taken at different frames (positions, orientations
883 * and velocities).
884 * @param biasX known x coordinate of gyroscope bias expressed in radians per
885 * second (rad/s).
886 * @param biasY known y coordinate of gyroscope bias expressed in radians per
887 * second (rad/s).
888 * @param biasZ known z coordinate of gyroscope bias expressed in radians per
889 * second (rad/s).
890 * @param listener listener to handle events raised by this calibrator.
891 * @throws IllegalArgumentException if provided quality scores length
892 * is smaller than 6 samples.
893 */
894 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
895 final double[] qualityScores, final List<StandardDeviationFrameBodyKinematics> measurements,
896 final double biasX, final double biasY, final double biasZ,
897 final RobustKnownBiasAndFrameGyroscopeCalibratorListener listener) {
898 super(measurements, biasX, biasY, biasZ, listener);
899 internalSetQualityScores(qualityScores);
900 }
901
902 /**
903 * Constructor.
904 *
905 * @param qualityScores quality scores corresponding to each provided
906 * measurement. The larger the score value the better
907 * the quality of the sample.
908 * @param biasX known x coordinate of gyroscope bias expressed in radians per
909 * second (rad/s).
910 * @param biasY known y coordinate of gyroscope bias expressed in radians per
911 * second (rad/s).
912 * @param biasZ known z coordinate of gyroscope bias expressed in radians per
913 * second (rad/s).
914 * @param commonAxisUsed indicates whether z-axis is assumed to be common for
915 * accelerometer and gyroscope.
916 * @throws IllegalArgumentException if provided quality scores length
917 * is smaller than 6 samples.
918 */
919 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
920 final double[] qualityScores, final double biasX, final double biasY, final double biasZ,
921 final boolean commonAxisUsed) {
922 super(biasX, biasY, biasZ, commonAxisUsed);
923 internalSetQualityScores(qualityScores);
924 }
925
926 /**
927 * Constructor.
928 *
929 * @param qualityScores quality scores corresponding to each provided
930 * measurement. The larger the score value the better
931 * the quality of the sample.
932 * @param biasX known x coordinate of gyroscope bias expressed in radians per
933 * second (rad/s).
934 * @param biasY known y coordinate of gyroscope bias expressed in radians per
935 * second (rad/s).
936 * @param biasZ known z coordinate of gyroscope bias expressed in radians per
937 * second (rad/s).
938 * @param commonAxisUsed indicates whether z-axis is assumed to be common for
939 * accelerometer and gyroscope.
940 * @param listener listener to handle events raised by this calibrator.
941 * @throws IllegalArgumentException if provided quality scores length
942 * is smaller than 6 samples.
943 */
944 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
945 final double[] qualityScores, final double biasX, final double biasY, final double biasZ,
946 final boolean commonAxisUsed, final RobustKnownBiasAndFrameGyroscopeCalibratorListener listener) {
947 super(biasX, biasY, biasZ, commonAxisUsed, listener);
948 internalSetQualityScores(qualityScores);
949 }
950
951 /**
952 * Constructor.
953 *
954 * @param qualityScores quality scores corresponding to each provided
955 * measurement. The larger the score value the better
956 * the quality of the sample.
957 * @param measurements list of body kinematics measurements with standard
958 * deviations taken at different frames (positions, orientations
959 * and velocities).
960 * @param biasX known x coordinate of gyroscope bias expressed in radians per
961 * second (rad/s).
962 * @param biasY known y coordinate of gyroscope bias expressed in radians per
963 * second (rad/s).
964 * @param biasZ known z coordinate of gyroscope bias expressed in radians per
965 * second (rad/s).
966 * @param commonAxisUsed indicates whether z-axis is assumed to be common for
967 * accelerometer and gyroscope.
968 * @throws IllegalArgumentException if provided quality scores length
969 * is smaller than 6 samples.
970 */
971 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
972 final double[] qualityScores, final List<StandardDeviationFrameBodyKinematics> measurements,
973 final double biasX, final double biasY, final double biasZ, final boolean commonAxisUsed) {
974 super(measurements, biasX, biasY, biasZ, commonAxisUsed);
975 internalSetQualityScores(qualityScores);
976 }
977
978 /**
979 * Constructor.
980 *
981 * @param qualityScores quality scores corresponding to each provided
982 * measurement. The larger the score value the better
983 * the quality of the sample.
984 * @param measurements list of body kinematics measurements with standard
985 * deviations taken at different frames (positions, orientations
986 * and velocities).
987 * @param biasX known x coordinate of gyroscope bias expressed in radians per
988 * second (rad/s).
989 * @param biasY known y coordinate of gyroscope bias expressed in radians per
990 * second (rad/s).
991 * @param biasZ known z coordinate of gyroscope bias expressed in radians per
992 * second (rad/s).
993 * @param commonAxisUsed indicates whether z-axis is assumed to be common for
994 * accelerometer and gyroscope.
995 * @param listener listener to handle events raised by this calibrator.
996 * @throws IllegalArgumentException if provided quality scores length
997 * is smaller than 6 samples.
998 */
999 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
1000 final double[] qualityScores, final List<StandardDeviationFrameBodyKinematics> measurements,
1001 final double biasX, final double biasY, final double biasZ, final boolean commonAxisUsed,
1002 final RobustKnownBiasAndFrameGyroscopeCalibratorListener listener) {
1003 super(measurements, biasX, biasY, biasZ, commonAxisUsed, listener);
1004 internalSetQualityScores(qualityScores);
1005 }
1006
1007 /**
1008 * Constructor.
1009 *
1010 * @param qualityScores quality scores corresponding to each provided
1011 * measurement. The larger the score value the better
1012 * the quality of the sample.
1013 * @param biasX known x coordinate of gyroscope bias.
1014 * @param biasY known y coordinate of gyroscope bias.
1015 * @param biasZ known z coordinate of gyroscope bias.
1016 * @throws IllegalArgumentException if provided quality scores length
1017 * is smaller than 6 samples.
1018 */
1019 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
1020 final double[] qualityScores,
1021 final AngularSpeed biasX, final AngularSpeed biasY, final AngularSpeed biasZ) {
1022 super(biasX, biasY, biasZ);
1023 internalSetQualityScores(qualityScores);
1024 }
1025
1026 /**
1027 * Constructor.
1028 *
1029 * @param qualityScores quality scores corresponding to each provided
1030 * measurement. The larger the score value the better
1031 * the quality of the sample.
1032 * @param biasX known x coordinate of gyroscope bias.
1033 * @param biasY known y coordinate of gyroscope bias.
1034 * @param biasZ known z coordinate of gyroscope bias.
1035 * @param listener listener to be notified of events such as when estimation
1036 * starts, ends or its progress significantly changes.
1037 * @throws IllegalArgumentException if provided quality scores length
1038 * is smaller than 6 samples.
1039 */
1040 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
1041 final double[] qualityScores, final AngularSpeed biasX, final AngularSpeed biasY, final AngularSpeed biasZ,
1042 final RobustKnownBiasAndFrameGyroscopeCalibratorListener listener) {
1043 super(biasX, biasY, biasZ, listener);
1044 internalSetQualityScores(qualityScores);
1045 }
1046
1047 /**
1048 * Constructor.
1049 *
1050 * @param qualityScores quality scores corresponding to each provided
1051 * measurement. The larger the score value the better
1052 * the quality of the sample.
1053 * @param measurements list of body kinematics measurements with standard
1054 * deviations taken at different frames (positions, orientations
1055 * and velocities).
1056 * @param biasX known x coordinate of gyroscope bias.
1057 * @param biasY known y coordinate of gyroscope bias.
1058 * @param biasZ known z coordinate of gyroscope bias.
1059 * @throws IllegalArgumentException if provided quality scores length
1060 * is smaller than 6 samples.
1061 */
1062 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
1063 final double[] qualityScores, final List<StandardDeviationFrameBodyKinematics> measurements,
1064 final AngularSpeed biasX, final AngularSpeed biasY, final AngularSpeed biasZ) {
1065 super(measurements, biasX, biasY, biasZ);
1066 internalSetQualityScores(qualityScores);
1067 }
1068
1069 /**
1070 * Constructor.
1071 *
1072 * @param qualityScores quality scores corresponding to each provided
1073 * measurement. The larger the score value the better
1074 * the quality of the sample.
1075 * @param measurements list of body kinematics measurements with standard
1076 * deviations taken at different frames (positions, orientations
1077 * and velocities).
1078 * @param biasX known x coordinate of gyroscope bias.
1079 * @param biasY known y coordinate of gyroscope bias.
1080 * @param biasZ known z coordinate of gyroscope bias.
1081 * @param listener listener to handle events raised by this calibrator.
1082 * @throws IllegalArgumentException if provided quality scores length
1083 * is smaller than 6 samples.
1084 */
1085 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
1086 final double[] qualityScores, final List<StandardDeviationFrameBodyKinematics> measurements,
1087 final AngularSpeed biasX, final AngularSpeed biasY, final AngularSpeed biasZ,
1088 final RobustKnownBiasAndFrameGyroscopeCalibratorListener listener) {
1089 super(measurements, biasX, biasY, biasZ, listener);
1090 internalSetQualityScores(qualityScores);
1091 }
1092
1093 /**
1094 * Constructor.
1095 *
1096 * @param qualityScores quality scores corresponding to each provided
1097 * measurement. The larger the score value the better
1098 * the quality of the sample.
1099 * @param biasX known x coordinate of gyroscope bias.
1100 * @param biasY known y coordinate of gyroscope bias.
1101 * @param biasZ known z coordinate of gyroscope bias.
1102 * @param commonAxisUsed indicates whether z-axis is assumed to be common for
1103 * accelerometer and gyroscope.
1104 * @throws IllegalArgumentException if provided quality scores length
1105 * is smaller than 6 samples.
1106 */
1107 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
1108 final double[] qualityScores, final AngularSpeed biasX, final AngularSpeed biasY, final AngularSpeed biasZ,
1109 final boolean commonAxisUsed) {
1110 super(biasX, biasY, biasZ, commonAxisUsed);
1111 internalSetQualityScores(qualityScores);
1112 }
1113
1114 /**
1115 * Constructor.
1116 *
1117 * @param qualityScores quality scores corresponding to each provided
1118 * measurement. The larger the score value the better
1119 * the quality of the sample.
1120 * @param biasX known x coordinate of gyroscope bias.
1121 * @param biasY known y coordinate of gyroscope bias.
1122 * @param biasZ known z coordinate of gyroscope bias.
1123 * @param commonAxisUsed indicates whether z-axis is assumed to be common for
1124 * accelerometer and gyroscope.
1125 * @param listener listener to handle events raised by this calibrator.
1126 * @throws IllegalArgumentException if provided quality scores length
1127 * is smaller than 6 samples.
1128 */
1129 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
1130 final double[] qualityScores, final AngularSpeed biasX, final AngularSpeed biasY, final AngularSpeed biasZ,
1131 final boolean commonAxisUsed, final RobustKnownBiasAndFrameGyroscopeCalibratorListener listener) {
1132 super(biasX, biasY, biasZ, commonAxisUsed, listener);
1133 internalSetQualityScores(qualityScores);
1134 }
1135
1136 /**
1137 * Constructor.
1138 *
1139 * @param qualityScores quality scores corresponding to each provided
1140 * measurement. The larger the score value the better
1141 * the quality of the sample.
1142 * @param measurements list of body kinematics measurements with standard
1143 * deviations taken at different frames (positions, orientations
1144 * and velocities).
1145 * @param biasX known x coordinate of gyroscope bias.
1146 * @param biasY known y coordinate of gyroscope bias.
1147 * @param biasZ known z coordinate of gyroscope bias.
1148 * @param commonAxisUsed indicates whether z-axis is assumed to be common for
1149 * accelerometer and gyroscope.
1150 * @throws IllegalArgumentException if provided quality scores length
1151 * is smaller than 6 samples.
1152 */
1153 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
1154 final double[] qualityScores, final List<StandardDeviationFrameBodyKinematics> measurements,
1155 final AngularSpeed biasX, final AngularSpeed biasY, final AngularSpeed biasZ,
1156 final boolean commonAxisUsed) {
1157 super(measurements, biasX, biasY, biasZ, commonAxisUsed);
1158 internalSetQualityScores(qualityScores);
1159 }
1160
1161 /**
1162 * Constructor.
1163 *
1164 * @param qualityScores quality scores corresponding to each provided
1165 * measurement. The larger the score value the better
1166 * the quality of the sample.
1167 * @param measurements list of body kinematics measurements with standard
1168 * deviations taken at different frames (positions, orientations
1169 * and velocities).
1170 * @param biasX known x coordinate of gyroscope bias.
1171 * @param biasY known y coordinate of gyroscope bias.
1172 * @param biasZ known z coordinate of gyroscope bias.
1173 * @param commonAxisUsed indicates whether z-axis is assumed to be common for
1174 * accelerometer and gyroscope.
1175 * @param listener listener to handle events raised by this calibrator.
1176 * @throws IllegalArgumentException if provided quality scores length
1177 * is smaller than 6 samples.
1178 */
1179 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
1180 final double[] qualityScores, final List<StandardDeviationFrameBodyKinematics> measurements,
1181 final AngularSpeed biasX, final AngularSpeed biasY, final AngularSpeed biasZ,
1182 final boolean commonAxisUsed, final RobustKnownBiasAndFrameGyroscopeCalibratorListener listener) {
1183 super(measurements, biasX, biasY, biasZ, commonAxisUsed, listener);
1184 internalSetQualityScores(qualityScores);
1185 }
1186
1187 /**
1188 * Constructor.
1189 *
1190 * @param qualityScores quality scores corresponding to each provided
1191 * measurement. The larger the score value the better
1192 * the quality of the sample.
1193 * @param bias known gyroscope bias.
1194 * @throws IllegalArgumentException if provided bias array does not have length 3 or
1195 * if provided quality scores length is smaller
1196 * than 6 samples.
1197 */
1198 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(final double[] qualityScores, final double[] bias) {
1199 super(bias);
1200 internalSetQualityScores(qualityScores);
1201 }
1202
1203 /**
1204 * Constructor.
1205 *
1206 * @param qualityScores quality scores corresponding to each provided
1207 * measurement. The larger the score value the better
1208 * the quality of the sample.
1209 * @param bias known gyroscope bias.
1210 * @param listener listener to be notified of events such as when estimation
1211 * starts, ends or its progress significantly changes.
1212 * @throws IllegalArgumentException if provided array does not have length 3 or
1213 * if provided quality scores length is smaller
1214 * than 6 samples.
1215 */
1216 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
1217 final double[] qualityScores, final double[] bias,
1218 final RobustKnownBiasAndFrameGyroscopeCalibratorListener listener) {
1219 super(bias, listener);
1220 internalSetQualityScores(qualityScores);
1221 }
1222
1223 /**
1224 * Constructor.
1225 *
1226 * @param qualityScores quality scores corresponding to each provided
1227 * measurement. The larger the score value the better
1228 * the quality of the sample.
1229 * @param measurements list of body kinematics measurements with standard
1230 * deviations taken at different frames (positions, orientations
1231 * and velocities).
1232 * @param bias known gyroscope bias.
1233 * @throws IllegalArgumentException if provided array does not have length 3 or
1234 * if provided quality scores length is smaller
1235 * than 6 samples.
1236 */
1237 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
1238 final double[] qualityScores, final List<StandardDeviationFrameBodyKinematics> measurements,
1239 final double[] bias) {
1240 super(measurements, bias);
1241 internalSetQualityScores(qualityScores);
1242 }
1243
1244 /**
1245 * Constructor.
1246 *
1247 * @param qualityScores quality scores corresponding to each provided
1248 * measurement. The larger the score value the better
1249 * the quality of the sample.
1250 * @param measurements list of body kinematics measurements with standard
1251 * deviations taken at different frames (positions, orientations
1252 * and velocities).
1253 * @param bias known gyroscope bias.
1254 * @param listener listener to handle events raised by this calibrator.
1255 * @throws IllegalArgumentException if provided array does not have length 3 or
1256 * if provided quality scores length is smaller
1257 * than 6 samples.
1258 */
1259 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
1260 final double[] qualityScores, final List<StandardDeviationFrameBodyKinematics> measurements,
1261 final double[] bias, final RobustKnownBiasAndFrameGyroscopeCalibratorListener listener) {
1262 super(measurements, bias, listener);
1263 internalSetQualityScores(qualityScores);
1264 }
1265
1266 /**
1267 * Constructor.
1268 *
1269 * @param qualityScores quality scores corresponding to each provided
1270 * measurement. The larger the score value the better
1271 * the quality of the sample.
1272 * @param bias known gyroscope bias.
1273 * @param commonAxisUsed indicates whether z-axis is assumed to be common for
1274 * accelerometer and gyroscope.
1275 * @throws IllegalArgumentException if provided array does not have length 3 or
1276 * if provided quality scores length is smaller
1277 * than 6 samples.
1278 */
1279 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
1280 final double[] qualityScores, final double[] bias, final boolean commonAxisUsed) {
1281 super(bias, commonAxisUsed);
1282 internalSetQualityScores(qualityScores);
1283 }
1284
1285 /**
1286 * Constructor.
1287 *
1288 * @param qualityScores quality scores corresponding to each provided
1289 * measurement. The larger the score value the better
1290 * the quality of the sample.
1291 * @param bias known gyroscope bias.
1292 * @param commonAxisUsed indicates whether z-axis is assumed to be common for
1293 * accelerometer and gyroscope.
1294 * @param listener listener to handle events raised by this calibrator.
1295 * @throws IllegalArgumentException if provided array does not have length 3 or
1296 * if provided quality scores length is smaller
1297 * than 6 samples.
1298 */
1299 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
1300 final double[] qualityScores, final double[] bias, final boolean commonAxisUsed,
1301 final RobustKnownBiasAndFrameGyroscopeCalibratorListener listener) {
1302 super(bias, commonAxisUsed, listener);
1303 internalSetQualityScores(qualityScores);
1304 }
1305
1306 /**
1307 * Constructor.
1308 *
1309 * @param qualityScores quality scores corresponding to each provided
1310 * measurement. The larger the score value the better
1311 * the quality of the sample.
1312 * @param measurements list of body kinematics measurements with standard
1313 * deviations taken at different frames (positions, orientations
1314 * and velocities).
1315 * @param bias known gyroscope bias.
1316 * @param commonAxisUsed indicates whether z-axis is assumed to be common for
1317 * accelerometer and gyroscope.
1318 * @throws IllegalArgumentException if provided array does not have length 3 or
1319 * if provided quality scores length is smaller
1320 * than 6 samples.
1321 */
1322 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
1323 final double[] qualityScores, final List<StandardDeviationFrameBodyKinematics> measurements,
1324 final double[] bias, final boolean commonAxisUsed) {
1325 super(measurements, bias, commonAxisUsed);
1326 internalSetQualityScores(qualityScores);
1327 }
1328
1329 /**
1330 * Constructor.
1331 *
1332 * @param qualityScores quality scores corresponding to each provided
1333 * measurement. The larger the score value the better
1334 * the quality of the sample.
1335 * @param measurements list of body kinematics measurements with standard
1336 * deviations taken at different frames (positions, orientations
1337 * and velocities).
1338 * @param bias known gyroscope bias.
1339 * @param commonAxisUsed indicates whether z-axis is assumed to be common for
1340 * accelerometer and gyroscope.
1341 * @param listener listener to handle events raised by this calibrator.
1342 * @throws IllegalArgumentException if provided array does not have length 3 or
1343 * if provided quality scores length is smaller
1344 * than 6 samples.
1345 */
1346 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
1347 final double[] qualityScores, final List<StandardDeviationFrameBodyKinematics> measurements,
1348 final double[] bias, final boolean commonAxisUsed,
1349 final RobustKnownBiasAndFrameGyroscopeCalibratorListener listener) {
1350 super(measurements, bias, commonAxisUsed, listener);
1351 internalSetQualityScores(qualityScores);
1352 }
1353
1354 /**
1355 * Constructor.
1356 *
1357 * @param qualityScores quality scores corresponding to each provided
1358 * measurement. The larger the score value the better
1359 * the quality of the sample.
1360 * @param bias known gyroscope bias.
1361 * @throws IllegalArgumentException if provided matrix is not 3x1 or
1362 * if provided quality scores length is smaller
1363 * than 6 samples.
1364 */
1365 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(final double[] qualityScores, final Matrix bias) {
1366 super(bias);
1367 internalSetQualityScores(qualityScores);
1368 }
1369
1370 /**
1371 * Constructor.
1372 *
1373 * @param qualityScores quality scores corresponding to each provided
1374 * measurement. The larger the score value the better
1375 * the quality of the sample.
1376 * @param bias known gyroscope bias.
1377 * @param listener listener to be notified of events such as when estimation
1378 * starts, ends or its progress significantly changes.
1379 * @throws IllegalArgumentException if provided matrix is not 3x1 or
1380 * if provided quality scores length is smaller
1381 * than 6 samples.
1382 */
1383 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
1384 final double[] qualityScores, final Matrix bias,
1385 final RobustKnownBiasAndFrameGyroscopeCalibratorListener listener) {
1386 super(bias, listener);
1387 internalSetQualityScores(qualityScores);
1388 }
1389
1390 /**
1391 * Constructor.
1392 *
1393 * @param qualityScores quality scores corresponding to each provided
1394 * measurement. The larger the score value the better
1395 * the quality of the sample.
1396 * @param measurements list of body kinematics measurements with standard
1397 * deviations taken at different frames (positions, orientations
1398 * and velocities).
1399 * @param bias known gyroscope bias.
1400 * @throws IllegalArgumentException if provided matrix is not 3x1 or
1401 * if provided quality scores length is smaller
1402 * than 6 samples.
1403 */
1404 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
1405 final double[] qualityScores, final List<StandardDeviationFrameBodyKinematics> measurements,
1406 final Matrix bias) {
1407 super(measurements, bias);
1408 internalSetQualityScores(qualityScores);
1409 }
1410
1411 /**
1412 * Constructor.
1413 *
1414 * @param qualityScores quality scores corresponding to each provided
1415 * measurement. The larger the score value the better
1416 * the quality of the sample.
1417 * @param measurements list of body kinematics measurements with standard
1418 * deviations taken at different frames (positions, orientations
1419 * and velocities).
1420 * @param bias known gyroscope bias.
1421 * @param listener listener to handle events raised by this calibrator.
1422 * @throws IllegalArgumentException if provided matrix is not 3x1 or
1423 * if provided quality scores length is smaller
1424 * than 6 samples.
1425 */
1426 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
1427 final double[] qualityScores, final List<StandardDeviationFrameBodyKinematics> measurements,
1428 final Matrix bias, final RobustKnownBiasAndFrameGyroscopeCalibratorListener listener) {
1429 super(measurements, bias, listener);
1430 internalSetQualityScores(qualityScores);
1431 }
1432
1433 /**
1434 * Constructor.
1435 *
1436 * @param qualityScores quality scores corresponding to each provided
1437 * measurement. The larger the score value the better
1438 * the quality of the sample.
1439 * @param bias known gyroscope bias.
1440 * @param commonAxisUsed indicates whether z-axis is assumed to be common for
1441 * accelerometer and gyroscope.
1442 * @throws IllegalArgumentException if provided matrix is not 3x1 or
1443 * if provided quality scores length is smaller
1444 * than 6 samples.
1445 */
1446 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
1447 final double[] qualityScores, final Matrix bias, final boolean commonAxisUsed) {
1448 super(bias, commonAxisUsed);
1449 internalSetQualityScores(qualityScores);
1450 }
1451
1452 /**
1453 * Constructor.
1454 *
1455 * @param qualityScores quality scores corresponding to each provided
1456 * measurement. The larger the score value the better
1457 * the quality of the sample.
1458 * @param bias known gyroscope bias.
1459 * @param commonAxisUsed indicates whether z-axis is assumed to be common for
1460 * accelerometer and gyroscope.
1461 * @param listener listener to handle events raised by this calibrator.
1462 * @throws IllegalArgumentException if provided matrix is not 3x1 or
1463 * if provided quality scores length is smaller
1464 * than 6 samples.
1465 */
1466 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
1467 final double[] qualityScores, final Matrix bias, final boolean commonAxisUsed,
1468 final RobustKnownBiasAndFrameGyroscopeCalibratorListener listener) {
1469 super(bias, commonAxisUsed, listener);
1470 internalSetQualityScores(qualityScores);
1471 }
1472
1473 /**
1474 * Constructor.
1475 *
1476 * @param qualityScores quality scores corresponding to each provided
1477 * measurement. The larger the score value the better
1478 * the quality of the sample.
1479 * @param measurements list of body kinematics measurements with standard
1480 * deviations taken at different frames (positions, orientations
1481 * and velocities).
1482 * @param bias known gyroscope bias.
1483 * @param commonAxisUsed indicates whether z-axis is assumed to be common for
1484 * accelerometer and gyroscope.
1485 * @throws IllegalArgumentException if provided matrix is not 3x1 or
1486 * if provided quality scores length is smaller
1487 * than 6 samples.
1488 */
1489 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
1490 final double[] qualityScores, final List<StandardDeviationFrameBodyKinematics> measurements,
1491 final Matrix bias, final boolean commonAxisUsed) {
1492 super(measurements, bias, commonAxisUsed);
1493 internalSetQualityScores(qualityScores);
1494 }
1495
1496 /**
1497 * Constructor.
1498 *
1499 * @param qualityScores quality scores corresponding to each provided
1500 * measurement. The larger the score value the better
1501 * the quality of the sample.
1502 * @param measurements list of body kinematics measurements with standard
1503 * deviations taken at different frames (positions, orientations
1504 * and velocities).
1505 * @param bias known gyroscope bias.
1506 * @param commonAxisUsed indicates whether z-axis is assumed to be common for
1507 * accelerometer and gyroscope.
1508 * @param listener listener to handle events raised by this calibrator.
1509 * @throws IllegalArgumentException if provided matrix is not 3x1 or
1510 * if provided quality scores length is smaller
1511 * than 6 samples.
1512 */
1513 public PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator(
1514 final double[] qualityScores, final List<StandardDeviationFrameBodyKinematics> measurements,
1515 final Matrix bias, final boolean commonAxisUsed,
1516 final RobustKnownBiasAndFrameGyroscopeCalibratorListener listener) {
1517 super(measurements, bias, commonAxisUsed, listener);
1518 internalSetQualityScores(qualityScores);
1519 }
1520
1521 /**
1522 * Returns threshold to be used to keep the algorithm iterating in case that
1523 * best estimated threshold using median of residuals is not small enough.
1524 * Once a solution is found that generates a threshold below this value, the
1525 * algorithm will stop.
1526 * The stop threshold can be used to prevent the LMedS algorithm to iterate
1527 * too many times in cases where samples have a very similar accuracy.
1528 * For instance, in cases where proportion of outliers is very small (close
1529 * to 0%), and samples are very accurate (i.e. 1e-6), the algorithm would
1530 * iterate for a long time trying to find the best solution when indeed
1531 * there is no need to do that if a reasonable threshold has already been
1532 * reached.
1533 * Because of this behaviour the stop threshold can be set to a value much
1534 * lower than the one typically used in RANSAC, and yet the algorithm could
1535 * still produce even smaller thresholds in estimated results.
1536 *
1537 * @return stop threshold to stop the algorithm prematurely when a certain
1538 * accuracy has been reached.
1539 */
1540 public double getStopThreshold() {
1541 return stopThreshold;
1542 }
1543
1544 /**
1545 * Sets threshold to be used to keep the algorithm iterating in case that
1546 * best estimated threshold using median of residuals is not small enough.
1547 * Once a solution is found that generates a threshold below this value,
1548 * the algorithm will stop.
1549 * The stop threshold can be used to prevent the LMedS algorithm to iterate
1550 * too many times in cases where samples have a very similar accuracy.
1551 * For instance, in cases where proportion of outliers is very small (close
1552 * to 0%), and samples are very accurate (i.e. 1e-6), the algorithm would
1553 * iterate for a long time trying to find the best solution when indeed
1554 * there is no need to do that if a reasonable threshold has already been
1555 * reached.
1556 * Because of this behaviour the stop threshold can be set to a value much
1557 * lower than the one typically used in RANSAC, and yet the algorithm could
1558 * still produce even smaller thresholds in estimated results.
1559 *
1560 * @param stopThreshold stop threshold to stop the algorithm prematurely
1561 * when a certain accuracy has been reached.
1562 * @throws IllegalArgumentException if provided value is zero or negative.
1563 * @throws LockedException if calibrator is currently running.
1564 */
1565 public void setStopThreshold(final double stopThreshold) throws LockedException {
1566 if (running) {
1567 throw new LockedException();
1568 }
1569 if (stopThreshold <= MIN_STOP_THRESHOLD) {
1570 throw new IllegalArgumentException();
1571 }
1572
1573 this.stopThreshold = stopThreshold;
1574 }
1575
1576 /**
1577 * Returns quality scores corresponding to each provided sample.
1578 * The larger the score value the better the quality of the sample.
1579 *
1580 * @return quality scores corresponding to each sample.
1581 */
1582 @Override
1583 public double[] getQualityScores() {
1584 return qualityScores;
1585 }
1586
1587 /**
1588 * Sets quality scores corresponding to each provided sample.
1589 * The larger the score value the better the quality of the sample.
1590 *
1591 * @param qualityScores quality scores corresponding to each sample.
1592 * @throws IllegalArgumentException if provided quality scores length
1593 * is smaller than minimum required samples.
1594 * @throws LockedException if calibrator is currently running.
1595 */
1596 @Override
1597 public void setQualityScores(final double[] qualityScores) throws LockedException {
1598 if (running) {
1599 throw new LockedException();
1600 }
1601 internalSetQualityScores(qualityScores);
1602 }
1603
1604 /**
1605 * Indicates whether solver is ready to find a solution.
1606 *
1607 * @return true if solver is ready, false otherwise.
1608 */
1609 @Override
1610 public boolean isReady() {
1611 return super.isReady() && qualityScores != null && qualityScores.length == measurements.size();
1612 }
1613
1614 /**
1615 * Estimates gyroscope calibration parameters containing bias, scale factors
1616 * cross-coupling errors and g-dependant cross biases.
1617 *
1618 * @throws LockedException if calibrator is currently running.
1619 * @throws NotReadyException if calibrator is not ready.
1620 * @throws CalibrationException if estimation fails for numerical reasons.
1621 */
1622 @SuppressWarnings("DuplicatedCode")
1623 @Override
1624 public void calibrate() throws LockedException, NotReadyException, CalibrationException {
1625 if (running) {
1626 throw new LockedException();
1627 }
1628 if (!isReady()) {
1629 throw new NotReadyException();
1630 }
1631
1632 final var innerEstimator = new PROMedSRobustEstimator<>(
1633 new PROMedSRobustEstimatorListener<PreliminaryResult>() {
1634 @Override
1635 public double[] getQualityScores() {
1636 return qualityScores;
1637 }
1638
1639 @Override
1640 public double getThreshold() {
1641 return stopThreshold;
1642 }
1643
1644 @Override
1645 public int getTotalSamples() {
1646 return measurements.size();
1647 }
1648
1649 @Override
1650 public int getSubsetSize() {
1651 return preliminarySubsetSize;
1652 }
1653
1654 @Override
1655 public void estimatePreliminarSolutions(
1656 final int[] samplesIndices, final List<PreliminaryResult> solutions) {
1657 computePreliminarySolutions(samplesIndices, solutions);
1658 }
1659
1660 @Override
1661 public double computeResidual(final PreliminaryResult currentEstimation, final int i) {
1662 return computeError(measurements.get(i), currentEstimation);
1663 }
1664
1665 @Override
1666 public boolean isReady() {
1667 return PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator.this.isReady();
1668 }
1669
1670 @Override
1671 public void onEstimateStart(final RobustEstimator<PreliminaryResult> estimator) {
1672 // no action needed
1673 }
1674
1675 @Override
1676 public void onEstimateEnd(final RobustEstimator<PreliminaryResult> estimator) {
1677 // no action needed
1678 }
1679
1680 @Override
1681 public void onEstimateNextIteration(
1682 final RobustEstimator<PreliminaryResult> estimator, final int iteration) {
1683 if (listener != null) {
1684 listener.onCalibrateNextIteration(
1685 PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator.this, iteration);
1686 }
1687 }
1688
1689 @Override
1690 public void onEstimateProgressChange(
1691 final RobustEstimator<PreliminaryResult> estimator, final float progress) {
1692 if (listener != null) {
1693 listener.onCalibrateProgressChange(
1694 PROMedSRobustKnownBiasAndFrameGyroscopeCalibrator.this, progress);
1695 }
1696 }
1697 });
1698
1699 try {
1700 running = true;
1701
1702 if (listener != null) {
1703 listener.onCalibrateStart(this);
1704 }
1705
1706 inliersData = null;
1707 innerEstimator.setUseInlierThresholds(true);
1708 innerEstimator.setConfidence(confidence);
1709 innerEstimator.setMaxIterations(maxIterations);
1710 innerEstimator.setProgressDelta(progressDelta);
1711 final var preliminaryResult = innerEstimator.estimate();
1712 inliersData = innerEstimator.getInliersData();
1713
1714 attemptRefine(preliminaryResult);
1715
1716 if (listener != null) {
1717 listener.onCalibrateEnd(this);
1718 }
1719
1720 } catch (final com.irurueta.numerical.LockedException e) {
1721 throw new LockedException(e);
1722 } catch (final com.irurueta.numerical.NotReadyException e) {
1723 throw new NotReadyException(e);
1724 } catch (final RobustEstimatorException e) {
1725 throw new CalibrationException(e);
1726 } finally {
1727 running = false;
1728 }
1729 }
1730
1731 /**
1732 * Returns method being used for robust estimation.
1733 *
1734 * @return method being used for robust estimation.
1735 */
1736 @Override
1737 public RobustEstimatorMethod getMethod() {
1738 return RobustEstimatorMethod.PROMEDS;
1739 }
1740
1741 /**
1742 * Indicates whether this calibrator requires quality scores for each
1743 * measurement/sequence or not.
1744 *
1745 * @return true if quality scores are required, false otherwise.
1746 */
1747 @Override
1748 public boolean isQualityScoresRequired() {
1749 return true;
1750 }
1751
1752 /**
1753 * Sets quality scores corresponding to each provided sample.
1754 * This method is used internally and does not check whether instance is
1755 * locked or not.
1756 *
1757 * @param qualityScores quality scores to be set.
1758 * @throws IllegalArgumentException if provided quality scores length is
1759 * smaller than 6 samples.
1760 */
1761 private void internalSetQualityScores(final double[] qualityScores) {
1762 if (qualityScores == null || qualityScores.length < MINIMUM_MEASUREMENTS) {
1763 throw new IllegalArgumentException();
1764 }
1765
1766 this.qualityScores = qualityScores;
1767 }
1768 }