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 |
|---|---|---|---|
|
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) |
|
Same as above |
Only (bias given) |
3 (linear and non-linear solvers) |
|
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) |
|
Same as above |
Only |
10 (7 with common z-axis) |
|
Indirectly: device static at several unknown orientations, but at a known geodetic position: the gravity
magnitude is computed from the position with the |
+ |
13 (10 with common z-axis) |
|
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 GradientEstimator, not an analytical expression). The norm alone cannot fix the
rotation of the sensor frame, so the general (nine-entry)
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
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
setInputData gives to the fitter. Previously
Minimum measurements. One scalar equation per measurement, and the implementation asks for one more measurement than unknowns:
| Calibrator | Unknowns | Constant in code | Minimum measurements |
|---|---|---|---|
|
12 |
|
13 |
|
9 |
|
10 |
|
9 |
|
10 |
|
6 |
|
7 |
KnownPosition: the norm from the gravity model
KnownPosition and KnownBiasAndPosition use exactly the equation above. The only difference is where
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
At rest the specific force is minus gravity expressed in body axes, so with the sensor level (z down) it reads
| k | |
|
|
|---|---|---|---|
1 |
|
|
|
2 |
|
|
|
3 |
|
|
|
4 |
|
|
|
With the library’s unknown order
Blocks 3 and 4 follow the same pattern with the entries
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
|
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 |
|---|---|
|
Root marker interfaces implemented by every calibrator (all / non-linear-only, respectively). |
|
Enum distinguishing which measurement container a given calibrator instance expects. |
|
Mixin interfaces exposing estimated bias getters, implemented by the "unknown bias" half of each family. |
|
Interfaces for calibrators that need an ordered measurement list (used by PROSAC-style robust variants). |
|
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 |
|---|---|---|
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
Where to go next
-
Gyroscope Calibration — the Tedaldi et al. "Easy" calibrator and turntable-based gyroscope calibration.
-
Magnetometer Calibration — the same known-frame / known-norm / known-position structure, applied to hard-iron/soft-iron.
-
Static/Dynamic Interval Detection and Measurement Generation — how static-interval measurements like the ones
KnownGravityNormneeds are actually produced from a raw sensor stream. -
reference.adoc#bibliography — bibliography.