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.
The steps at a glance
Section titled “The steps at a glance”| 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 |
1. Prepare the cameras
Section titled “1. Prepare the cameras”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”.
2. Make and measure the target
Section titled “2. Make and measure the target”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:
# Example: a 6 x 6 grid of 8 cm tags with gaps of 0.3 x the tag sizekalibr_create_target_pdf --type apriltag --nx 6 --ny 6 --tsize 0.08 --tspace 0.3Then:
- Print it and mount it flat. The wiki: “Best is to glue it to a rigid plate such as aluminum or acrylic glass.”
- Measure it. “Most printers will scale the target during the printing process.” Measure one tag’s outer black edge for
tagSizeand the gap between tags, then settagSpacingto gap ÷tagSize.tagSpacingis a ratio, not a length. See target.yaml. - 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).
- Write
target.yamlwith the measured numbers:
# Example: replace these with your own measured valuestarget_type: 'aprilgrid'tagCols: 6tagRows: 6tagSize: 0.0795tagSpacing: 0.3Keep the target’s measurements with the calibration. If the target is measured wrong, every translation Kalibr reports is scaled wrong with it.
3. Record the camera dataset
Section titled “3. Record the camera dataset”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.
4. Get the data into a ROS 1 bag
Section titled “4. Get the data into a ROS 1 bag”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
rosbagspackage:rosbags-convert <ros2_bag_folder> --dst calib_01.bag, with--exclude-topicfor 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.csvtimestamp,omega_x,omega_y,omega_z,alpha_x,alpha_y,alpha_z1385030208736607488,0.5,-0.2,-0.1,8.1,-1.9,-3.3kalibr_bagcreater --folder dataset-dir/. --output-bag awsome.bagThe 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.”
5. Calibrate the cameras
Section titled “5. Calibrate the cameras”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:
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.0The 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_cnm1for 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).
6. Find the IMU noise values
Section titled “6. Find the IMU noise values”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'saccelerometer_noise_density: 1.86e-03accelerometer_random_walk: 4.33e-04gyroscope_noise_density: 1.87e-04gyroscope_random_walk: 2.66e-05rostopic: /imu0update_rate: 200.0Set 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.
7. Record the camera–IMU dataset
Section titled “7. Record the camera–IMU dataset”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).
8. Calibrate camera to IMU
Section titled “8. Calibrate camera to IMU”Run, following the wiki’s example:
kalibr_calibrate_imu_camera \ --target target.yaml \ --imu imu.yaml \ --imu-models calibrated \ --cam cam_april-camchain.yaml \ --bag imu_april.bagTime 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”.
9. Judge the results
Section titled “9. Judge the results”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.
Common failures
Section titled “Common failures”| 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.”
Prompts you can give an AI
Section titled “Prompts you can give an AI”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.
Check a camchain for problems
Section titled “Check a camchain for problems”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 anddistortion 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-Brandtmodel. 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 camerauses omni, ds or eucm, tell me there is no exact equivalent instead of approximatingsilently. For the stereo pair, write Python that calls cv2.stereoRectify with the right Rand T from T_cn_cnm1, and fill in R and P in the camera_info from its output.
[paste camchain.yaml]Compute IMU noise values from a datasheet
Section titled “Compute IMU noise values from a datasheet”Here are the noise specifications from my IMU's datasheet. Convert them into a Kalibrimu.yaml: accelerometer_noise_density in m/s^2/sqrt(Hz), accelerometer_random_walk inm/s^3/sqrt(Hz), gyroscope_noise_density in rad/s/sqrt(Hz), gyroscope_random_walk inrad/s^2/sqrt(Hz). Show every unit conversion step. Note that Kalibr's noise densities arecontinuous-time values and that angular random walk and velocity random walk on adatasheet are white-noise terms. If the datasheet gives no bias random walk, say so plainlyand 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, theinflation the Kalibr wiki says may be needed for low-cost sensors.
[paste the datasheet's noise table]Read a camera–IMU calibration report
Section titled “Read a camera–IMU calibration report”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 Residualssections means, whether my gyroscope and accelerometer residuals look consistent with thenoise values in the IMU configuration section, and whether the time shift and thetransforms 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 stayinside their bounds? is the IMU rate plot flat?]Sources
Section titled “Sources”- Kalibr wiki, ETH Zurich ASL: Multiple camera calibration, Camera–IMU calibration, Multi-IMU and IMU intrinsic calibration, Calibration targets, IMU noise model, YAML formats, Bag format, ROS 2 calibration, Camera focus, Calibration validator, Calibrating Intel RealSense cameras.
- Kalibr source code, github.com/ethz-asl/kalibr (commit
1f60227): kalibr_calibrate_cameras, kalibr_calibrate_imu_camera, ConfigReader.py, CameraCalibrator.py, IccSensors.py. - Furgale, P., Rehder, J. and Siegwart, R. (2013). Unified temporal and spatial calibration for multi-sensor systems. IEEE/RSJ IROS.
- Rehder, J., Nikolic, J., Schneider, T., Hinzmann, T. and Siegwart, R. (2016). Extending kalibr: Calibrating the extrinsics of multiple IMUs and of individual axes. IEEE ICRA.
- Usenko, V., Demmel, N. and Cremers, D. (2018). The double sphere camera model. International Conference on 3D Vision (3DV).
- allan_variance_ros, Oxford Robotics Institute.
- rosbags, the ROS bag conversion library used in the Kalibr ROS 2 guide.