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.
Terms used in this lesson
Section titled “Terms used in this lesson”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 |
How Kalibr solves it
Section titled “How Kalibr solves it”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 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.
The inputs
Section titled “The inputs”| 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 command
Section titled “The command”The guide gives the general form:
kalibr_calibrate_imu_camera --bag [filename.bag] --cam [camchain.yaml] --imu [imu.yaml] --target [target.yaml]and this example for its sample bag:
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.bagThe 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).
What comes out
Section titled “What comes out”| 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.
Judging the result
Section titled “Judging the result”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.
Self-check
Section titled “Self-check”- In the camera–IMU recording, what stays still and what moves? How is that different from C201?
- Your rig was waved left and right in front of the board for two minutes. What is wrong with the recording?
- Your IMU’s scale factors have never been calibrated. Which
--imu-modelsvalue do you pass? T_cam_imufor cam0 has a translation of about 3 cm in x. What does that number describe?- The angular-velocity residuals lie far outside the dashed ±3σ lines. Name two possible causes.
Answers
Section titled “Answers”- The target stays still and the rig moves, on every axis. In camera calibration the cameras stay still and the target moves.
- It excites only one rotation axis. The solver needs rotation about, and translation along, every axis.
scale-misalignment(orscale-misalignment-size-effect), which estimates them;calibratedassumes they are already corrected.- Where the IMU sits in cam0’s frame, in metres. Check it against a ruler or the mechanical drawing.
- The noise values in
imu.yamlare too small (not inflated enough), or the dataset is bad, for example with broken timestamps.
Sources
Section titled “Sources”- Field guide: Kalibr Workflow, Kalibr File Reference, Camera-IMU Time Offset, IMU Calibration for Camera Rigs, glossary.
- Kalibr wiki, ETH Zurich ASL: camera–IMU calibration, Multi-IMU and IMU intrinsic calibration, YAML formats, bag format, Calibrating Intel RealSense cameras.
- Kalibr source code, github.com/ethz-asl/kalibr (commit
1f60227): kalibr_calibrate_imu_camera. - Python Software Foundation. argparse documentation (
allow_abbrev). - Furgale, P., Rehder, J. and Siegwart, R. (2013). Unified temporal and spatial calibration for multi-sensor systems. IEEE/RSJ IROS.