1 /*
2 * Copyright (C) 2022 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.magnetometer;
17
18 import com.irurueta.algebra.Matrix;
19 import com.irurueta.navigation.LockedException;
20 import com.irurueta.navigation.inertial.calibration.StandardDeviationBodyMagneticFluxDensity;
21 import com.irurueta.units.MagneticFluxDensity;
22 import com.irurueta.units.MagneticFluxDensityConverter;
23 import com.irurueta.units.MagneticFluxDensityUnit;
24
25 import java.util.Collection;
26
27 /**
28 * Estimates magnetometer hard-iron biases, cross couplings and scaling factors.
29 * This calibrator uses Levenberg-Marquardt to find a minimum least squared
30 * error solution.
31 * <p>
32 * To use this calibrator at least 10 measurements with known magnetic field norm at
33 * an unknown position and instant must be taken at 10 different unknown orientations
34 * when common z-axis is assumed, otherwise at least 13
35 * measurements are required.
36 * <p>
37 * Measured magnetic flux density is assumed to follow the model shown below:
38 * <pre>
39 * mBmeas = bm + (I + Mm) * mBtrue + w
40 * </pre>
41 * Where:
42 * - mBmeas is the measured magnetic flux density. This is a 3x1 vector.
43 * - bm is magnetometer hard-iron bias. Ideally, on a perfect magnetometer,
44 * this should be a 3x1 zero vector.
45 * - I is the 3x3 identity matrix.
46 * - Mm is the 3x3 soft-iron matrix containing cross-couplings and scaling
47 * factors. Ideally, on a perfect magnetometer, this should be a 3x3 zero
48 * matrix.
49 * - mBtrue is ground-truth magnetic flux density. This is a 3x1 vector.
50 * - w is measurement noise. This is a 3x1 vector.
51 * Notice that this calibrator assumes that all measurements are taken in
52 * a short span of time, where Earth magnetic field can be assumed to be
53 * constant at provided location and instant.
54 */
55 public class KnownMagneticFluxDensityNormMagnetometerCalibrator extends
56 BaseMagneticFluxDensityNormMagnetometerCalibrator<KnownMagneticFluxDensityNormMagnetometerCalibrator,
57 KnownMagneticFluxDensityNormMagnetometerCalibratorListener> {
58
59 /**
60 * Constructor.
61 */
62 public KnownMagneticFluxDensityNormMagnetometerCalibrator() {
63 super();
64 }
65
66 /**
67 * Constructor.
68 *
69 * @param listener listener to handle events raised by this calibrator.
70 */
71 public KnownMagneticFluxDensityNormMagnetometerCalibrator(
72 final KnownMagneticFluxDensityNormMagnetometerCalibratorListener listener) {
73 super(listener);
74 }
75
76 /**
77 * Constructor.
78 *
79 * @param measurements collection of body magnetic flux density
80 * measurements with standard deviation of
81 * magnetometer measurements taken at the same
82 * position with zero velocity and unknown different
83 * orientations.
84 */
85 public KnownMagneticFluxDensityNormMagnetometerCalibrator(
86 final Collection<StandardDeviationBodyMagneticFluxDensity> measurements) {
87 super(measurements);
88 }
89
90 /**
91 * Constructor.
92 *
93 * @param commonAxisUsed indicates whether z-axis is assumed to be common
94 * for the accelerometer, gyroscope and magnetometer.
95 */
96 public KnownMagneticFluxDensityNormMagnetometerCalibrator(final boolean commonAxisUsed) {
97 super(commonAxisUsed);
98 }
99
100 /**
101 * Constructor.
102 *
103 * @param initialHardIron initial hard-iron to find a solution.
104 * @throws IllegalArgumentException if provided hard-iron array does
105 * not have length 3.
106 */
107 public KnownMagneticFluxDensityNormMagnetometerCalibrator(final double[] initialHardIron) {
108 super(initialHardIron);
109 }
110
111 /**
112 * Constructor.
113 *
114 * @param initialHardIron initial hard-iron to find a solution.
115 * @throws IllegalArgumentException if provided hard-iron matrix is not
116 * 3x1.
117 */
118 public KnownMagneticFluxDensityNormMagnetometerCalibrator(final Matrix initialHardIron) {
119 super(initialHardIron);
120 }
121
122 /**
123 * Constructor.
124 *
125 * @param initialHardIron initial hard-iron to find a solution.
126 * @param initialMm initial soft-iron matrix containing scale factors
127 * and cross coupling errors.
128 * @throws IllegalArgumentException if provided hard-iron matrix is not
129 * 3x1 or if soft-iron matrix is not
130 * 3x3.
131 */
132 public KnownMagneticFluxDensityNormMagnetometerCalibrator(final Matrix initialHardIron, final Matrix initialMm) {
133 super(initialHardIron, initialMm);
134 }
135
136 /**
137 * Constructor.
138 *
139 * @param measurements collection of body magnetic flux density
140 * measurements with standard deviation of
141 * magnetometer measurements taken at the same
142 * position with zero velocity and unknown different
143 * orientations.
144 * @param listener listener to handle events raised by this calibrator.
145 */
146 public KnownMagneticFluxDensityNormMagnetometerCalibrator(
147 final Collection<StandardDeviationBodyMagneticFluxDensity> measurements,
148 final KnownMagneticFluxDensityNormMagnetometerCalibratorListener listener) {
149 super(measurements, listener);
150 }
151
152 /**
153 * Constructor.
154 *
155 * @param measurements collection of body magnetic flux density
156 * measurements with standard deviation of
157 * magnetometer measurements taken at the same
158 * position with zero velocity and unknown different
159 * orientations.
160 * @param commonAxisUsed indicates whether z-axis is assumed to be common
161 * for the accelerometer, gyroscope and magnetometer.
162 */
163 public KnownMagneticFluxDensityNormMagnetometerCalibrator(
164 final Collection<StandardDeviationBodyMagneticFluxDensity> measurements, final boolean commonAxisUsed) {
165 super(measurements, commonAxisUsed);
166 }
167
168 /**
169 * Constructor.
170 *
171 * @param measurements collection of body magnetic flux density
172 * measurements with standard deviation of
173 * magnetometer measurements taken at the same
174 * position with zero velocity and unknown different
175 * orientations.
176 * @param commonAxisUsed indicates whether z-axis is assumed to be common
177 * for the accelerometer, gyroscope and magnetometer.
178 * @param listener listener to handle events raised by this calibrator.
179 */
180 public KnownMagneticFluxDensityNormMagnetometerCalibrator(
181 final Collection<StandardDeviationBodyMagneticFluxDensity> measurements, final boolean commonAxisUsed,
182 final KnownMagneticFluxDensityNormMagnetometerCalibratorListener listener) {
183 super(measurements, commonAxisUsed, listener);
184 }
185
186 /**
187 * Constructor.
188 *
189 * @param measurements collection of body magnetic flux density
190 * measurements with standard deviation of
191 * magnetometer measurements taken at the same
192 * position with zero velocity and unknown different
193 * orientations.
194 * @param initialHardIron initial hard-iron to find a solution.
195 * @throws IllegalArgumentException if provided hard-iron array does
196 * not have length 3.
197 */
198 public KnownMagneticFluxDensityNormMagnetometerCalibrator(
199 final Collection<StandardDeviationBodyMagneticFluxDensity> measurements, final double[] initialHardIron) {
200 super(measurements, initialHardIron);
201 }
202
203 /**
204 * Constructor.
205 *
206 * @param measurements collection of body magnetic flux density
207 * measurements with standard deviation of
208 * magnetometer measurements taken at the same
209 * position with zero velocity and unknown different
210 * orientations.
211 * @param initialHardIron initial hard-iron to find a solution.
212 * @param listener listener to handle events raised by this calibrator.
213 * @throws IllegalArgumentException if provided hard-iron array does
214 * not have length 3.
215 */
216 public KnownMagneticFluxDensityNormMagnetometerCalibrator(
217 final Collection<StandardDeviationBodyMagneticFluxDensity> measurements, final double[] initialHardIron,
218 final KnownMagneticFluxDensityNormMagnetometerCalibratorListener listener) {
219 super(measurements, initialHardIron, listener);
220 }
221
222 /**
223 * Constructor.
224 *
225 * @param measurements collection of body magnetic flux density
226 * measurements with standard deviation of
227 * magnetometer measurements taken at the same
228 * position with zero velocity and unknown different
229 * orientations.
230 * @param commonAxisUsed indicates whether z-axis is assumed to be common
231 * for the accelerometer, gyroscope and magnetometer.
232 * @param initialHardIron initial hard-iron to find a solution.
233 * @throws IllegalArgumentException if provided hard-iron array does
234 * not have length 3.
235 */
236 public KnownMagneticFluxDensityNormMagnetometerCalibrator(
237 final Collection<StandardDeviationBodyMagneticFluxDensity> measurements, final boolean commonAxisUsed,
238 final double[] initialHardIron) {
239 super(measurements, commonAxisUsed, initialHardIron);
240 }
241
242 /**
243 * Constructor.
244 *
245 * @param measurements collection of body magnetic flux density
246 * measurements with standard deviation of
247 * magnetometer measurements taken at the same
248 * position with zero velocity and unknown different
249 * orientations.
250 * @param commonAxisUsed indicates whether z-axis is assumed to be common
251 * for the accelerometer, gyroscope and magnetometer.
252 * @param initialHardIron initial hard-iron to find a solution.
253 * @param listener listener to handle events raised by this calibrator.
254 * @throws IllegalArgumentException if provided hard-iron array does
255 * not have length 3.
256 */
257 public KnownMagneticFluxDensityNormMagnetometerCalibrator(
258 final Collection<StandardDeviationBodyMagneticFluxDensity> measurements, final boolean commonAxisUsed,
259 final double[] initialHardIron, final KnownMagneticFluxDensityNormMagnetometerCalibratorListener listener) {
260 super(measurements, commonAxisUsed, initialHardIron, listener);
261 }
262
263 /**
264 * Constructor.
265 *
266 * @param measurements collection of body magnetic flux density
267 * measurements with standard deviation of
268 * magnetometer measurements taken at the same
269 * position with zero velocity and unknown different
270 * orientations.
271 * @param initialHardIron initial hard-iron to find a solution.
272 * @throws IllegalArgumentException if provided hard-iron matrix is not
273 * 3x1.
274 */
275 public KnownMagneticFluxDensityNormMagnetometerCalibrator(
276 final Collection<StandardDeviationBodyMagneticFluxDensity> measurements, final Matrix initialHardIron) {
277 super(measurements, initialHardIron);
278 }
279
280 /**
281 * Constructor.
282 *
283 * @param measurements collection of body magnetic flux density
284 * measurements with standard deviation of
285 * magnetometer measurements taken at the same
286 * position with zero velocity and unknown different
287 * orientations.
288 * @param initialHardIron initial hard-iron to find a solution.
289 * @param listener listener to handle events raised by this calibrator.
290 * @throws IllegalArgumentException if provided hard-iron matrix is not
291 * 3x1.
292 */
293 public KnownMagneticFluxDensityNormMagnetometerCalibrator(
294 final Collection<StandardDeviationBodyMagneticFluxDensity> measurements, final Matrix initialHardIron,
295 final KnownMagneticFluxDensityNormMagnetometerCalibratorListener listener) {
296 super(measurements, initialHardIron, listener);
297 }
298
299 /**
300 * Constructor.
301 *
302 * @param measurements collection of body magnetic flux density
303 * measurements with standard deviation of
304 * magnetometer measurements taken at the same
305 * position with zero velocity and unknown different
306 * orientations.
307 * @param commonAxisUsed indicates whether z-axis is assumed to be common
308 * for the accelerometer, gyroscope and magnetometer.
309 * @param initialHardIron initial hard-iron to find a solution.
310 * @throws IllegalArgumentException if provided hard-iron matrix is not
311 * 3x1.
312 */
313 public KnownMagneticFluxDensityNormMagnetometerCalibrator(
314 final Collection<StandardDeviationBodyMagneticFluxDensity> measurements, final boolean commonAxisUsed,
315 final Matrix initialHardIron) {
316 super(measurements, commonAxisUsed, initialHardIron);
317 }
318
319 /**
320 * Constructor.
321 *
322 * @param measurements collection of body magnetic flux density
323 * measurements with standard deviation of
324 * magnetometer measurements taken at the same
325 * position with zero velocity and unknown different
326 * orientations.
327 * @param commonAxisUsed indicates whether z-axis is assumed to be common
328 * for the accelerometer, gyroscope and magnetometer.
329 * @param initialHardIron initial hard-iron to find a solution.
330 * @param listener listener to handle events raised by this calibrator.
331 * @throws IllegalArgumentException if provided hard-iron matrix is not
332 * 3x1.
333 */
334 public KnownMagneticFluxDensityNormMagnetometerCalibrator(
335 final Collection<StandardDeviationBodyMagneticFluxDensity> measurements, final boolean commonAxisUsed,
336 final Matrix initialHardIron, final KnownMagneticFluxDensityNormMagnetometerCalibratorListener listener) {
337 super(measurements, commonAxisUsed, initialHardIron, listener);
338 }
339
340 /**
341 * Constructor.
342 *
343 * @param measurements collection of body magnetic flux density
344 * measurements with standard deviation of
345 * magnetometer measurements taken at the same
346 * position with zero velocity and unknown different
347 * orientations.
348 * @param initialHardIron initial hard-iron to find a solution.
349 * @param initialMm initial soft-iron matrix containing scale factors
350 * and cross coupling errors.
351 * @throws IllegalArgumentException if provided hard-iron matrix is not
352 * 3x1 or if soft-iron matrix is not
353 * 3x3.
354 */
355 public KnownMagneticFluxDensityNormMagnetometerCalibrator(
356 final Collection<StandardDeviationBodyMagneticFluxDensity> measurements, final Matrix initialHardIron,
357 final Matrix initialMm) {
358 super(measurements, initialHardIron, initialMm);
359 }
360
361 /**
362 * Constructor.
363 *
364 * @param measurements collection of body magnetic flux density
365 * measurements with standard deviation of
366 * magnetometer measurements taken at the same
367 * position with zero velocity and unknown different
368 * orientations.
369 * @param initialHardIron initial hard-iron to find a solution.
370 * @param initialMm initial soft-iron matrix containing scale factors
371 * and cross coupling errors.
372 * @param listener listener to handle events raised by this calibrator.
373 * @throws IllegalArgumentException if provided hard-iron matrix is not
374 * 3x1 or if soft-iron matrix is not
375 * 3x3.
376 */
377 public KnownMagneticFluxDensityNormMagnetometerCalibrator(
378 final Collection<StandardDeviationBodyMagneticFluxDensity> measurements, final Matrix initialHardIron,
379 final Matrix initialMm, final KnownMagneticFluxDensityNormMagnetometerCalibratorListener listener) {
380 super(measurements, initialHardIron, initialMm, listener);
381 }
382
383 /**
384 * Constructor.
385 *
386 * @param measurements collection of body magnetic flux density
387 * measurements with standard deviation of
388 * magnetometer measurements taken at the same
389 * position with zero velocity and unknown different
390 * orientations.
391 * @param commonAxisUsed indicates whether z-axis is assumed to be common
392 * for the accelerometer, gyroscope and magnetometer.
393 * @param initialHardIron initial hard-iron to find a solution.
394 * @param initialMm initial soft-iron matrix containing scale factors
395 * and cross coupling errors.
396 * @throws IllegalArgumentException if provided hard-iron matrix is not
397 * 3x1 or if soft-iron matrix is not
398 * 3x3.
399 */
400 public KnownMagneticFluxDensityNormMagnetometerCalibrator(
401 final Collection<StandardDeviationBodyMagneticFluxDensity> measurements, final boolean commonAxisUsed,
402 final Matrix initialHardIron, final Matrix initialMm) {
403 super(measurements, commonAxisUsed, initialHardIron, initialMm);
404 }
405
406 /**
407 * Constructor.
408 *
409 * @param measurements collection of body magnetic flux density
410 * measurements with standard deviation of
411 * magnetometer measurements taken at the same
412 * position with zero velocity and unknown different
413 * orientations.
414 * @param commonAxisUsed indicates whether z-axis is assumed to be common
415 * for the accelerometer, gyroscope and magnetometer.
416 * @param initialHardIron initial hard-iron to find a solution.
417 * @param initialMm initial soft-iron matrix containing scale factors
418 * and cross coupling errors.
419 * @param listener listener to handle events raised by this calibrator.
420 * @throws IllegalArgumentException if provided hard-iron matrix is not
421 * 3x1 or if soft-iron matrix is not
422 * 3x3.
423 */
424 public KnownMagneticFluxDensityNormMagnetometerCalibrator(
425 final Collection<StandardDeviationBodyMagneticFluxDensity> measurements, final boolean commonAxisUsed,
426 final Matrix initialHardIron, final Matrix initialMm,
427 final KnownMagneticFluxDensityNormMagnetometerCalibratorListener listener) {
428 super(measurements, commonAxisUsed, initialHardIron, initialMm, listener);
429 }
430
431 /**
432 * Constructor.
433 *
434 * @param groundTruthMagneticFluxDensityNorm ground truth magnetic flux density norm expressed in Teslas (T).
435 * @throws IllegalArgumentException if provided magnetic flux norm value is negative.
436 */
437 public KnownMagneticFluxDensityNormMagnetometerCalibrator(final Double groundTruthMagneticFluxDensityNorm) {
438 super(groundTruthMagneticFluxDensityNorm);
439 }
440
441 /**
442 * Constructor.
443 *
444 * @param groundTruthMagneticFluxDensityNorm ground truth magnetic flux density norm expressed in Teslas (T).
445 * @param listener listener to handle events raised by this calibrator.
446 * @throws IllegalArgumentException if provided magnetic flux norm value is negative.
447 */
448 public KnownMagneticFluxDensityNormMagnetometerCalibrator(
449 final Double groundTruthMagneticFluxDensityNorm,
450 final KnownMagneticFluxDensityNormMagnetometerCalibratorListener listener) {
451 super(groundTruthMagneticFluxDensityNorm, listener);
452 }
453
454 /**
455 * Constructor.
456 *
457 * @param groundTruthMagneticFluxDensityNorm ground truth magnetic flux density norm expressed in Teslas (T).
458 * @param measurements collection of body magnetic flux density
459 * measurements with standard deviation of
460 * magnetometer measurements taken at the same
461 * position with zero velocity and unknown different
462 * orientations.
463 * @throws IllegalArgumentException if provided magnetic flux norm value is negative.
464 */
465 public KnownMagneticFluxDensityNormMagnetometerCalibrator(
466 final Double groundTruthMagneticFluxDensityNorm,
467 final Collection<StandardDeviationBodyMagneticFluxDensity> measurements) {
468 super(groundTruthMagneticFluxDensityNorm, measurements);
469 }
470
471 /**
472 * Constructor.
473 *
474 * @param groundTruthMagneticFluxDensityNorm ground truth magnetic flux density norm expressed in Teslas (T).
475 * @param commonAxisUsed indicates whether z-axis is assumed to be common
476 * for the accelerometer, gyroscope and magnetometer.
477 * @throws IllegalArgumentException if provided magnetic flux norm value is negative.
478 */
479 public KnownMagneticFluxDensityNormMagnetometerCalibrator(
480 final Double groundTruthMagneticFluxDensityNorm, final boolean commonAxisUsed) {
481 super(groundTruthMagneticFluxDensityNorm, commonAxisUsed);
482 }
483
484 /**
485 * Constructor.
486 *
487 * @param groundTruthMagneticFluxDensityNorm ground truth magnetic flux density norm expressed in Teslas (T).
488 * @param initialHardIron initial hard-iron to find a solution.
489 * @throws IllegalArgumentException if provided magnetic flux norm value is
490 * negative, or if provided hard-iron array does
491 * not have length 3.
492 */
493 public KnownMagneticFluxDensityNormMagnetometerCalibrator(
494 final Double groundTruthMagneticFluxDensityNorm, final double[] initialHardIron) {
495 super(groundTruthMagneticFluxDensityNorm, initialHardIron);
496 }
497
498 /**
499 * Constructor.
500 *
501 * @param groundTruthMagneticFluxDensityNorm ground truth magnetic flux density norm expressed in Teslas (T).
502 * @param initialHardIron initial hard-iron to find a solution.
503 * @throws IllegalArgumentException if provided magnetic flux norm value is
504 * negative, or if provided hard-iron matrix is not
505 * 3x1.
506 */
507 public KnownMagneticFluxDensityNormMagnetometerCalibrator(
508 final Double groundTruthMagneticFluxDensityNorm, final Matrix initialHardIron) {
509 super(groundTruthMagneticFluxDensityNorm, initialHardIron);
510 }
511
512 /**
513 * Constructor.
514 *
515 * @param groundTruthMagneticFluxDensityNorm ground truth magnetic flux density norm expressed in Teslas (T).
516 * @param initialHardIron initial hard-iron to find a solution.
517 * @param initialMm initial soft-iron matrix containing scale factors
518 * and cross coupling errors.
519 * @throws IllegalArgumentException if provided magnetic flux norm value is
520 * negative, or if provided hard-iron matrix is not
521 * 3x1 or if soft-iron matrix is not
522 * 3x3.
523 */
524 public KnownMagneticFluxDensityNormMagnetometerCalibrator(
525 final Double groundTruthMagneticFluxDensityNorm, final Matrix initialHardIron, final Matrix initialMm) {
526 super(groundTruthMagneticFluxDensityNorm, initialHardIron, initialMm);
527 }
528
529 /**
530 * Constructor.
531 *
532 * @param groundTruthMagneticFluxDensityNorm ground truth magnetic flux density norm expressed in Teslas (T).
533 * @param measurements collection of body magnetic flux density
534 * measurements with standard deviation of
535 * magnetometer measurements taken at the same
536 * position with zero velocity and unknown different
537 * orientations.
538 * @param listener listener to handle events raised by this calibrator.
539 * @throws IllegalArgumentException if provided magnetic flux norm value is negative.
540 */
541 public KnownMagneticFluxDensityNormMagnetometerCalibrator(
542 final Double groundTruthMagneticFluxDensityNorm,
543 final Collection<StandardDeviationBodyMagneticFluxDensity> measurements,
544 final KnownMagneticFluxDensityNormMagnetometerCalibratorListener listener) {
545 super(groundTruthMagneticFluxDensityNorm, measurements, listener);
546 }
547
548 /**
549 * Constructor.
550 *
551 * @param groundTruthMagneticFluxDensityNorm ground truth magnetic flux density norm expressed in Teslas (T).
552 * @param measurements collection of body magnetic flux density
553 * measurements with standard deviation of
554 * magnetometer measurements taken at the same
555 * position with zero velocity and unknown different
556 * orientations.
557 * @param commonAxisUsed indicates whether z-axis is assumed to be common
558 * for the accelerometer, gyroscope and magnetometer.
559 * @throws IllegalArgumentException if provided magnetic flux norm value is negative.
560 */
561 public KnownMagneticFluxDensityNormMagnetometerCalibrator(
562 final Double groundTruthMagneticFluxDensityNorm,
563 final Collection<StandardDeviationBodyMagneticFluxDensity> measurements, final boolean commonAxisUsed) {
564 super(groundTruthMagneticFluxDensityNorm, measurements, commonAxisUsed);
565 }
566
567 /**
568 * Constructor.
569 *
570 * @param groundTruthMagneticFluxDensityNorm ground truth magnetic flux density norm expressed in Teslas (T).
571 * @param measurements collection of body magnetic flux density
572 * measurements with standard deviation of
573 * magnetometer measurements taken at the same
574 * position with zero velocity and unknown different
575 * orientations.
576 * @param commonAxisUsed indicates whether z-axis is assumed to be common
577 * for the accelerometer, gyroscope and magnetometer.
578 * @param listener listener to handle events raised by this calibrator.
579 * @throws IllegalArgumentException if provided magnetic flux norm value is negative.
580 */
581 public KnownMagneticFluxDensityNormMagnetometerCalibrator(
582 final Double groundTruthMagneticFluxDensityNorm,
583 final Collection<StandardDeviationBodyMagneticFluxDensity> measurements, final boolean commonAxisUsed,
584 final KnownMagneticFluxDensityNormMagnetometerCalibratorListener listener) {
585 super(groundTruthMagneticFluxDensityNorm, measurements, commonAxisUsed, listener);
586 }
587
588 /**
589 * Constructor.
590 *
591 * @param groundTruthMagneticFluxDensityNorm ground truth magnetic flux density norm expressed in Teslas (T).
592 * @param measurements collection of body magnetic flux density
593 * measurements with standard deviation of
594 * magnetometer measurements taken at the same
595 * position with zero velocity and unknown different
596 * orientations.
597 * @param initialHardIron initial hard-iron to find a solution.
598 * @throws IllegalArgumentException if provided magnetic flux norm value is negative,
599 * or if provided hard-iron array does not have length 3.
600 */
601 public KnownMagneticFluxDensityNormMagnetometerCalibrator(
602 final Double groundTruthMagneticFluxDensityNorm,
603 final Collection<StandardDeviationBodyMagneticFluxDensity> measurements, final double[] initialHardIron) {
604 super(groundTruthMagneticFluxDensityNorm, measurements, initialHardIron);
605 }
606
607 /**
608 * Constructor.
609 *
610 * @param groundTruthMagneticFluxDensityNorm ground truth magnetic flux density norm expressed in Teslas (T).
611 * @param measurements collection of body magnetic flux density
612 * measurements with standard deviation of
613 * magnetometer measurements taken at the same
614 * position with zero velocity and unknown different
615 * orientations.
616 * @param initialHardIron initial hard-iron to find a solution.
617 * @param listener listener to handle events raised by this calibrator.
618 * @throws IllegalArgumentException if provided magnetic flux norm value is negative,
619 * or if provided hard-iron array does not have length 3.
620 */
621 public KnownMagneticFluxDensityNormMagnetometerCalibrator(
622 final Double groundTruthMagneticFluxDensityNorm,
623 final Collection<StandardDeviationBodyMagneticFluxDensity> measurements, final double[] initialHardIron,
624 final KnownMagneticFluxDensityNormMagnetometerCalibratorListener listener) {
625 super(groundTruthMagneticFluxDensityNorm, measurements, initialHardIron, listener);
626 }
627
628 /**
629 * Constructor.
630 *
631 * @param groundTruthMagneticFluxDensityNorm ground truth magnetic flux density norm expressed in Teslas (T).
632 * @param measurements collection of body magnetic flux density
633 * measurements with standard deviation of
634 * magnetometer measurements taken at the same
635 * position with zero velocity and unknown different
636 * orientations.
637 * @param commonAxisUsed indicates whether z-axis is assumed to be common
638 * for the accelerometer, gyroscope and magnetometer.
639 * @param initialHardIron initial hard-iron to find a solution.
640 * @throws IllegalArgumentException if provided magnetic flux norm value is negative,
641 * or if provided hard-iron array does not have length 3.
642 */
643 public KnownMagneticFluxDensityNormMagnetometerCalibrator(
644 final Double groundTruthMagneticFluxDensityNorm,
645 final Collection<StandardDeviationBodyMagneticFluxDensity> measurements, final boolean commonAxisUsed,
646 final double[] initialHardIron) {
647 super(groundTruthMagneticFluxDensityNorm, measurements, commonAxisUsed, initialHardIron);
648 }
649
650 /**
651 * Constructor.
652 *
653 * @param groundTruthMagneticFluxDensityNorm ground truth magnetic flux density norm expressed in Teslas (T).
654 * @param measurements collection of body magnetic flux density
655 * measurements with standard deviation of
656 * magnetometer measurements taken at the same
657 * position with zero velocity and unknown different
658 * orientations.
659 * @param commonAxisUsed indicates whether z-axis is assumed to be common
660 * for the accelerometer, gyroscope and magnetometer.
661 * @param initialHardIron initial hard-iron to find a solution.
662 * @param listener listener to handle events raised by this calibrator.
663 * @throws IllegalArgumentException if provided magnetic flux norm value is negative,
664 * or if provided hard-iron array does not have length 3.
665 */
666 public KnownMagneticFluxDensityNormMagnetometerCalibrator(
667 final Double groundTruthMagneticFluxDensityNorm,
668 final Collection<StandardDeviationBodyMagneticFluxDensity> measurements, final boolean commonAxisUsed,
669 final double[] initialHardIron, final KnownMagneticFluxDensityNormMagnetometerCalibratorListener listener) {
670 super(groundTruthMagneticFluxDensityNorm, measurements, commonAxisUsed, initialHardIron, listener);
671 }
672
673 /**
674 * Constructor.
675 *
676 * @param groundTruthMagneticFluxDensityNorm ground truth magnetic flux density norm expressed in Teslas (T).
677 * @param measurements collection of body magnetic flux density
678 * measurements with standard deviation of
679 * magnetometer measurements taken at the same
680 * position with zero velocity and unknown different
681 * orientations.
682 * @param initialHardIron initial hard-iron to find a solution.
683 * @throws IllegalArgumentException if provided magnetic flux norm value is negative,
684 * or if provided hard-iron matrix is not 3x1.
685 */
686 public KnownMagneticFluxDensityNormMagnetometerCalibrator(
687 final Double groundTruthMagneticFluxDensityNorm,
688 final Collection<StandardDeviationBodyMagneticFluxDensity> measurements, final Matrix initialHardIron) {
689 super(groundTruthMagneticFluxDensityNorm, measurements, initialHardIron);
690 }
691
692 /**
693 * Constructor.
694 *
695 * @param groundTruthMagneticFluxDensityNorm ground truth magnetic flux density norm expressed in Teslas (T).
696 * @param measurements collection of body magnetic flux density
697 * measurements with standard deviation of
698 * magnetometer measurements taken at the same
699 * position with zero velocity and unknown different
700 * orientations.
701 * @param initialHardIron initial hard-iron to find a solution.
702 * @param listener listener to handle events raised by this calibrator.
703 * @throws IllegalArgumentException if provided magnetic flux norm value is negative,
704 * or if provided hard-iron matrix is not 3x1.
705 */
706 public KnownMagneticFluxDensityNormMagnetometerCalibrator(
707 final Double groundTruthMagneticFluxDensityNorm,
708 final Collection<StandardDeviationBodyMagneticFluxDensity> measurements, final Matrix initialHardIron,
709 final KnownMagneticFluxDensityNormMagnetometerCalibratorListener listener) {
710 super(groundTruthMagneticFluxDensityNorm, measurements, initialHardIron, listener);
711 }
712
713 /**
714 * Constructor.
715 *
716 * @param groundTruthMagneticFluxDensityNorm ground truth magnetic flux density norm expressed in Teslas (T).
717 * @param measurements collection of body magnetic flux density
718 * measurements with standard deviation of
719 * magnetometer measurements taken at the same
720 * position with zero velocity and unknown different
721 * orientations.
722 * @param commonAxisUsed indicates whether z-axis is assumed to be common
723 * for the accelerometer, gyroscope and magnetometer.
724 * @param initialHardIron initial hard-iron to find a solution.
725 * @throws IllegalArgumentException if provided magnetic flux norm value is negative,
726 * or if provided hard-iron matrix is not 3x1.
727 */
728 public KnownMagneticFluxDensityNormMagnetometerCalibrator(
729 final Double groundTruthMagneticFluxDensityNorm,
730 final Collection<StandardDeviationBodyMagneticFluxDensity> measurements, final boolean commonAxisUsed,
731 final Matrix initialHardIron) {
732 super(groundTruthMagneticFluxDensityNorm, measurements, commonAxisUsed, initialHardIron);
733 }
734
735 /**
736 * Constructor.
737 *
738 * @param groundTruthMagneticFluxDensityNorm ground truth magnetic flux density norm expressed in Teslas (T).
739 * @param measurements collection of body magnetic flux density
740 * measurements with standard deviation of
741 * magnetometer measurements taken at the same
742 * position with zero velocity and unknown different
743 * orientations.
744 * @param commonAxisUsed indicates whether z-axis is assumed to be common
745 * for the accelerometer, gyroscope and magnetometer.
746 * @param initialHardIron initial hard-iron to find a solution.
747 * @param listener listener to handle events raised by this calibrator.
748 * @throws IllegalArgumentException if provided magnetic flux norm value is negative,
749 * or if provided hard-iron matrix is not 3x1.
750 */
751 public KnownMagneticFluxDensityNormMagnetometerCalibrator(
752 final Double groundTruthMagneticFluxDensityNorm,
753 final Collection<StandardDeviationBodyMagneticFluxDensity> measurements, final boolean commonAxisUsed,
754 final Matrix initialHardIron, final KnownMagneticFluxDensityNormMagnetometerCalibratorListener listener) {
755 super(groundTruthMagneticFluxDensityNorm, measurements, commonAxisUsed, initialHardIron, listener);
756 }
757
758 /**
759 * Constructor.
760 *
761 * @param groundTruthMagneticFluxDensityNorm ground truth magnetic flux density norm expressed in Teslas (T).
762 * @param measurements collection of body magnetic flux density
763 * measurements with standard deviation of
764 * magnetometer measurements taken at the same
765 * position with zero velocity and unknown different
766 * orientations.
767 * @param initialHardIron initial hard-iron to find a solution.
768 * @param initialMm initial soft-iron matrix containing scale factors
769 * and cross coupling errors.
770 * @throws IllegalArgumentException if provided magnetic flux norm value is negative,
771 * or if provided hard-iron matrix is not 3x1 or if
772 * soft-iron matrix is not 3x3.
773 */
774 public KnownMagneticFluxDensityNormMagnetometerCalibrator(
775 final Double groundTruthMagneticFluxDensityNorm,
776 final Collection<StandardDeviationBodyMagneticFluxDensity> measurements, final Matrix initialHardIron,
777 final Matrix initialMm) {
778 super(groundTruthMagneticFluxDensityNorm, measurements, initialHardIron, initialMm);
779 }
780
781 /**
782 * Constructor.
783 *
784 * @param groundTruthMagneticFluxDensityNorm ground truth magnetic flux density norm expressed in Teslas (T).
785 * @param measurements collection of body magnetic flux density
786 * measurements with standard deviation of
787 * magnetometer measurements taken at the same
788 * position with zero velocity and unknown different
789 * orientations.
790 * @param initialHardIron initial hard-iron to find a solution.
791 * @param initialMm initial soft-iron matrix containing scale factors
792 * and cross coupling errors.
793 * @param listener listener to handle events raised by this calibrator.
794 * @throws IllegalArgumentException if provided magnetic flux norm value is negative,
795 * or if provided hard-iron matrix is not 3x1 or if
796 * soft-iron matrix is not 3x3.
797 */
798 public KnownMagneticFluxDensityNormMagnetometerCalibrator(
799 final Double groundTruthMagneticFluxDensityNorm,
800 final Collection<StandardDeviationBodyMagneticFluxDensity> measurements, final Matrix initialHardIron,
801 final Matrix initialMm, final KnownMagneticFluxDensityNormMagnetometerCalibratorListener listener) {
802 super(groundTruthMagneticFluxDensityNorm, measurements, initialHardIron, initialMm, listener);
803 }
804
805 /**
806 * Constructor.
807 *
808 * @param groundTruthMagneticFluxDensityNorm ground truth magnetic flux density norm expressed in Teslas (T).
809 * @param measurements collection of body magnetic flux density
810 * measurements with standard deviation of
811 * magnetometer measurements taken at the same
812 * position with zero velocity and unknown different
813 * orientations.
814 * @param commonAxisUsed indicates whether z-axis is assumed to be common
815 * for the accelerometer, gyroscope and magnetometer.
816 * @param initialHardIron initial hard-iron to find a solution.
817 * @param initialMm initial soft-iron matrix containing scale factors
818 * and cross coupling errors.
819 * @throws IllegalArgumentException if provided magnetic flux norm value is negative,
820 * or if provided hard-iron matrix is not 3x1
821 * or if soft-iron matrix is not 3x3.
822 */
823 public KnownMagneticFluxDensityNormMagnetometerCalibrator(
824 final Double groundTruthMagneticFluxDensityNorm,
825 final Collection<StandardDeviationBodyMagneticFluxDensity> measurements, final boolean commonAxisUsed,
826 final Matrix initialHardIron, final Matrix initialMm) {
827 super(groundTruthMagneticFluxDensityNorm, measurements, commonAxisUsed, initialHardIron, initialMm);
828 }
829
830 /**
831 * Constructor.
832 *
833 * @param groundTruthMagneticFluxDensityNorm ground truth magnetic flux density norm expressed in Teslas (T).
834 * @param measurements collection of body magnetic flux density
835 * measurements with standard deviation of
836 * magnetometer measurements taken at the same
837 * position with zero velocity and unknown different
838 * orientations.
839 * @param commonAxisUsed indicates whether z-axis is assumed to be common
840 * for the accelerometer, gyroscope and magnetometer.
841 * @param initialHardIron initial hard-iron to find a solution.
842 * @param initialMm initial soft-iron matrix containing scale factors
843 * and cross coupling errors.
844 * @param listener listener to handle events raised by this calibrator.
845 * @throws IllegalArgumentException if provided magnetic flux norm value is negative,
846 * or if provided hard-iron matrix is not 3x1
847 * or if soft-iron matrix is not 3x3.
848 */
849 public KnownMagneticFluxDensityNormMagnetometerCalibrator(
850 final Double groundTruthMagneticFluxDensityNorm,
851 final Collection<StandardDeviationBodyMagneticFluxDensity> measurements, final boolean commonAxisUsed,
852 final Matrix initialHardIron, final Matrix initialMm,
853 final KnownMagneticFluxDensityNormMagnetometerCalibratorListener listener) {
854 super(groundTruthMagneticFluxDensityNorm, measurements, commonAxisUsed, initialHardIron, initialMm, listener);
855 }
856
857 /**
858 * Sets ground truth magnetic flux density norm to be expected at location where
859 * measurements have been made, expressed in Teslas (T).
860 *
861 * @param groundTruthMagneticFluxDensityNorm ground truth magnetic flux density norm or null if undefined.
862 * @throws IllegalArgumentException if provided value is negative.
863 * @throws LockedException if calibrator is currently running.
864 */
865 public void setGroundTruthMagneticFluxDensityNorm(final Double groundTruthMagneticFluxDensityNorm)
866 throws LockedException {
867 if (isRunning()) {
868 throw new LockedException();
869 }
870
871 internalSetGroundTruthMagneticFluxDensityNorm(groundTruthMagneticFluxDensityNorm);
872 }
873
874 /**
875 * Sets ground truth magnetic flux density norm to be expected at location where
876 * measurements have been made.
877 *
878 * @param groundTruthMagneticFluxDensityNorm ground truth magnetic flux density norm or null if undefined.
879 * @throws IllegalArgumentException if provided value is negative.
880 * @throws LockedException if calibrator is currently running.
881 */
882 public void setGroundTruthMagneticFluxDensityNorm(final MagneticFluxDensity groundTruthMagneticFluxDensityNorm)
883 throws LockedException {
884 if (isRunning()) {
885 throw new LockedException();
886 }
887 if (groundTruthMagneticFluxDensityNorm != null) {
888 internalSetGroundTruthMagneticFluxDensityNorm(MagneticFluxDensityConverter.convert(
889 groundTruthMagneticFluxDensityNorm.getValue().doubleValue(),
890 groundTruthMagneticFluxDensityNorm.getUnit(),
891 MagneticFluxDensityUnit.TESLA));
892 } else {
893 internalSetGroundTruthMagneticFluxDensityNorm(null);
894 }
895 }
896
897 /**
898 * Indicates whether calibrator is ready to start.
899 *
900 * @return true if calibrator is ready, false otherwise.
901 */
902 @Override
903 public boolean isReady() {
904 return super.isReady() && getGroundTruthMagneticFluxDensityNorm() != null;
905 }
906 }