Skip to content

C202 Lesson 3: Camera-IMU Calibration with Kalibr

With the cameras calibrated (C201) and the IMU’s noise values measured (Lesson 2), one calibration remains: where the IMU sits relative to each camera, and how their clocks relate. Kalibr’s kalibr_calibrate_imu_camera estimates both at once. This lesson covers the recording, the inputs, the command and the result. The step-by-step version is on the Kalibr Workflow, steps 6 to 9.

See also the glossary’s calibration section.

Term Meaning
Camera–IMU extrinsics The rotation and translation between the IMU’s frame and a camera’s frame
T_cam_imu Kalibr’s transform from IMU coordinates to camera coordinates; its translation is the IMU’s position seen from the camera
timeshift_cam_imu The time offset Kalibr adds to a camera timestamp to get the same instant on the IMU clock
Excitation Motion that makes every parameter observable: rotation about, and translation along, every axis
Continuous-time batch calibration Fitting a spline to the rig’s trajectory so IMU samples and camera frames can be optimised together for the extrinsics and the time offset
Normalised residual An error divided by the noise the solver was told to expect

Kalibr follows Furgale, Rehder and Siegwart (2013). It represents the IMU’s trajectory and biases as B-splines, continuous functions of time. A spline can be evaluated at any instant, so shifting the image timestamps by a candidate offset needs no re-integration of the IMU data, and the offset becomes one more unknown in a single batch estimate, with the gravity direction, the camera–IMU transform and the time-varying pose and biases (Offline estimation with Kalibr).

Doing it in one estimate matters. On 40 real datasets, the paper reports RMS timing errors of “0.054ms, 0.344ms, 0.165ms and 0.572ms” for the joint calibration, a separate time-delay estimate, gyroscope only and accelerometer only.

The Kalibr workflow: two recordings, two calibrations A flow chart of the Kalibr workflow for cameras plus an IMU, as the Kalibr wiki describes it. Two recordings, both stored as ROS 1 bags, with the roles swapped. Recording 1, the camera dataset: the cameras stay fixed and the Aprilgrid target is moved in front of them, at around 4 Hz. It goes with target.yaml, which holds the target's measured tag size and spacing, into kalibr_calibrate_cameras, which writes camchain.yaml with each camera's intrinsics and distortion and the camera-to-camera transforms. Recording 2, the camera-IMU dataset: the target stays fixed and the rig is moved to excite every rotation and translation axis; the guide reports good results at a 20 Hz camera rate and 200 Hz IMU rate. It goes with target.yaml, camchain.yaml and imu.yaml, the four IMU noise values from an Allan deviation or the datasheet, into kalibr_calibrate_imu_camera, which writes camchain-imucam.yaml, adding T_cam_imu and timeshift_cam_imu to each camera. Both tools also write a results text file and a PDF report to judge before accepting. Recording 1 cameras fixed, target moved in front camera rate ~4 Hz target.yaml measured tag size, spacing Recording 2 target fixed, rig moved on every axis; e.g. camera 20 Hz, IMU 200 Hz imu.yaml 4 noise values kalibr_calibrate_cameras camera calibration kalibr_calibrate_imu_camera camera–IMU calibration camchain.yaml intrinsics, distortion, camera-to-camera transforms camchain-imucam.yaml camchain plus T_cam_imu and timeshift_cam_imu per camera camchain.yaml feeds in check: results-cam.txt, report-cam.pdf check: results-imucam.txt, report-imucam.pdf Both recordings are ROS 1 bags. The roles swap: cameras still, then target still
Kalibr's two calibrations and the files that pass between them. The camera calibration uses a recording in which the cameras stay still and the target moves; the camera–IMU calibration uses one in which the target stays still and the rig moves on every axis, and it takes camchain.yaml from the first step plus the IMU noise values in imu.yaml. Rates are the Kalibr wiki's suggestions (about 4 Hz for the first recording; 20 Hz camera and 200 Hz IMU for the second). Each tool also writes a results file and a PDF report to judge before you accept the output.

The recording: the target stays still, the rig moves

Section titled “The recording: the target stays still, the rig moves”

The roles swap from C201. The camera–IMU guide says: “The calibration target is fixed in this calibration and the camera-imu system is moved in front of the target to excite all IMU axes.” Its tips:

  • “try to excite all IMU axes (rotation and translation)”
  • “avoid shocks, especially at the beginning/end when you pick up the sensor”
  • “keep the motion blur low”, with “low shutter times” and “good illumination”
  • “ensure low jitter timestamps in same clock”

The reasons for each tip, including why shocks and frames without the target hurt, are listed in the Kalibr workflow, step 7. The guide adds that “Good results have been obtained by using a camera rate of 20 Hz and an IMU rate of 200 Hz.” Furgale and colleagues recorded for “typically 1–2 minutes”; in their experiments each recording was “about 90 seconds”, with “an average absolute angular velocity of about 55° s−1 and an average absolute acceleration of 1.1m/s2” (Kalibr workflow, step 7).

Two warnings from the same pages. A rig that only pans left and right gives the solver nothing on the other axes. The reason is the lever arm: the IMU’s offset from the camera shows up only in the accelerometer, through terms that need rotation, and rotation about one axis hides any offset along that axis (Why every axis has to move). And with a symmetric target, “movements which could lead to flips in the target pose estimates have to be avoided”; an Aprilgrid avoids the problem.

Record with the IMU configured exactly as it will be in production: same output rate, same filter settings. The filter changes the time offset, as Lesson 4 shows.

Input Flag Where it comes from
A ROS 1 bag with images and IMU data --bag recorded directly, converted from ROS 2, or built with kalibr_bagcreater from images and an imu0.csv (bag format)
The camera calibration --cam <bag>-camchain.yaml from kalibr_calibrate_cameras (C201 lab)
The IMU file, one per IMU --imu imu.yaml with the noise values from Lesson 2
The target --target target.yaml with the measured board dimensions
The IMU model, one per IMU --imu-models calibrated, scale-misalignment or scale-misalignment-size-effect

The source spells the camera flag --cams; the wiki and the tool’s usage text write --cam (kalibr_calibrate_imu_camera). The tool builds its options with Python’s argparse, which by default “allows long options to be abbreviated to a prefix, if the abbreviation is unambiguous” (argparse documentation), so the wiki’s --cam reaches --cams.

The IMU model. The default, calibrated, assumes the IMU’s scale and misalignment are already corrected. scale-misalignment also estimates a scale-and-misalignment matrix for each sensor, the gyroscope’s sensitivity to acceleration, and the rotation between the gyroscope and accelerometer axes. scale-misalignment-size-effect also locates each accelerometer axis (imu.yaml: the output file).

The guide gives the general form:

Terminal window
kalibr_calibrate_imu_camera --bag [filename.bag] --cam [camchain.yaml] --imu [imu.yaml] --target [target.yaml]

and this example for its sample bag:

Terminal window
rosrun kalibr kalibr_calibrate_imu_camera \
--target april_6x6.yaml \
--imu imu_adis16448.yaml \
--imu-models calibrated \
--cam cam_april-camchain.yaml \
--bag imu_april.bag

The guide states that temporal calibration is on by default; --no-time-calibration turns it off. The camera-to-camera transforms are kept from the camera calibration unless you pass --recompute-camera-chain-extrinsics, which the source calls “exclusively recommended for debugging purposes” (Kalibr workflow, step 8).

File What it holds
<bag>-camchain-imucam.yaml the camchain plus T_cam_imu and timeshift_cam_imu for each camera
<bag>-imu.yaml the input IMU values plus the model, T_i_b, time_offset and, for the richer models, the estimated matrices
<bag>-results-imucam.txt normalised and plain residuals, the transforms in both directions, the time shift, baselines, the gravity vector
<bag>-report-imucam.pdf the plots

The file names are the ones the source writes; the wiki writes them the other way round, as camchain-imucam-%BAGNAME%.yaml (The files at a glance).

Kalibr names every transform T_a_b, which takes a point in frame b into frame a. So T_cam_imu is, in the YAML formats page’s words, the “transformation from IMU to camera coordinates (T_c_i)”, and its translation is where the IMU sits in the camera’s frame. The results file prints both directions, as T_ci and T_ic.

The transforms in a Kalibr camchain-imucam.yaml Three coordinate frames: the IMU, cam0 and cam1. An arrow from the IMU to cam0 is labelled T_cam_imu stored under cam0, meaning it takes a point in IMU coordinates to cam0 coordinates. An arrow from cam0 to cam1 is labelled T_cn_cnm1 stored under cam1, which equals T_c1_c0 and takes a point in cam0 coordinates to cam1 coordinates. A third arrow from the IMU to cam1 is labelled T_cam_imu stored under cam1. The rule printed below: T_a_b takes a point expressed in frame b and returns it expressed in frame a. IMU (imu0) cam0 cam1 cam1: T_cn_cnm1 = T_c1_c0 cam0 coordinates to cam1 cam0: T_cam_imu cam1: T_cam_imu T_a_b takes a point in frame b and returns it in frame a
How Kalibr names its transforms. T_a_b takes a point given in frame b and returns it in frame a. Each camera block in camchain-imucam.yaml stores T_cam_imu (IMU to that camera), and every camera after cam0 stores T_cn_cnm1 (the previous camera to this one, so cam1 holds T_c1_c0).

The wiki’s RealSense tutorial gives the checks in a few lines; the field guide lays out where each one is (Kalibr workflow, step 9, report-imucam.pdf):

Check Where What to see If not
IMU sample timing the IMU measurement-rates page a flat line at the expected rate “Inspect the IMU time dt plot carefully in the PDF report!” Fix timestamps first
IMU residuals acceleration and angular velocity error pages inside the dashed ±3σ lines “your IMU noise or the dataset are incorrect”
Bias estimates accelerometer and gyroscope bias pages inside the ±3σ bounds “your trajectory was too dynamic, or your noise values are not good”
Transform T_ci in the results file matches the rig “Sanity check your final rotation and translation with hand-measured values.”
Reprojection reprojection pages points inside the 3σ circle reduce motion blur

The ±3σ lines come from the noise values you supplied. The multi-IMU page says they are there to “foster an intuition about the correctness of the noise parameters and models”. That is how you judge the inflation factor from Lesson 2: residuals far outside the lines mean the assumed noise is too small or the data is bad. To the best of our knowledge, normalised residuals far below one mean the assumed noise is much larger than the data shows (results-imucam.txt).

The time shift has its own lesson, next.

  1. In the camera–IMU recording, what stays still and what moves? How is that different from C201?
  2. Your rig was waved left and right in front of the board for two minutes. What is wrong with the recording?
  3. Your IMU’s scale factors have never been calibrated. Which --imu-models value do you pass?
  4. T_cam_imu for cam0 has a translation of about 3 cm in x. What does that number describe?
  5. The angular-velocity residuals lie far outside the dashed ±3σ lines. Name two possible causes.
  1. The target stays still and the rig moves, on every axis. In camera calibration the cameras stay still and the target moves.
  2. It excites only one rotation axis. The solver needs rotation about, and translation along, every axis.
  3. scale-misalignment (or scale-misalignment-size-effect), which estimates them; calibrated assumes they are already corrected.
  4. Where the IMU sits in cam0’s frame, in metres. Check it against a ruler or the mechanical drawing.
  5. The noise values in imu.yaml are too small (not inflated enough), or the dataset is bad, for example with broken timestamps.