This documentation was generated with the assistance of AI. Please report any inaccuracies.
Classes: AccelerationFixer, AngularRateFixer, MagneticFluxDensityFixer, BodyKinematicsFixer,
IMUErrorsCreator (see the Class Reference table at the end of this page for Javadoc and source
links).
All three sensors share the structure
(plus
for the gyroscope). A fixer drops the noise term, which cannot be recovered
from a single reading, and solves for :
How this maps onto the code (identical in AccelerationFixer, AngularRateFixer and
MagneticFluxDensityFixer):
is the full matrix, diagonal included. The fixer stores the matrix exactly as a
calibrator reports it (getEstimatedMa(), getEstimatedMg(), …), with the scale-factor errors on the
diagonal and the cross-coupling terms off it:
setSx(…), setMxy(…) and the other element setters just rewrite one entry of this matrix and then
rebuild the inverse. Because the fixer adds the identity itself, pass and not; the zero matrix means "no scale or cross-coupling error".
The inverse is of , computed once. Every setCrossCouplingErrors(…)
(and every element setter) forms and inverts it with a general matrix
inverse (Utils.inverse), caching the result for all later fix calls. A singular
raises an AlgebraException. Before any matrix is set, the cached inverse
is the identity and the bias is zero, so a fresh fixer returns its input unchanged. The fix overloads
that take an explicit bias and matrix instead recompute the inverse on every call.
is never inverted. It multiplies the true specific force and is subtracted from
the reading before is applied. Its setter stores the matrix and
does no algebra.
Order of operations (gyroscope): ,
then . Bias and g-term are removed
before the matrix is undone, because in the forward model they are added after the matrix acts on the
angular rate.
Since is small for a decent sensor, one may be tempted to use the first-order
instead of the exact inverse. The residual is the matrix
, so a 1 % scale or cross-coupling error leaves roughly a
relative error. The fixers do not take that shortcut. (This error estimate is an own
derivation, not something the code or Javadoc states.)
The calibrators and the fixers use the same convention for , so a calibrator’s output can
be fed straight into a fixer. The synthetic-data generator BodyKinematicsGenerator applies the forward model
with the same form, which makes generator, calibrator and fixer a closed loop: for
noise-free data, fixing the generated readings recovers the true signal up to round-off.
AccelerationFixer
Inverts :
// bias and cross-coupling matrix estimated by a calibrator (see calibration/accelerometer.adoc)
double[] bias = {0.02, -0.01, 0.05}; // m/s^2
Matrix crossCouplingErrors = new Matrix(3, 3); // Ma, here left at zero for brevity
AccelerationFixer fixer = new AccelerationFixer();
fixer.setBias(bias);
fixer.setCrossCouplingErrors(crossCouplingErrors);
double[] measuredF = {0.15, -0.18, -9.79};
double[] trueF = new double[3];
fixer.fix(measuredF, trueF);
AngularRateFixer
Inverts .
Because the g-dependent term needs the true specific force, this fixer requires an already-fixed
acceleration as an additional input (typically the output of AccelerationFixer for the same sample):
double[] gyroBias = {1e-4, -5e-5, 2e-5}; // rad/s
Matrix gyroCrossCouplingErrors = new Matrix(3, 3); // Mg
Matrix gDependentCrossBias = new Matrix(3, 3); // Gg
AngularRateFixer fixer = new AngularRateFixer();
fixer.setBias(gyroBias);
fixer.setCrossCouplingErrors(gyroCrossCouplingErrors);
fixer.setGDependantCrossBias(gDependentCrossBias);
double[] measuredAngularRate = {0.001, -0.0005, 0.02};
double[] trueF = {0.0, 0.0, -9.81}; // fixed specific force from AccelerationFixer, same sample
double[] trueAngularRate = new double[3];
fixer.fix(measuredAngularRate, trueF, trueAngularRate);
MagneticFluxDensityFixer
Inverts
(hard iron / soft iron), with the same closed form as AccelerationFixer:
double[] hardIron = {2.1e-6, -1.4e-6, 3.0e-6}; // T
Matrix softIron = new Matrix(3, 3); // Mm
MagneticFluxDensityFixer fixer = new MagneticFluxDensityFixer();
fixer.setBias(hardIron);
fixer.setCrossCouplingErrors(softIron);
double[] measuredB = {2.3e-5, 1.1e-5, 4.2e-5};
double[] trueB = new double[3];
fixer.fix(measuredB, trueB);
BodyKinematicsFixer
A convenience wrapper combining AccelerationFixer and AngularRateFixer to fix a whole
BodyKinematics (specific force + angular rate) reading in one call, correctly threading the fixed
specific force into the angular-rate fixer’s g-dependent term:
flowchart LR
F["Measured specific force"] --> AF["AccelerationFixer\n(I + Ma)^-1 (f - ba)"]
AF --> FT["Fixed specific force"]
W["Measured angular rate"] --> GF["AngularRateFixer\n(I + Mg)^-1 (w - bg - Gg f)"]
FT --> GF
GF --> WT["Fixed angular rate"]
The specific force must be fixed first and the fixed value, not the raw reading, goes into the g-term:
using the raw reading would subtract times a force that still contains
and the accelerometer’s own cross-coupling, leaving an error of order
(own estimate, not stated in the code).
Assembles a complete IMUErrors from whatever combination of sources
is available, rather than requiring a single calibrator to produce every parameter:
Bias + scale-factor/cross-coupling matrix, from any calibrator implementing
AccelerometerCalibrationSource or GyroscopeCalibrationSource
(see Noise and Approximate-Bias Estimators).
create() copies the sources' biases, , and into
the IMUErrors and takes the two noise values from getAccelerometerBaseNoiseLevelRootPsd() and
getGyroscopeBaseNoiseLevelRootPsd(). It throws NotReadyException unless all four sources are set and
every bias/matrix they return is non-null (isReady()). Quantization levels are not estimated by anything in
the package: they default to zero (no quantization) and can only be supplied through the six-argument
constructor. The noise values are norm-form root-PSDs (see
PSD and root-PSD), which matters when IMUErrors later drives
BodyKinematicsGenerator.
This lets a calibration pipeline mix, for example, bias/cross-coupling from a robust
KnownGravityNormAccelerometerCalibrator with a noise root-PSD from
a separate static-interval detector into a single
IMUErrors ready for use by BodyKinematicsGenerator (synthetic data) or the fixers above.
// accelCalibrator and gyroCalibrator implement AccelerometerCalibrationSource /
// GyroscopeCalibrationSource; accelNoiseSource and gyroNoiseSource implement
// AccelerometerNoiseRootPsdSource / GyroscopeNoiseRootPsdSource - each can come
// from a different pipeline stage (see calibration/noise-and-bias.adoc).
IMUErrorsCreator creator = new IMUErrorsCreator(
accelCalibrator, gyroCalibrator, accelNoiseSource, gyroNoiseSource);
IMUErrors imuErrors = creator.create();
Class Reference
Javadoc and source links for the classes used in the examples above: