Accelerometer Calibration

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

The com.irurueta.navigation.inertial.calibration.accelerometer package (79 classes) estimates accelerometer bias and the scale-factor/cross-coupling matrix from the model introduced in the sensor error model:

Every calibrator needs several measurements of at different, sufficiently varied orientations, together with the corresponding (or enough information to derive it). The 79 classes reduce to 6 distinct algorithms, differing only in how is known and whether the bias is already known:

Family How is obtained Solves for Min. measurements

KnownFrame

Directly: the full position/orientation/velocity frame at each measurement is known, so the specific force that an ideal sensor would read follows from the frame (gravity rotated into body axes plus any motion).

+

4 (linear and non-linear solvers)

KnownBiasAndFrame

Same as above

Only (bias given)

3 (linear and non-linear solvers)

KnownGravityNorm

Indirectly: device held static at several unknown orientations; only the magnitude is assumed known (e.g. local standard gravity).

+

13 (10 with common z-axis)

KnownBiasAndGravityNorm

Same as above

Only

10 (7 with common z-axis)

KnownPosition

Indirectly: device static at several unknown orientations, but at a known geodetic position: the gravity magnitude is computed from the position with the ECEFGravityEstimator (see gravity) instead of being assumed.

+

13 (10 with common z-axis)

KnownBiasAndPosition

Same as above

Only

10 (7 with common z-axis)

The equations behind each row are written out in The system of equations per family, and the numerical methods in Calibration algorithms.

Usage examples

Javadoc and source links for every class used in the examples below are collected in the Class Reference table at the end of this page.

The snippets below are simplified illustrations (not full copies of the test suite) showing how to construct each family’s plain calibrator, run calibrate(), and read back the results. Measurement collection is elided with // …​ since in practice it comes from several real orientations/positions of the device.

KnownFrame

KnownFrameAccelerometerLinearLeastSquaresCalibrator takes a collection of FrameBodyKinematics (measured specific force plus the known frame it was taken at) and solves for both bias and :

List<FrameBodyKinematics> measurements = new ArrayList<>();
// ... add FrameBodyKinematics(bodyKinematics, ecefFrame, previousEcefFrame) for each measurement

var calibrator = new KnownFrameAccelerometerLinearLeastSquaresCalibrator(measurements);
calibrator.calibrate();

double[] estimatedBiases = calibrator.getEstimatedBiases();
Matrix estimatedMa = calibrator.getEstimatedMa();

KnownBiasAndFrame

Same measurements, but the bias is already known and passed to the constructor, so only is solved for:

List<FrameBodyKinematics> measurements = new ArrayList<>();
// ... add FrameBodyKinematics measurements as above

double biasX = 0.01, biasY = 0.02, biasZ = 0.03; // known bias, in m/s^2

var calibrator = new KnownBiasAndFrameAccelerometerLinearLeastSquaresCalibrator(
        measurements, biasX, biasY, biasZ);
calibrator.calibrate();

Matrix estimatedMa = calibrator.getEstimatedMa();

KnownGravityNorm

The device is held static at several unknown orientations; each StandardDeviationBodyKinematics measurement only needs the measured kinematics plus its noise standard deviations, and the known gravity-norm magnitude is passed once to the calibrator:

List<StandardDeviationBodyKinematics> measurements = new ArrayList<>();
// ... add StandardDeviationBodyKinematics(bodyKinematics, specificForceStd, angularRateStd)
//     for each static orientation

double groundTruthGravityNorm = 9.81; // m/s^2, e.g. local standard gravity

var calibrator = new KnownGravityNormAccelerometerCalibrator(groundTruthGravityNorm, measurements);
calibrator.calibrate();

double[] estimatedBiases = calibrator.getEstimatedBiases();
Matrix estimatedMa = calibrator.getEstimatedMa();

KnownBiasAndGravityNorm

Same idea, but with a known bias supplied up front so only is estimated:

List<StandardDeviationBodyKinematics> measurements = new ArrayList<>();
// ... add StandardDeviationBodyKinematics measurements as above

double groundTruthGravityNorm = 9.81; // m/s^2
double biasX = 0.01, biasY = 0.02, biasZ = 0.03; // known bias, in m/s^2

var calibrator = new KnownBiasAndGravityNormAccelerometerCalibrator(
        groundTruthGravityNorm, measurements, biasX, biasY, biasZ);
calibrator.calibrate();

Matrix estimatedMa = calibrator.getEstimatedMa();

KnownPosition

Instead of an assumed gravity-norm magnitude, the device’s known geodetic position is used to derive the gravity magnitude internally (the position is converted to ECEF and passed to ECEFGravityEstimator):

List<StandardDeviationBodyKinematics> measurements = new ArrayList<>();
// ... add StandardDeviationBodyKinematics measurements as above, all taken at the same position

NEDPosition position = new NEDPosition(latitude, longitude, height);

var calibrator = new KnownPositionAccelerometerCalibrator(position, measurements);
calibrator.calibrate();

double[] estimatedBiases = calibrator.getEstimatedBiases();
Matrix estimatedMa = calibrator.getEstimatedMa();

KnownBiasAndPosition

Same as KnownPosition, but with the bias already known:

List<StandardDeviationBodyKinematics> measurements = new ArrayList<>();
// ... add StandardDeviationBodyKinematics measurements as above

NEDPosition position = new NEDPosition(latitude, longitude, height);
double[] bias = new double[]{0.01, 0.02, 0.03}; // known bias, in m/s^2

var calibrator = new KnownBiasAndPositionAccelerometerCalibrator(position, measurements, bias);
calibrator.calibrate();

Matrix estimatedMa = calibrator.getEstimatedMa();

Robust wrapper: RANSACRobustKnownFrameAccelerometerCalibrator

Robust variants of KnownFrame need each measurement’s standard deviation (a List<StandardDeviationFrameBodyKinematics> instead of a plain FrameBodyKinematics collection) so that residuals can be weighed, and RANSAC additionally exposes a threshold controlling how large a residual is still considered an inlier:

List<StandardDeviationFrameBodyKinematics> measurements = new ArrayList<>();
// ... add StandardDeviationFrameBodyKinematics(bodyKinematics, ecefFrame, specificForceStd, angularRateStd)
//     for each measurement, including a few outliers

var calibrator = new RANSACRobustKnownFrameAccelerometerCalibrator(measurements);
calibrator.setThreshold(0.1); // m/s^2, default is RANSACRobustKnownFrameAccelerometerCalibrator.DEFAULT_THRESHOLD
calibrator.calibrate();

double[] estimatedBiases = calibrator.getEstimatedBiases();
Matrix estimatedMa = calibrator.getEstimatedMa();
KnownGravityNorm/KnownBiasAndGravityNorm is the accelerometer half of the same idea as the Tedaldi et al. "Easy" gyroscope calibrator: hold the device static at several orientations and rely only on the (approximately known, ~9.81 m/s²) magnitude of gravity — no turntable or precisely known frame needed. In this codebase, the two ideas are implemented as siblings rather than a single combined class.

The system of equations per family

All families fit the same model. Writing for the full gain matrix, one measurement of the sensor is

What changes between families is what is known about , and therefore which equation each measurement contributes. The unknowns are always the same: the bias (3 values) and the entries of (9 values in general, 6 with the common z-axis assumption, which makes upper triangular; see the common z-axis reduction). The KnownBias…​ variants remove the three bias unknowns. The frame-based calibrators default to commonAxisUsed = false, while the gravity-norm and position based calibrators (KnownGravityNorm, KnownBiasAndGravityNorm, KnownPosition, KnownBiasAndPosition and the robust …​GravityNorm variants) default to commonAxisUsed = true (DEFAULT_USE_COMMON_Z_AXIS), see the note under KnownGravityNorm: a norm constraint.

KnownFrame: from the frame

Each measurement is a FrameBodyKinematics: the measured specific force, the ECEF frame of the body when it was taken, the previous frame and the time interval between them. The calibrator gives the frame pair to ECEFKinematicsEstimator, which returns the specific force an ideal accelerometer would have measured. That is , and no iteration is needed to obtain it. The model then gives three linear scalar equations per measurement (one per axis), for example the x axis:

Stacked as , the full derivation, the column order of and the block are given in the linear model. In short, with unknowns ordered as the right-hand side is and for the KnownBiasAndFrame variants it is with the three bias columns dropped.

The linear calibrators solve this system directly. The non-linear KnownFrame calibrators describe exactly the same model to a Levenberg-Marquardt fitter and supply its Jacobian analytically (the entries of ); because the model is linear in the parameters this converges in very few iterations. The non-linear form lets you give an initial guess and obtain the covariance and goodness-of-fit values of the fitter, which are the reasons to pick it.

Each measurement adds three equations, but the three rows do not share unknowns: the x row involves only , the y row only , and the z row only . Each row therefore has four unknowns in the general case and needs four measurements, or three once the bias is known. This agrees with the constants in the code: MINIMUM_MEASUREMENTS is 4 for KnownFrame and 3 for KnownBiasAndFrame, in both the linear and the non-linear classes, and it does not change with the common z-axis flag.

KnownGravityNorm: a norm constraint

Here the orientation of each static measurement is unknown, so cannot be computed. All that is known is its length: a body at rest feels a specific force of magnitude , whatever its attitude. The equation contributed by measurement is a single scalar one,

which is non-linear in and . It is solved by Levenberg-Marquardt over the reparametrization described in the non-linear model, with the Jacobian obtained numerically (GradientEstimator, not an analytical expression). The norm alone cannot fix the rotation of the sensor frame, so the general (nine-entry) has equivalent solutions; the common z-axis option removes that ambiguity.

Since this release the norm-based calibrators default to the common z-axis (upper-triangular) model, the only one that is observable from norm constraints. The general (full 3x3) mode is still available with setCommonAxisUsed(false), but the norm is invariant to a rotation of the sensor frame, so the estimated is then defined only up to a rotation (its covariance is singular in those directions) and the result should not be compared with a ground truth matrix directly. Code that relied on the previous default (false) now gets a different, upper-triangular matrix and a lower minimum number of measurements (10 / 7 instead of 13 / 10).

The squared-norm residual is kept (it is the minimal change with respect to the paper’s cost), and its standard deviation is made consistent with the fitted quantity: if the specific force has standard deviation , the squared norm has standard deviation approximately , which is what setInputData gives to the fitter. Previously itself was given, so the chi-square was off by a factor of about and the reported covariance was wrongly scaled. The norm is not otherwise reformulated: this is one of the deliberate differences with the paper/imu_tk.

Minimum measurements. One scalar equation per measurement, and the implementation asks for one more measurement than unknowns:

Calibrator Unknowns Constant in code Minimum measurements

KnownGravityNorm / KnownPosition, general (not the default any more)

12

MINIMUM_MEASUREMENTS_GENERAL

13

KnownGravityNorm / KnownPosition, common z-axis

9

MINIMUM_MEASUREMENTS_COMMON_Z_AXIS

10

KnownBiasAndGravityNorm / KnownBiasAndPosition, general

9

MINIMUM_MEASUREMENTS_GENERAL

10

KnownBiasAndGravityNorm / KnownBiasAndPosition, common z-axis

6

MINIMUM_MEASUREMENTS_COMMON_Z_AXIS

7

KnownPosition: the norm from the gravity model

KnownPosition and KnownBiasAndPosition use exactly the equation above. The only difference is where comes from: instead of a value supplied by the user, setting the position (a NEDPosition is converted to ECEF with zero velocity) makes the calibrator evaluate ECEFGravityEstimator at that position and use the norm of the resulting gravity vector. Unknown counts and minimum measurements are therefore identical to the KnownGravityNorm rows, and all measurements are assumed to have been taken at that one position.

The new commonAxisUsed = true default applies to KnownPosition and KnownBiasAndPosition (they share the gravity-norm base class) and also to the robust …​RobustKnownPosition…​ and …​RobustKnownBiasAndPosition…​ wrappers, which declare their own DEFAULT_USE_COMMON_Z_AXIS.

Worked example: the linear system layout

This example builds the KnownFrame system by hand for four static measurements, the minimum. The values are invented for illustration (they are not taken from the test suite) and are noise free, so the exact parameters are recovered. Take and a sensor with

At rest the specific force is minus gravity expressed in body axes, so with the sensor level (z down) it reads . The four orientations and the readings they produce through are:

k (m/s²) (m/s²)

1

2

3

4

With the library’s unknown order , the first two blocks are

Blocks 3 and 4 follow the same pattern with the entries placed in the columns of (for ) and of (for ). The stacked matrix is , and because the three output axes do not share unknowns it splits into three independent problems. The x axis, with unknowns , is

which are the true values. With real, noisy data you use more than four orientations and the least-squares solve averages the noise; an orientation set where, say, no measurement has a non-zero leaves the column empty and the system singular. For the same attitudes with the bias known, the bias columns and the term disappear and each axis needs only three measurements.

The worked example, and the observation that the three rows of the linear system are independent (which explains why the minimum is four), are derived from the layout in the code and are not stated in the Javadoc. The sensor values are made up for illustration.

Robust variants

Each family also has five Robust* wrappers (RANSAC, MSAC, LMedS, PROSAC and PROMedS) that run the plain calibrator on random subsets of the measurements, whose size defaults to the minimum above, and keep the hypothesis that best explains the data; see robust estimation for residuals, scoring and parameters. QualityScoredAccelerometerCalibrator is the interface that the PROSAC and PROMedS variants need their measurements to implement.

Supporting types

Class group Purpose

AccelerometerCalibrator, AccelerometerNonLinearCalibrator

Root marker interfaces implemented by every calibrator (all / non-linear-only, respectively).

AccelerometerCalibratorMeasurementType

Enum distinguishing which measurement container a given calibrator instance expects.

UnknownBiasAccelerometerCalibrator, UnknownBiasNonLinearAccelerometerCalibrator

Mixin interfaces exposing estimated bias getters, implemented by the "unknown bias" half of each family.

OrderedStandardDeviationBodyKinematicsAccelerometerCalibrator, OrderedStandardDeviationFrameBodyKinematicsAccelerometerCalibrator

Interfaces for calibrators that need an ordered measurement list (used by PROSAC-style robust variants).

UnorderedFrameBodyKinematicsAccelerometerCalibrator, UnorderedStandardDeviationBodyKinematicsAccelerometerCalibrator, UnorderedStandardDeviationFrameBodyKinematicsAccelerometerCalibrator

Interfaces for calibrators taking a plain, unordered measurement collection (the non-robust calibrators).

Class Reference

Javadoc and source links for the classes used in the examples above:

Class Javadoc Source

com.irurueta.navigation.inertial.calibration.accelerometer (79 classes)

Javadoc

Source

KnownFrameAccelerometerLinearLeastSquaresCalibrator

Javadoc

Source

KnownBiasAndFrameAccelerometerLinearLeastSquaresCalibrator

Javadoc

Source

KnownGravityNormAccelerometerCalibrator

Javadoc

Source

KnownBiasAndGravityNormAccelerometerCalibrator

Javadoc

Source

KnownPositionAccelerometerCalibrator

Javadoc

Source

KnownBiasAndPositionAccelerometerCalibrator

Javadoc

Source

RANSACRobustKnownFrameAccelerometerCalibrator

Javadoc

Source

FrameBodyKinematics

Javadoc

Source

StandardDeviationBodyKinematics

Javadoc

Source

StandardDeviationFrameBodyKinematics

Javadoc

Source

Where to go next