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