Skip to content

Kalibr Workflow: From Target to Camera–IMU Calibration

This is the order of work for calibrating a rig’s cameras and IMU with Kalibr. Each step links to the field-by-field Kalibr file reference, where every number in every file is explained. The background is in the camera calibration guide and the IMU calibration guide.

The examples use a stereo pair, cam0 and cam1, and one IMU. The same steps work for one camera, or for more.

Step Tool Input Output
1. Prepare the cameras kalibr_camera_focus (optional) live images a fixed focus and exposure
2. Make and measure the target kalibr_create_target_pdf target size target.yaml
3. Record a camera dataset your recorder the target, moved in front of still cameras a recording
4. Get the data into a ROS 1 bag ROS 1 recorder, rosbags-convert or kalibr_bagcreater the recording a ROS 1 bag
5. Calibrate the cameras kalibr_calibrate_cameras bag, target.yaml camchain.yaml, results, report
6. Find the IMU noise values datasheet or Allan deviation IMU data imu.yaml
7. Record a camera–IMU dataset your recorder, then as in step 4 the rig, moved in front of a still target a ROS 1 bag
8. Calibrate camera to IMU kalibr_calibrate_imu_camera bag, camchain.yaml, imu.yaml, target.yaml camchain-imucam.yaml, imu.yaml, results, report
9. Judge the results you results and report accept or redo
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.

Calibration describes a camera at one focus setting, one resolution and one lens position. Fix all of them before recording, and keep them fixed afterwards. The camera calibration guide explains why autofocus and image stabilisation have to be off.

If the lenses have a manual focus ring, Kalibr’s camera focus tool helps set it the same way every time. It runs on a live ROS image topic, kalibr_camera_focus --topic [IMAGE_TOPIC], and shows the image “together with a measure of focus”. The wiki’s instructions: point the camera at a detailed scene, such as a Siemens star or a checkerboard, “and adjust the focus while trying to minimize the calculated focus measure.”

Set a short exposure. Both recordings below need sharp corners, and the camera–IMU guide says to “keep the motion blur low” with “low shutter times” and “good illumination”.

Use an Aprilgrid unless you have a reason not to. The calibration targets page recommends it because “partially visible calibration boards can be used” and the “pose of the target is fully resolved (no flips)”. Generate one with:

Terminal window
# Example: a 6 x 6 grid of 8 cm tags with gaps of 0.3 x the tag size
kalibr_create_target_pdf --type apriltag --nx 6 --ny 6 --tsize 0.08 --tspace 0.3

Then:

  1. Print it and mount it flat. The wiki: “Best is to glue it to a rigid plate such as aluminum or acrylic glass.”
  2. Measure it. “Most printers will scale the target during the printing process.” Measure one tag’s outer black edge for tagSize and the gap between tags, then set tagSpacing to gap ÷ tagSize. tagSpacing is a ratio, not a length. See target.yaml.
  3. Keep a white border at least one grid element wide around it, so it detects reliably in all lighting. The detector finds each tag by the contrast between its black border and the white around it (How fiducial detection shapes the board).
  4. Write target.yaml with the measured numbers:
# Example: replace these with your own measured values
target_type: 'aprilgrid'
tagCols: 6
tagRows: 6
tagSize: 0.0795
tagSpacing: 0.3

Keep the target’s measurements with the calibration. If the target is measured wrong, every translation Kalibr reports is scaled wrong with it.

For camera calibration, the multiple-camera guide says “The camera system is fixed and the calibration target is moved in front of the cameras”. It recommends lowering the camera rate “to around 4 Hz while capturing the calibration data”, because “This reduces redundant information in the dataset and thus lowering the runtime of the calibration.”

What the recording needs:

  • Coverage. The target should reach every part of every image, the corners and edges above all, at different distances and tilts. The camera calibration guide explains why coverage matters more than the number of images.
  • Both cameras at once. For a stereo pair, many frames need the target in both cameras at the same moment. Those shared views are what fix the transform between the cameras, and the tool stops if the cameras are “not connected through mutual observations”.
  • Enough of the grid. A frame only counts if it shows more tags than the grid’s longer side has: at least 7 tags on a 6 × 6 Aprilgrid. The source’s reason is that a board pose solved from points “almost on a line” can be bad (Aprilgrid).
  • No other AprilTags. “Make sure to hide all external Apriltags while collecting the calibration dataset.” A second board or a stray tag can carry the same IDs as the grid’s own tags (How fiducial detection shapes the board).
  • Sharp images. Move slowly enough that the corners are not blurred.

Kalibr reads only ROS 1 bags (bag format). There are three ways in:

  • Record a ROS 1 bag directly from the camera and IMU drivers.
  • Convert a ROS 2 bag. The ROS 2 guide uses the rosbags package: rosbags-convert <ros2_bag_folder> --dst calib_01.bag, with --exclude-topic for any topic that is not a standard image or IMU message.
  • Build one from files with kalibr_bagcreater. Put each camera’s images in its own folder, named by their timestamps in nanoseconds, and the IMU data in a CSV:
dataset-dir/
cam0/1385030208726607500.png
cam1/1385030208726607500.png
imu0.csv
timestamp,omega_x,omega_y,omega_z,alpha_x,alpha_y,alpha_z
1385030208736607488,0.5,-0.2,-0.1,8.1,-1.9,-3.3
Terminal window
kalibr_bagcreater --folder dataset-dir/. --output-bag awsome.bag

The CSV units are “timestamps=[ns], omega=[rad/s], alpha=[m/s^2]”. The topics come out as /cam0/image_raw, /cam1/image_raw and /imu0. The example values above are from the Kalibr wiki.

The timestamps you put in are the timestamps Kalibr uses. The multi-IMU page says Kalibr “exclusively employs header timestamps and normally does not apply any corrections in order to preserve the original timing of your system.”

Pick a model for each camera. The choices are pinhole-radtan, pinhole-equi, pinhole-fov, omni-none, omni-radtan, eucm-none and ds-none; the camera models section of the reference describes each one and the lenses it suits. For wide lenses, note what the double sphere paper found: the pinhole camera “demonstrates suboptimal performance for a field-of-view greater than 120°”, even with a distortion model added. On its test lenses, its own double sphere model and the extended unified model both came within 2% of the most accurate model’s mean reprojection error on every sequence (Table 1).

Then run, following the wiki’s example:

Terminal window
kalibr_calibrate_cameras \
--target target.yaml \
--models pinhole-radtan pinhole-radtan \
--topics /cam0/image_raw /cam1/image_raw \
--bag cam_april.bag \
--bag-freq 10.0

The order of --topics and --models sets which camera is cam0 and which is cam1. If the target is not being found, add --show-extraction to watch the detection. If the optimisation diverges in the first few images, the wiki’s advice is to “just try to restart the calibration as the initial guesses are based on a random pick of images.”

The output is <bag>-camchain.yaml, <bag>-results-cam.txt and <bag>-report-cam.pdf. Before moving on, check:

  • The reprojection error in the results file: the mean close to zero, and the spread small. See results-cam.txt.
  • The coverage in the report’s reprojection error page: detected corners across the whole image.
  • The polar error page: error that stays flat out to the largest angles.
  • The baseline. The translation in T_cn_cnm1 for cam1 should match the measured distance between the two lenses.
  • The target block at the end of the results file: the dimensions you measured, not the ones you meant to print.

If you have a live ROS setup, kalibr_camera_validator --cam camchain.yaml --target target.yaml shows reprojection errors on live images (calibration validator).

The camera–IMU calibration needs four noise values for the IMU in imu.yaml, plus its topic and rate. The IMU noise model page gives two ways to get them, and the reference explains every field and unit.

  • From an Allan deviation. The more reliable way. Record the IMU completely still, the wiki suggests for “~15-24 hour”, and run allan_variance_ros on it. The noise density is the curve’s value at τ = 1 s; the random walk is the fitted +½ slope line’s value at τ = 3 s.
  • From the datasheet. The white noise terms are usually there, as noise density or as angular or velocity random walk. Convert them to Kalibr’s units. The bias random walk is “rarely directly specified in the datasheet”.

Then decide how much to inflate them. The wiki warns that static values are “optimistic” and that “for lowest-cost sensors, increasing the noise model parameters by a factor of 10x or more may be necessary.”

# Example values, from the Kalibr wiki; use your own IMU's
accelerometer_noise_density: 1.86e-03
accelerometer_random_walk: 4.33e-04
gyroscope_noise_density: 1.87e-04
gyroscope_random_walk: 2.66e-05
rostopic: /imu0
update_rate: 200.0

Set update_rate to the rate the IMU really runs at in the bag. Kalibr uses it to turn the continuous-time noise into a per-sample noise.

The default IMU model, calibrated, assumes the IMU’s scale and axis errors are already corrected. If they are not, the camera–IMU guide says “one should use an IMU model which calibrates these values”: --imu-models scale-misalignment in step 8.

Now the roles swap. “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.” The camera–IMU guide adds:

  • “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”: “low shutter times” and “good illumination”
  • “ensure low jitter timestamps in same clock”

The guide reports that “Good results have been obtained by using a camera rate of 20 Hz and an IMU rate of 200 Hz.” Furgale, Rehder and Siegwart (2013), the method behind the tool, collect data over “typically 1–2 minutes” as the sensor head “is waved in front of a static calibration pattern”. In their own 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”.

Keep the target in view while moving. Rotate around every axis and translate along every axis, not just pan left and right. With a checkerboard or circle grid, avoid motions that could make the target’s pose flip.

Why each tip:

  • All axes. Rotation about one axis tells the solver nothing about the IMU’s offset along that axis; the reasoning is on IMU Calibration for Camera Rigs.
  • The target in view. Kalibr’s only visual measurements are the target’s corners. A frame without the target adds nothing to tie the IMU’s motion to the cameras.
  • No shocks. To the best of our knowledge, a knock is a very short, large acceleration that the solver’s smooth spline trajectory cannot follow, and it may exceed the accelerometer’s range, so the seconds around it fit badly. The guide singles out picking the sensor up and putting it down, where knocks are most likely.
  • Low blur, good light. Sharp corners need a short exposure, and a short exposure needs bright light; see Lighting: why calibration wants bright, even light.
  • One clock, low jitter. Kalibr estimates one constant time offset per camera. Jitter is noise that a constant cannot absorb, and two clocks that drift apart change the offset during the recording (When the offset changes during a recording).

Run, following the wiki’s example:

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

Time calibration is on by default. Kalibr first guesses each camera’s offset by cross-correlating the camera’s and the IMU’s angular-rate magnitudes (findTimeshiftCameraImuPrior in IccSensors.py), then refines it. --timeoffset-padding bounds only the refinement: its help text reads “Maximum range in which the timeoffset may change during estimation [s]” (kalibr_calibrate_imu_camera). The tool writes <bag>-camchain-imucam.yaml, with T_cam_imu and timeshift_cam_imu added to each camera; <bag>-imu.yaml; <bag>-results-imucam.txt; and <bag>-report-imucam.pdf. Every field is in the reference.

The camera-to-camera transforms are kept from step 5 unless you pass --recompute-camera-chain-extrinsics, which the source calls “exclusively recommended for debugging purposes”.

Work through the report and the results file. The checks come from the wiki’s RealSense tutorial unless noted.

Check Where What to see If not
IMU sample timing “imu0: measurement rates” page flat at the expected rate “Inspect the IMU time dt plot carefully in the PDF report!” Fix the timestamps before anything else
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”
Transforms T_ci in the results file matches the rig “Sanity check your final rotation and translation with hand-measured values.”
Reprojection error results file and the reprojection pages points inside the dashed 3σ circle the camera–IMU guide’s tip: “keep the motion blur low”
Time shift timeshift cam0 to imu0 for scale, the wiki’s example has −8.121e-05 s and −8.681e-05 s for its two cameras check how the timestamps are made

Remember the direction of each transform: T_ci takes IMU coordinates to camera coordinates, so its translation is the IMU’s position seen from the camera. How Kalibr names transforms explains the convention.

From our conversations with people in the industry, a useful final check is to record the calibration twice and compare the two results: values that move a lot between two good recordings were not well determined by either.

Symptom Likely cause What the sources say to do
“Cameras are not connected through mutual observations” too few frames with the target in both cameras, or cameras not synchronised record more shared views; the message suggests “Maybe adjust the approx. sync. tolerance” (--approx-sync, default 0.02 s)
Optimisation diverges in the first images “a bad initial guess on the focal lengths” “just try to restart the calibration”
Target never or rarely detected wrong target.yaml, no white border, other AprilTags in view, blur use --show-extraction to “visualize the calibration target extraction process”; check the dimensions and the border
Checkerboard never detected targetCols and targetRows counted as squares they are “number of internal chessboard corners”
Scale of every translation slightly off the printed target is not the size in the YAML remeasure: “Most printers will scale the target during the printing process”
Target pose flips symmetric checkerboard or circle grid “The use of an Aprilgrid is recommended to avoid this problem entirely.”
“Omni with equidistant model not yet supported!” omni with equidistant in a YAML file use omni-radtan, or another model
IMU residuals far outside ±3σ noise values too small, or bad data inflate the noise values; check the timestamps
IMU timestamps in bursts messages buffered and republished, as in the wiki’s example of “a burst of IMU are send at a rate of 1ms with gaps of 6ms between” “You will need to rectify the timestamp problems.”
Time offset runs into its bounds the refined offset moves further from the cross-correlation first guess than --timeoffset-padding (default 0.03 s) allows, or bad data the wiki: “this padding should not reflect the estimated temporal offset but merely a guess for the bounds within which this offsets will vary during calibration”, and “trouble finding an appropriate value likely hints to issues in the dataset”
Bag rejected a ROS 2 bag convert it to ROS 1 with rosbags-convert

The multi-IMU page sums up the biggest one: “The most common failure mode of kalibr appears to be incorrect timestamps provided by the user.” Its --perform-synchronization option corrects clock jitter and skew, but it “will alter your timing” and is “solely recommended for assessing potential improvements through more adequate system design.”

These prompts work with any capable AI assistant. Paste your own files where the brackets are. Check what comes back against the reference page: an AI can misread a transform’s direction as easily as a person can.

Below is a Kalibr camchain-imucam.yaml, its results-imucam.txt and my target.yaml.
Kalibr's convention: T_a_b maps a point from frame b into frame a, translations in metres;
T_cn_cnm1 under cam1 is T_c1_c0; T_cam_imu is IMU to camera; t_imu = t_cam + timeshift_cam_imu.
Check, and show your working for each:
1. Each intrinsics and distortion_coeffs list has the right length for its camera_model
and distortion_model.
2. fu and fv are close, and the principal point is near the image centre for the resolution.
3. Every 3x3 rotation is orthonormal with determinant +1.
4. The baseline norm of T_cn_cnm1, compared with my measured lens spacing of [X] m.
5. The IMU position in each camera frame (the translation of T_cam_imu) and the camera
position in the IMU frame (the translation of its inverse), compared with my measured
offsets: [describe them].
6. Whether the timeshift values are plausible and consistent between cameras on one clock.
7. Whether the normalized residuals in the results file suggest the IMU noise values are
too small or too large.
List anything that looks wrong, most serious first. Do not guess at values I have not given you.
[paste camchain-imucam.yaml]
[paste results-imucam.txt]
[paste target.yaml]

Convert Kalibr output to OpenCV or ROS camera_info

Section titled “Convert Kalibr output to OpenCV or ROS camera_info”
Convert this Kalibr camchain.yaml for a stereo pair into (a) OpenCV camera matrices and
distortion vectors for cv2 and (b) ROS sensor_msgs/CameraInfo YAML for each camera.
Kalibr's intrinsics are [fu, fv, pu, pv] for pinhole. radtan coefficients are
[k1, k2, p1, p2]. equidistant coefficients are [k1, k2, k3, k4] of the Kannala-Brandt
model. T_cn_cnm1 under cam1 maps cam0 coordinates to cam1 coordinates.
For each camera, say which OpenCV and ROS distortion model you used and why. If a camera
uses omni, ds or eucm, tell me there is no exact equivalent instead of approximating
silently. For the stereo pair, write Python that calls cv2.stereoRectify with the right R
and T from T_cn_cnm1, and fill in R and P in the camera_info from its output.
[paste camchain.yaml]
Here are the noise specifications from my IMU's datasheet. Convert them into a Kalibr
imu.yaml: accelerometer_noise_density in m/s^2/sqrt(Hz), accelerometer_random_walk in
m/s^3/sqrt(Hz), gyroscope_noise_density in rad/s/sqrt(Hz), gyroscope_random_walk in
rad/s^2/sqrt(Hz). Show every unit conversion step. Note that Kalibr's noise densities are
continuous-time values and that angular random walk and velocity random walk on a
datasheet are white-noise terms. If the datasheet gives no bias random walk, say so plainly
and explain what I would need (for example an Allan deviation) instead of inventing one.
The IMU runs at [rate] Hz on topic [topic]. Finally, show the values multiplied by 10, the
inflation the Kalibr wiki says may be needed for low-cost sensors.
[paste the datasheet's noise table]
Here is my Kalibr results-imucam.txt and a description of the report plots.
Explain, in plain language, what each number in the Normalized Residuals and Residuals
sections means, whether my gyroscope and accelerometer residuals look consistent with the
noise values in the IMU configuration section, and whether the time shift and the
transforms look plausible. Then list the most likely causes of anything that looks wrong,
using only what is in the file.
[paste results-imucam.txt]
[describe the plots: are the IMU errors inside the 3-sigma lines? do the biases stay
inside their bounds? is the IMU rate plot flat?]