IMU model
Use this page to see how MVIS models an IMU, which convention to pick, and how to correct raw IMU readings with a calibration result.
MVIS solves the IMU intrinsics rather than taking them from a datasheet. IMU intrinsics are the sensor’s own error terms:
- Scale and misalignment of the gyroscope and the accelerometer (, )
- The rotation between the two triads (the gyro and accel axes are not exactly parallel)
- G-sensitivity : specific force leaking into the gyro (optional)
- Biases ,
- The gyro–accel time offset inside one IMU
Symbols follow Notation & glossary. The code is in
src/mvis/imu/:
imu_model.py holds the shared equations, kalibr.py, rpng.py and
calyx.py the three layouts.
Measurement model
Section titled “Measurement model”and are correction matrices: they turn a raw reading into a true value. The raw readings are therefore their inverses applied to the truth. With the true angular velocity and the true specific force, both in the IMU frame :
- and rotate the gyro triad and the accel triad into . Each convention fixes one of them to the identity.
- is the gyro–accel offset of the accel against the gyro clock.
- , are white noise. The biases follow a random
walk, , .
Their densities are the config’s
sigma_g,sigma_a,sigma_bg,sigma_ba.
Inverse model (correction)
Section titled “Inverse model (correction)”The correction is the exact inverse. The accel comes first, because the gyro’s g-sensitivity term needs the corrected specific force:
This is the correction the IMU factor applies to every sample inside the solve
(src/mvis/calibration/factors/aci.py),
the ACI3 integration (cite ACI2).
The simulator uses the forward model above to make raw readings, so the two are
exact inverses without noise.
Three conventions
Section titled “Three conventions”estimate: imu: model: calyx # kalibr | rpng | calyx (default calyx)solve.imu_intrinsics_model is the same setting under its low-level name.
The two triads and have 3 + 3 + 3 rotational degrees of freedom, but the data only sees the rotation between the triads. So one rotation must be pinned. What is pinned, and the shape of each matrix, is the convention:
| Convention | Free rotation | is | Parameters | ||
|---|---|---|---|---|---|
kalibr | lower-triangular (6) | lower-triangular (6) | (3) | the accel triad | 6 + 6 + 3 + 9 () = 24 |
rpng | upper-triangular (6) | upper-triangular (6) | (3) | the gyro triad | 6 + 6 + 3 + 9 = 24 |
calyx (default) | full (9) | upper-triangular (6) | none: the rotation is inside | the accel triad | 9 + 6 + 9 = 24 |
On top of those 24, every convention has the two biases (3 + 3) and (1).
kalibr
Section titled “kalibr”This is the structure of Kalibr’s scale-misalignment IMU model. Kalibr’s
imu.yaml maps onto it as ,
,
and
(src/mvis/io/kalibr.py).
Pick it when you compare against Kalibr.
The convention of the RPNG group’s VINS work (the OpenVINS lineage). Here is the gyro triad, so the camera–IMU extrinsics are relative to the gyro axes.
The full is linear in its nine entries, so the solve needs no rotation variable. After the solve, MVIS splits it into a rotation and an upper-triangular matrix with a positive diagonal (a QR decomposition):
The result reports both: R_wtoI, U_w, and Dw_decomposed with the
per-axis gyro scale (Dw_scale, the diagonal of ), the
cross-coupling (Dw_shear, its upper off-diagonals) and
gyro_misalign_rotvec in rad.
Read the scale from Dw_scale, not from Dw_diag: in calyx the diagonal of
mixes scale with rotation.
How they compare
Section titled “How they compare”- Same physics, different bookkeeping. All three describe the same sensor. They differ in which frame is and where the triad rotation sits.
- Not a quality lever. Before the 0.1.0 release we checked this on TUM-VI and on the Monado SLAM calibration set MIC (Valve Index, see Datasets), with camera intrinsics pinned or freed. All three recovered the same extrinsics and camera intrinsics. Choose the one that matches what you compare against.
- Not comparable entry by entry. A
kalibrand anrpngof the same IMU differ. Before concluding that two calibrations disagree, check they used the same convention. - Default staging differs. The default
estimate.imu.intrinsics: dw_dafrees and only. Incalyxthat already includes the triad rotation (it lives in ). Inkalibrandrpngthe rotation stays at the identity until you choosedw_da_r.
estimate.imu.intrinsics | Frees |
|---|---|
pinned (or false) | nothing |
dw_da (default) | , |
dw_da_r | , , the triad rotation (kalibr, rpng; same as dw_da in calyx) |
full (or true) | the above plus |
Freed blocks carry weak priors around their start values: the identity for
, and the rotation, zero for
(sigma_dw_da 0.1, sigma_imu_R 0.1 rad, sigma_tg 0.05).
Correct readings with a result
Section titled “Correct readings with a result”mvis cam-imu writes a calibration YAML next to its JSON summary (for
cam_imu.json, the file is cam_imu_calib.yaml). Each entry of its imus:
list has:
| Key | Meaning |
|---|---|
name, role, topic | IMU name, base or aux, and its topic when known |
model | kalibr, rpng or calyx |
Dw, Da | the correction matrices, |
imu_intr_xi | the 24 intrinsics as an offset from the identity, in the convention’s order; it also carries and the triad rotation |
b_g, b_a | biases, rad/s and m/s² |
t_ga, t_ga_sigma | gyro–accel offset and its 1-sigma, s |
Dw_diag, Da_diag | the diagonals, for a quick look only; in calyx Dw_diag is not a scale |
Dw_decomposed | calyx only (base and aux): scale, shear and misalignment rotation |
R_wtoI, U_w | calyx, base IMU only: the split above |
td | aux only: IMU–IMU time offset, s |
p_IsinI_m | aux only: lever arm to the base IMU, m |
gyro_only | aux only, present when the IMU was calibrated gyro-only |
The layout of imu_intr_xi:
| Convention | (column-major) | rotation vector | ||
|---|---|---|---|---|
kalibr | [0:6] | [6:12] | [12:21] | [21:24], |
rpng | [0:6] | [6:12] | [12:21] | [21:24], |
calyx | [0:9] | [9:15] | [15:24] | none |
With MVIS
Section titled “With MVIS”mvis.recalib.load_rig_calib reads any convention
and applies the inverse model above:
from mvis.recalib import load_rig_calib
imu = load_rig_calib("cam_imu_calib.yaml").base_imuw, a = imu.intr.correct(w_m, a_m, imu.b_g, imu.b_a) # true omega, true specific force in {I}With numpy only
Section titled “With numpy only”Read the YAML with yaml.safe_load and pass one imus: entry. The Dw and
Da matrices come straight from the file; and the rotation come
from imu_intr_xi. w_m and a_m are length-3 arrays of one sample, with the
accel already shifted by (below).
import numpy as npfrom scipy.spatial.transform import Rotation
def correct_kalibr(w_m, a_m, imu): xi = np.asarray(imu["imu_intr_xi"]) Dw, Da = np.asarray(imu["Dw"]), np.asarray(imu["Da"]) # lower-triangular Tg = xi[12:21].reshape(3, 3, order="F") R_wtoI = Rotation.from_rotvec(xi[21:24]).as_matrix() a = Da @ (a_m - imu["b_a"]) # accel triad = {I} w = R_wtoI @ Dw @ (w_m - imu["b_g"] - Tg @ a) return w, aimport numpy as npfrom scipy.spatial.transform import Rotation
def correct_rpng(w_m, a_m, imu): xi = np.asarray(imu["imu_intr_xi"]) Dw, Da = np.asarray(imu["Dw"]), np.asarray(imu["Da"]) # upper-triangular Tg = xi[12:21].reshape(3, 3, order="F") R_atoI = Rotation.from_rotvec(xi[21:24]).as_matrix() a = R_atoI @ Da @ (a_m - imu["b_a"]) w = Dw @ (w_m - imu["b_g"] - Tg @ a) # gyro triad = {I} return w, aimport numpy as np
def correct_calyx(w_m, a_m, imu): xi = np.asarray(imu["imu_intr_xi"]) Dw, Da = np.asarray(imu["Dw"]), np.asarray(imu["Da"]) # full, upper-triangular Tg = xi[15:24].reshape(3, 3, order="F") a = Da @ (a_m - imu["b_a"]) # accel triad = {I} w = Dw @ (w_m - imu["b_g"] - Tg @ a) # Dw already holds the triad rotation return w, aWe checked all three against ImuModel.correct in MVIS on random
intrinsics; they agree to machine precision.
Shifting the accel by t_ga
Section titled “Shifting the accel by t_ga”Do this first, on the whole recording: re-sample the accel channel at each stamp plus , so that gyro and accel describe the same instant.
import numpy as np
def shift_accel(t, acc, t_ga): """t: (N,) stamps in s, sorted; acc: (N, 3) raw accel. Returns acc at t + t_ga.""" return np.stack([np.interp(t + t_ga, t, acc[:, k]) for k in range(3)], axis=1)What mvis apply-calib does
Section titled “What mvis apply-calib does”mvis apply-calib writes a corrected copy of a ROS1 bag
(src/mvis/recalib/apply.py).
On each IMU message, in this order:
- t_ga: the accel is linearly re-interpolated at header stamp +
(
--no-t-gaskips it). - Intrinsics and bias: the inverse model above subtracts the saved
, and removes , ,
and the triad rotation.
--keep-biasleaves the biases in;--no-imu-intrinsicsremoves only the biases. - td: the header stamp becomes stamp +
td(--no-tdkeeps the original).
An auxiliary IMU entry without imu_intr_xi is read with identity intrinsics,
so only its saved bias (if any) and its stamps change.
t_ga: the gyro–accel offset
Section titled “t_ga: the gyro–accel offset”is the time offset between the gyroscope and accelerometer channels inside one IMU.
Many drivers publish gyro and accel together under one stamp, yet the two channels are sampled at different rates and instants. MVIS takes the shared stamp as the gyro clock and models the accel stored at as sampled at .
solve: estimate_t_ga: true # default in camera–IMU runs sigma_t_ga: 0.010 # weak prior, s- In the solve: the IMU factor corrects to first order,
,
with from finite differences of the raw accel. That adds
one Jacobian column; through it also reaches the gyro row. When
moves more than 3 ms from where the factors were integrated, they are
integrated again (
tga_relin_threshold_s). - Reported in the calibration YAML, the
cam_imu.jsonsummary (t_ga_ms) and the report. - Corrected by
mvis apply-calib, as above. - Checked by
mvis roundtrip: after correction a re-calibration should find near zero.
Why it matters: a tool without puts part of that delay into the camera . On real devices a single can also depend on the motion. Both are shown in Why calibrate t_ga.
Gyro-only auxiliaries
Section titled “Gyro-only auxiliaries”The other answer to an untrustworthy accelerometer is to skip it:
input: imus: - {} # base IMU - {gyro_only: true} # auxiliary IMUWhat a gyro-only IMU solves and pins:
- Solved: extrinsic rotation,
td(here the IMU-to-IMU time offset), and the gyro bias. - Pinned: the lever arm (the translation between the two IMUs), and .
It is not allowed on the base IMU: the base IMU needs its accelerometer for
gravity and metric scale. The result marks each such IMU with gyro_only: true.
We built it for the Intel T265 (Bosch BMI055), whose 62.5 Hz accel the driver
interpolates to 200 Hz. We calibrated, corrected the bag and calibrated again.
Without gyro-only, the T265’s td moved from +8.6 ms to −9.0 ms between the two
runs. With gyro-only it moved from +0.9 ms to +0.4 ms.
Which to reach for
Section titled “Which to reach for”Both address an accelerometer that is out of step with its gyro:
| Option | What it does | Prefer it for |
|---|---|---|
estimate_t_ga | Measures the offset | The base IMU, which must use its accel; the value itself is worth having |
gyro_only | Avoids the accelerometer | An auxiliary IMU whose accel adds nothing you need |
What is observable
Section titled “What is observable”Each term needs the right motion:
- Scale and misalignment need rotation and acceleration on every axis.
- The triad rotation needs rotation about several axes while the accelerometer sees gravity from several directions.
- G-sensitivity needs rotation and strong linear acceleration at the same time. Most hand-held motions do not produce that, which is why the default leaves it out.
- needs the specific force to change quickly, so that a time shift changes the reading.
When a freed term returns near its start value with a wide covariance, it was not observed. See Observability and Degeneracy.