This documentation was generated with the assistance of AI. Please report any inaccuracies.
The com.irurueta.navigation.inertial.calibration.gyroscope package (86 classes) estimates gyroscope
bias , the scale-factor/cross-coupling matrix , and the
g-dependent cross-bias matrix (extra bias driven by the specific force the
accelerometer senses — typically from mass unbalance in the sensing element):
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.
Algorithm families
Family
Reference used
Solves for
Needs a turntable?
KnownFrame / KnownBiasAndFrame
Position, orientation, velocity and angular rate known at each measurement (linear and non-linear
least-squares variants, as with the accelerometer’s equivalent families).
+ + (or just the latter two if bias is known)
No, but requires precise external ground truth for angular rate.
Turntable / KnownBiasTurntable
IMU on a turntable spinning at a known, constant rate. The Earth rate seen at the known position is
subtracted, so the norm of the remaining true rate is the turntable rate. Fast enough that Earth rotation is
negligible, slow enough to be measured accurately.
+ + (or just the latter two if bias is known)
Yes.
Easy / KnownBiasEasy
[imu-tk] Tedaldi, Pretto, Menegatti: no turntable, no known frame. Several
sequences of motion, each bracketed by static periods, are captured and the gravity direction measured in
the static brackets stands in for ground truth (see the Tedaldi et al. method).
+ + (or just the latter two if bias is known)
No.
AccelerometerDependentGyroscopeCalibrator is the common interface marking calibrators that also need
(already-calibrated) accelerometer bias and cross-coupling, because the g-dependent term requires the true
specific force. TurntableGyroscopeCalibrator, KnownBiasTurntableGyroscopeCalibrator, EasyGyroscopeCalibrator
and KnownBiasEasyGyroscopeCalibrator implement it.
Unknowns and minimum data
All counts below are taken from the constants of the classes. A "measurement" is one body-kinematics sample
(KnownFrame, Turntable); a "sequence" is one BodyKinematicsSequence (Easy).
Calibrator
Unknowns (general)
Unknowns (common z-axis)
Minimum (general)
Minimum (common z-axis)
KnownFrame…LinearLeastSquares and …NonLinearLeastSquares: b, M, G
21
18
7 (a single MINIMUM_MEASUREMENTS)
7
KnownBiasAndFrame…: M, G
18
15
6 (a single MINIMUM_MEASUREMENTS)
6
Turntable / Easy, b and M only (the Easy default)
12
9
13
10
Turntable / Easy, b, M and G (the Turntable default)
21
18
22
19
KnownBiasTurntable / KnownBiasEasy, M only (the KnownBiasEasy default)
9
6
10
7
KnownBiasTurntable / KnownBiasEasy, M and G
18
15
19
16
The KnownFrame classes are linear in the unknowns and each measurement gives three equations, so
and measurements suffice, and the minimum is the same for
the linear and the non-linear classes and does not depend on the common-axis flag. The turntable and Easy
calibrators keep a minimum of one more than the number of unknowns: the Turntable classes produce one scalar
residual per measurement, and for Easy this is a deliberately conservative minimum (each sequence now provides
three equations, see Easy calibrators: integrated rotation versus gravity direction). Defaults: commonAxisUsed = true and estimateGDependentCrossBiases = true for
Turntable and KnownBiasTurntable; commonAxisUsed = false and estimateGDependentCrossBiases = false for
Easy, KnownBiasEasy and their robust variants (they follow the paper, see Easy calibrators: integrated rotation versus gravity direction); commonAxisUsed = false
for the KnownFrame classes. With the Easy defaults the minimum is therefore 13 sequences (Easy, 12
unknowns) or 10 sequences (KnownBiasEasy, 9 unknowns).
KnownFrame example
Each measurement pairs a BodyKinematics sample with the known ECEF frame (position, orientation, velocity)
at which it was taken. KnownFrameGyroscopeNonLinearLeastSquaresCalibrator refines an initial
, and guess through non-linear least squares:
// each measurement bundles a body kinematics sample with the known frame it was taken at
final Collection<StandardDeviationFrameBodyKinematics> measurements = new ArrayList<>();
// ...
measurements.add(new StandardDeviationFrameBodyKinematics(measuredKinematics, ecefFrame, ecefFrame,
timeIntervalSeconds, specificForceStandardDeviation, angularRateStandardDeviation));
// initial bg, Mg, Gg guesses close to the expected solution
final Matrix initialBias = new Matrix(3, 1);
final Matrix initialMg = new Matrix(3, 3);
final Matrix initialGg = new Matrix(3, 3);
final var calibrator = new KnownFrameGyroscopeNonLinearLeastSquaresCalibrator(measurements, false, initialBias,
initialMg, initialGg, this);
calibrator.calibrate();
final Matrix estimatedBg = calibrator.getEstimatedBiasesAsMatrix();
final Matrix estimatedMg = calibrator.getEstimatedMg();
final Matrix estimatedGg = calibrator.getEstimatedGg();
Turntable example
Measurements only need position (the turntable’s fixed location) plus the known, constant rotation rate —
no per-measurement orientation is required, since the turntable enforces it:
final NEDPosition position = new NEDPosition(latitude, longitude, height);
final double rotationRate = Constants.EARTH_ROTATION_RATE; // rad/s
final double timeInterval = TurntableGyroscopeCalibrator.DEFAULT_TIME_INTERVAL; // seconds
final Collection<StandardDeviationBodyKinematics> measurements = new ArrayList<>();
// ...
measurements.add(new StandardDeviationBodyKinematics(measuredKinematics, specificForceStandardDeviation,
angularRateStandardDeviation));
final Matrix initialBias = new Matrix(3, 1);
final Matrix initialMg = new Matrix(3, 3);
final Matrix initialGg = new Matrix(3, 3);
// accelerometer bias/cross-coupling are only used when the g-dependent term is estimated
// (setAccelerometerBias / setAccelerometerMa); here it is disabled with the second flag
final var calibrator = new TurntableGyroscopeCalibrator(position, rotationRate, timeInterval, measurements,
true, false, initialBias, initialMg, initialGg);
calibrator.calibrate();
final Matrix estimatedBg = calibrator.getEstimatedBiasesAsMatrix();
final Matrix estimatedMg = calibrator.getEstimatedMg();
final Matrix estimatedGg = calibrator.getEstimatedGg();
KnownFrame calibrators: linear in the unknowns
With a known frame at every measurement the true angular rate and the true
specific force are computed from the frame (the library derives both from the
ECEF frames of the measurement with its kinematics estimator). Moving the known
to the left of the error model of this page makes every unknown appear linearly:
With the common z-axis assumption is upper triangular (six entries), otherwise it has nine.
The code orders the unknowns as
(common axis; the general case has three more entries of ) and each measurement contributes a three-row block. Using and
, the first block of columns is (bias), the next ones multiply the
entries of by the components of (as in
the linear model) and the last nine are .
Written out row by row for the common-axis case with the full :
Stacking the blocks gives exactly as in
the linear model, with 21 columns (18 with the common axis).
KnownFrameGyroscopeLinearLeastSquaresCalibrator solves it in one step. The non-linear
KnownFrameGyroscopeNonLinearLeastSquaresCalibrator runs Levenberg-Marquardt on the same linear model, but
feeds the fitter the analytical Jacobian (the entries of above, no numerical differentiation),
so it needs an initial guess and then converges almost immediately. KnownBiasAndFrame… drops the first block
( subtracted from the left side instead): 18 or 15 unknowns.
Turntable calibrators: constant known rate and Earth rate
Idea
A turntable spinning at a constant, known rate gives a reference magnitude but not the
direction of the true rate in the sensor frame, in the same way a static accelerometer gives only the magnitude
. The calibrators therefore reuse the norm-based formulation of
the non-linear model, with the known rate in place of the
gravity norm.
Earth rate removal
Both the turntable and the Earth rotate, so the code first removes the Earth-rate vector. At the given
position (NEDPosition or ECEFPosition) it builds a frame whose body axes coincide with the local
navigation axes (identity attitude), asks the kinematics estimator for the angular rate that frame senses, and
takes that vector (the Earth rate resolved on those axes) as the Earth contribution. Every
sample is shifted by it:
so the squared turntable rate is the observation of every measurement.
(DEFAULT_TURNTABLE_ROTATION_RATE is the Earth rate and DEFAULT_TIME_INTERVAL is 0.02 s, defaults only.)
Only the magnitude of the rate enters, so the sense of rotation does not matter.
Model and bias handling
Using the reparametrization of the non-linear model, ,
, , the error model
becomes .
Solving for the true rate and taking its squared norm gives the prediction fitted by Levenberg-Marquardt:
is the measured specific force corrected with the accelerometer bias and
cross-coupling supplied by the user, and is the angular-rate standard deviation of the
measurement. Geometrically the corrected samples lie on a sphere of radius ; in measurement space
this is an ellipsoid whose center is the gyroscope bias and whose shape is . The bias
is therefore not eliminated by differencing but estimated as the ellipsoid center, jointly with the scale
factors and cross-couplings (the same picture as hard and soft iron in Magnetometer Calibration).
TurntableGyroscopeCalibrator fits , (and by default) with the
Jacobian obtained by numerical GradientEstimator, not analytically.
KnownBiasTurntableGyroscopeCalibrator removes the bias unknowns: the supplied bias is subtracted inside the
same expression, leaving only (and ) to estimate. If estimateGDependentCrossBiases is false the
term is dropped. With the common z-axis flag is upper triangular, which also
removes the rotational ambiguity of the norm-only cost described in the non-linear model.
The measurements must cover several directions of the true rate (for example by mounting the IMU in
different orientations on the table). If every sample shares the same direction the ellipsoid cannot be
recovered and the fit is rank deficient.
Easy calibrators: integrated rotation versus gravity direction
For sequence let and be the mean specific forces of
the static bracket before and after the motion. They are corrected with the accelerometer bias and
cross-coupling supplied by the user and normalized, so only the gravity direction remains:
For a candidate (same reparametrization as above) every timed sample of
the sequence is corrected with the gyroscope model, including its own corrected specific force:
The corrected rates are integrated with the Runge-Kutta step integrator (this choice is fixed inside the
calibrator, it is not configurable) starting from the identity attitude, giving the attitude change
of the body over the motion. Gravity is fixed in the world, so in body axes it turns by the
inverse rotation, and the residual is the three-component difference between the predicted and the measured
final direction:
where is the rotation matrix of (so
is applied to ) and is the standard deviation of
the gravity direction of the sequence, BodyKinematicsSequence.getGravityDirectionStandardDeviation()
(dimensionless). Each sequence therefore contributes three equations instead of one scalar distance. The fit is
done by LevenbergMarquardtMultiVariateFitter: the inputs of each observation are the two normalized static
directions, which stay fixed, and the model output is , compared with
. The Jacobian is still numerical, but it is obtained with the JacobianEstimator of
irurueta-numerical configured with a relative step and a minimum step of 1e-7, so the step is
1e-7 * max(1, |p|) (with the default, purely relative step, the step vanishes for parameters near zero, which
made the fit singular on noiseless data whose true parameters are zero). When a sequence does not carry a gravity-direction standard deviation, it is estimated from
the items (accelerometer noise and integrated gyroscope noise), and a value of 1 is used if nothing is available.
The robust variants already scored each sequence with the norm of this three-component residual.
Defaults. Following the paper, EasyGyroscopeCalibrator, KnownBiasEasyGyroscopeCalibrator and their robust
variants now default to commonAxisUsed = false (full , nine entries) and
estimateGDependentCrossBiases = false. The upper-triangular form is only valid for the sensor that defines the
body frame, which is the accelerometer, not the gyroscope; and is weakly observable from
gravity references alone. Both remain available as options (setCommonAxisUsed(true),
setEstimateGDependentCrossBiases(true)). The Turntable calibrators keep their previous defaults.
Differences from the paper (see the Tedaldi notes on the algorithms page): the gyroscope bias is an
unknown of this fit (nothing is subtracted beforehand), the residual is a distance between unit vectors rather
than between integrated vectors in the paper’s own parametrization, and the defaults are the general (full)
matrix without the g-dependent term (see [easy-defaults]). The accelerometer must be calibrated first because
and depend on it. KnownBiasEasyGyroscopeCalibrator is the same
fit with the bias taken from the caller (6 to 18 unknowns, 9 by default, see Unknowns and minimum data).
flowchart LR
S1["Static bracket before: mean f, corrected, normalized -> u_minus"] --> R["Rotate u_minus by the inverse of q -> predicted u_plus"]
M["Motion samples: Omega_true = inv(M) Omega_meas - b - G f_true"] --> I["Integrate with Runge-Kutta -> attitude change q"]
I --> R
R --> C["Residual r = u_plus - predicted (3 components)"]
S2["Static bracket after: mean f, corrected, normalized -> u_plus"] --> C
C --> LM["Levenberg-Marquardt (numerical Jacobian) updates b, M, G"]
LM -->|"new parameters"| M
Easy example
Each sequence carries the specific-force readings from the static brackets before/after, plus the
timed angular-rate samples captured in between:
final List<BodyKinematicsSequence<StandardDeviationTimedBodyKinematics>> sequences = new ArrayList<>();
// ...
final var sequence = new BodyKinematicsSequence<StandardDeviationTimedBodyKinematics>();
sequence.setBeforeMeanSpecificForceCoordinates(beforeMeanFx, beforeMeanFy, beforeMeanFz);
sequence.setAfterMeanSpecificForceCoordinates(afterMeanFx, afterMeanFy, afterMeanFz);
final List<StandardDeviationTimedBodyKinematics> items = new ArrayList<>();
// ...
items.add(new StandardDeviationTimedBodyKinematics(measuredKinematics, timestampSeconds,
specificForceStandardDeviation, angularRateStandardDeviation));
sequence.setItems(items);
sequences.add(sequence);
// known accelerometer bias/cross-coupling, needed because bg-dependent bias
// requires the true specific force
final Matrix initialBias = new Matrix(3, 1);
final Matrix initialMg = new Matrix(3, 3);
final Matrix initialGg = new Matrix(3, 3);
final Matrix accelerometerBias = new Matrix(3, 1);
final Matrix accelerometerMa = new Matrix(3, 3);
final var calibrator = new EasyGyroscopeCalibrator(sequences, true, false, initialBias, initialMg,
initialGg, accelerometerBias, accelerometerMa);
calibrator.calibrate();
final Matrix estimatedBg = calibrator.getEstimatedBiasesAsMatrix();
final Matrix estimatedMg = calibrator.getEstimatedMg();
final Matrix estimatedGg = calibrator.getEstimatedGg();
The g-dependent matrix
captures the part of the bias that follows the specific force (typically a mass unbalance in
the sensing element): the term adds nine unknowns. It is observable only if
the specific force changes independently of the angular-rate information, so the data must be gathered in
several attitudes. How each family estimates it:
KnownFrame: exactly as in the block above, nine extra columns
(stored row by row: ) multiply the known true specific force.
Turntable and Easy: through inside the non-linear model, where the specific force is
the measured one corrected by the accelerometer bias and cross-coupling. The calibrator reports
after the fit. This is why the accelerometer has to be calibrated
before the gyroscope (AccelerometerDependentGyroscopeCalibrator).
Disable it (estimateGDependentCrossBiases = false) when the data have little specific-force diversity or when
the minimum counts in Unknowns and minimum data cannot be met; the g-term is then assumed zero.
Quaternion step integrators
Integrating angular rate over a dynamic interval means numerically solving the quaternion kinematic
differential equation
(the matrix is exactly the one built by QuaternionStepIntegrator.computeOmegaSkew; it
satisfies ).
QuaternionStepIntegrator defines the strategy interface; QuaternionIntegrator drives it over a sequence:
for consecutive items it calls the step with the previous rate , the current rate
and equal to the timestamp difference, starting from the identity or a given
attitude. Every step ends with a re-normalization of the quaternion. Six schemes exist (selected with
QuaternionStepIntegratorType, default RUNGE_KUTTA).
Step equations
In the formulas below is the attitude at the start of the step, the result
(before normalization), ,
,
and . Define
.
Euler (EulerQuaternionStepIntegrator): only the rate at the start of the step is used.
Mid-point (MidPointQuaternionStepIntegrator): a half Euler step with the start rate, then a full step with the
slope evaluated at the half-step state using the average rate.
Runge-Kutta (RungeKuttaQuaternionStepIntegrator): classic RK4 where the rate is at the start,
for both mid-step slopes and at the end.
Yuan (YuanQuaternionStepIntegrator): the closed-form rotation for a constant rate equal to the average
(exact matrix exponential, using ). With
, and (taken as 1 when ):
Suh (SuhQuaternionStepIntegrator): a truncated expansion that combines the two rates with weights and
and adds second and third order terms in :
Trawny (TrawnyQuaternionStepIntegrator): matrix exponential of the rate extrapolated by its first derivative
, plus a commutator correction:
The Suh and Trawny formulas are the ones of the cited papers ([suh2010],
[trawny2005]), restated; the code evaluates them as written above.
Accuracy and cost
Integrator
Order, constant rate
Order, varying rate (as called by the library)
Work per step
Remarks
Euler
2 (measured, thanks to re-normalization; the formal order is 1)
1
1 slope evaluation
Cheapest. Uses only the start rate.
Mid-point
2
2
2 slopes
Uses the average rate (linear interpolation of the rate).
Runge-Kutta
4
2
4 slopes (3 skew matrices)
Default. With only two rate samples per step the rate is linearly interpolated, which caps the order at 2 when the rate varies.
Yuan
exact
2
1 skew matrix, 1 sin and 1 cos, no matrix product
Exact for a constant axis; the error comes from the rate variation inside the step.
Suh
4
1
2 skew matrices, 1 matrix product
The 3/4 and -1/4 weights extrapolate the rate; see the note below.
Trawny
exact
1
a 4x4 matrix exponential plus 2 matrix products
Most expensive; same extrapolation caveat as Suh.
The orders in the table come from a numerical experiment run for this page, not from the library tests: the six
formulas above were applied to rad/s over 2 s with
the rate sampled at both ends of each step, the result compared with a fine reference, and the slope of the
log-log error read for 10 to 160 steps. For a constant rate the same experiment gave slope 4 for Runge-Kutta and Suh, slope 2
for Euler and mid-point, and zero error (machine precision) for Yuan and Trawny.
Suh and Trawny are designed to predict the next interval from the previous and the current rate
(the weights and the term extrapolate the rate to the middle of the next step). QuaternionIntegrator
instead passes the rates at both ends of the interval being integrated, so for these two integrators the rate is
extrapolated beyond the interval and the experiment shows first-order accuracy; feeding the same formulas the previous
rate and the current rate to advance to the next instant gave second-order accuracy. Prefer Runge-Kutta, Yuan or
mid-point with QuaternionIntegrator, and note that the choice matters little when the sampling is fast
compared with the rate dynamics (the typical gyroscope case).
EasyGyroscopeCalibrator always integrates its sequences with the Runge-Kutta scheme.
Integrating a sequence directly
QuaternionStepIntegrator.create(type) builds the strategy for one scheme; QuaternionIntegrator
drives it step-by-step across an entire BodyKinematicsSequence to obtain the final attitude:
// integrate a whole sequence in one call, choosing the RK4 scheme
final Quaternion initialAttitude = new Quaternion(); // identity
final Quaternion finalAttitude = QuaternionIntegrator.integrateGyroSequenceAndReturnNew(sequence,
initialAttitude, QuaternionStepIntegratorType.RUNGE_KUTTA);
// or drive a single integration step manually
final QuaternionStepIntegrator stepIntegrator =
QuaternionStepIntegrator.create(QuaternionStepIntegratorType.RUNGE_KUTTA);
final Quaternion result = new Quaternion();
stepIntegrator.integrate(initialAttitude, previousWx, previousWy, previousWz, currentWx, currentWy,
currentWz, dt, result);
Class Reference
Javadoc and source links for the classes used in the examples above: