IMU Calibration

This documentation was generated with the assistance of AI. Please report any inaccuracies.

The com.irurueta.navigation.inertial.calibration package (and its accelerometer, gyroscope, magnetometer, bias, generators, intervals, and noise sub-packages) estimates the systematic errors of an accelerometer, gyroscope, and/or magnetometer — bias, scale factor, and cross-axis coupling — and, once known, corrects ("fixes") raw sensor readings back to their true values.

This package is by far the largest in the library (around 280 classes). Rather than one page per class, this documentation groups classes by what they do, since the vast majority of classes are boilerplate variants (different robust outlier-rejection strategies, different measurement orderings, unit conversions) of a much smaller number of distinct algorithms.

The sensor error model

Every calibratable sensor in this library (accelerometer, gyroscope, magnetometer) is assumed to follow the same linear error model: a fixed bias, plus a matrix of scale-factor and cross-coupling errors applied to the true signal, plus noise . For the accelerometer:

The gyroscope additionally picks up a g-dependent bias driven by the specific force sensed by the accelerometer (typically caused by mass unbalance in the spinning/vibrating element):

and the magnetometer follows the accelerometer’s form, with "hard iron" playing the role of bias and "soft iron" playing the role of cross-coupling:

Sensor error model: bias offset plus scale-factor and cross-coupling misalignment

Here is the full 3x3 matrix with the scale-factor errors on the diagonal and the cross-coupling terms off it, and the model applies to the true signal, so is an ideal sensor. The noise is white, with a per-sample standard deviation for sampling interval (see PSD and root-PSD); it is estimated separately from bias and matrices, never by the calibrators themselves.

Calibration means estimating and (and, for the gyroscope, ) from measurements taken at known or partially-known references. Fixing means applying the inverse of this model to a raw reading once those parameters are known, to recover (see Fixers: Undoing the Sensor Error Model).

, , and above are always resolved about body-frame axes — the raw sensor reading itself is never "in NED." NED only appears as one of two interchangeable ways to describe the known frame/position some calibrators need alongside a measurement: FrameBodyKinematics (see Calibration Data Model) stores that frame internally as ECEFFrame and exposes an NED-converted view via getNedFrame()/setNedFrame(), and calibrator families such as KnownPositionAccelerometerCalibrator (Accelerometer Calibration) and TurntableGyroscopeCalibrator (Gyroscope Calibration) accept a position as either NEDPosition or ECEFPosition — neither is mandatory. Only the magnetometer’s WMM-position families (Magnetometer Calibration) and the bias estimators require geodetic (NED-style latitude/longitude/height) position, since that is what the WMM and gravity models are keyed on.

Do not confuse the point above (the resolving frame for a known position, which is flexible) with the body-frame axis convention of , , and themselves, which is not flexible: every equation and every Ma/Mg/Gg/Mm matrix in this package assumes the raw sensor vector already follows Groves' forward-right-down (FRD) body convention (§2.1.4, [book-groves]) — see the same warning on the estimators page for the exact conversion to apply if your IMU instead reports an ENU-aligned body convention. This library performs no such conversion itself; getting it wrong will not raise an error, only wrong bias/scale-factor/cross-coupling estimates.

Map of the package

Page Covers

Calibration algorithms

The mathematics shared by all calibrators: linear least-squares system, non-linear norm-based fit (Levenberg-Marquardt), robust estimation and the Tedaldi et al. method.

Calibration Data Model

Data containers shared by every calibrator: triads, BodyKinematics-based measurement types, IMUErrors.

Fixers: Undoing the Sensor Error Model

AccelerationFixer, AngularRateFixer, MagneticFluxDensityFixer, BodyKinematicsFixer, IMUErrorsCreator — applying the inverse error model.

Accelerometer Calibration

The accelerometer sub-package (79 files): six Known…​ families, each with the five robust wrappers.

Gyroscope Calibration

The gyroscope sub-package (86 files), including the Tedaldi et al. "Easy" calibrator and quaternion integrators.

Magnetometer Calibration

The magnetometer sub-package (79 files), mirroring the accelerometer’s algorithm/robust-estimator structure.

Static/Dynamic Interval Detection and Measurement Generation

Static/dynamic interval detection and measurement-sequence generation — the preprocessing step before calibration.

Noise and Approximate-Bias Estimators

Noise (PSD/root-PSD) and approximate-bias estimators used to seed calibrators and Kalman filter configs.

Which calibrator family uses which algorithm

Which algorithm a calibrator runs depends on what is known about each measurement: the full reference signal, only its norm, or nothing but the raw motion. The names below are the class-name stems; each page of the sensor family lists the concrete classes.

Family What is known Algorithm and sensor page

KnownFrame, KnownBiasAndFrame (accelerometer, gyroscope, magnetometer; the magnetometer’s version is KnownHardIronAndFrame)

Position, orientation and (for the gyroscope) angular rate of the body at every measurement, so the true signal is known as a vector. Linear and non-linear least-squares variants exist.

Linear least squares (the non-linear variants minimise the same residual with an analytical Jacobian, see calibration/algorithms.adoc#nonlinear-model). Pages: Accelerometer Calibration, Gyroscope Calibration, Magnetometer Calibration.

KnownGravityNorm, KnownBiasAndGravityNorm, KnownPosition, KnownBiasAndPosition (accelerometer); KnownMagneticFluxDensityNorm, KnownHardIronMagneticFluxDensityNorm, KnownPositionAndInstant, KnownHardIronPositionAndInstant (magnetometer)

Only the norm of the true signal: a given gravity norm, the gravity model evaluated at a known position, or the WMM field magnitude at a known position and instant. Orientation is unknown.

Non-linear least squares (Levenberg-Marquardt over the norm residual; the Jacobian is estimated numerically). Pages: Accelerometer Calibration, Magnetometer Calibration.

Turntable, KnownBiasTurntable (gyroscope)

The IMU spins flat on a turntable at constant rate; the true angular-rate norm is known, orientation and position are not.

Non-linear least squares, using the norm of the angular rate. Page: Gyroscope Calibration.

Easy, KnownBiasEasy (gyroscope)

Nothing external: static-moving-static sequences recorded by hand, with gravity as the only reference.

Tedaldi et al. method: integrates the angular rate across each sequence and compares the rotated gravity direction. It estimates the gyroscope bias inside the same fit (except in the KnownBias variant) and, as in the paper, estimates a full (general) gyroscope matrix without the g-dependent term by default. Page: Gyroscope Calibration.

Robust…​ wrappers (every family above)

The same inputs, but some measurements may be outliers.

Robust estimation: RANSAC, MSAC, LMedS, PROSAC or PROMedS around the base calibrator.

The quantities that feed these calibrators come from the preprocessing stage in Static/Dynamic Interval Detection and Measurement Generation, and the root-PSD and approximate-bias estimators in Noise and Approximate-Bias Estimators seed or complement them. Once calibrated, the readings are corrected with the fixers.

Why so many classes per algorithm?

Every non-trivial calibration algorithm in accelerometer, gyroscope, and magnetometer appears in up to six forms:

flowchart LR A["Known<X>...Calibrator\n(base: assumes every measurement is trustworthy)"] --> B["RANSACRobust...\n(random sample consensus)"] A --> C["MSACRobust...\n(RANSAC + soft cost function)"] A --> D["LMedSRobust...\n(least median of squares)"] A --> E["PROSACRobust...\n(RANSAC + measurement quality ordering)"] A --> F["PROMedSRobust...\n(LMedS + measurement quality ordering)"]

The base (non-robust) calibrator is the one that actually implements the algorithm’s math — it assumes every input measurement can be trusted. The five Robust* classes wrap it with an outlier-rejection strategy from `irurueta-numerical-computing’s robust-estimator framework, useful when some measurements (e.g. from a noisy or disturbed static interval) might be bad. This documentation describes each algorithm’s math once and lists all six forms in a summary table, rather than repeating the same equations six times.

Where to go next