Calibration: Intrinsic, Extrinsic, Temporal

Type 23 mm for a checkerboard with 25 mm squares, and every stereo depth comes out 8% short. The reprojection error stays at 0.42 px, so every check stays green. Only a length you measure yourself catches it.

Drag the square size away from 25 mm and watch the gripper close on air while the dashboard says pass. Then press the tape check. Then we build, one calibration at a time, what each one solves, what makes it observable, and the trace each fault leaves.

You need matrix times vector, the pinhole camera and a little Python. We build the rest from zero.

Lesson 5 of the Robotics Engineering track. Before: Lesson 4, The Sensor Suite. Next: Lesson 6, The SLAM Frontend. Lesson 4 asked what each sensor lies about. This lesson asks how we measure the numbers that tie the sensors together, and how we know when they are wrong.

Mistype the square, watch the grasp

25.0 mm

Illustrative rig, numbers from our simulation: 20 synthetic views of a 9 by 6 board with 25 mm squares, 0.3 px corner noise, calibrated with OpenCV's calibrateCamera and stereoCalibrate. The RMS error was 0.42 px for every typed size; K was identical; the baseline came out 0.120 m at 25 mm and 0.110 m at 23 mm. The mug sits 0.300 m from the cameras.

Chapter 0

The Typo: Eight Percent Short, Zero Residual

Sort a robot's calibrations into three kinds, and find the fault that no residual can see

A picking arm carries a stereo camera. Its calibration passed with a reprojection error of 0.42 px. Weeks later the gripper closes 24 mm short of every mug. The cause is one line in a file: someone typed 23 mm for checkerboard squares that measure 25 mm.

So every length from that calibration is 23/25 = 0.92 of the truth. The stereo baseline is 0.92 of the truth, so every depth is too. A mug at 0.300 m reads 0.276 m. The reprojection error did not move, because nothing in the images changed. Chapter 3 proves why.

A robot carries three kinds of calibration. Intrinsics map a ray to a pixel: focal lengths, principal point and lens distortion. Extrinsics place each sensor on the robot: one rigid transform per sensor, as in Lesson 1. Temporal calibration finds the offset between two sensors' clocks; Lesson 2 built the clocks.

KindUnknownsMeasured fromFails silently when
Intrinsic4 to 5 for K, 2 to 5 for the lensa flat board, many tilted viewsthe board size is wrong, or the views never reach the image corners
Extrinsic6 per sensor paira shared target, or the same motion seen by boththe motion never rotates, or rotates about one axis only
Temporal1 offset per clock pair, plus its driftimage motion against gyro ratenothing moves, or the turn rate never changes

The residual is the gap between where a feature appears and where the calibrated model predicts it. It is the only alarm a running robot has. The device asks it about five faults.

Ask the residual about five faults

The top bar is the residual the robot measures while it drives. The yellow line is the noise floor. The bottom bar is the true error the fault causes. Pick a fault.

Illustrative drive, the same seeded model as the Chapter 9 fault injector: 300 features at 1 to 20 m depth, up to 400 px from the image centre, image speeds up to 300 px/s, 0.3 px noise, f = 800 px. The true errors are the faults themselves.

Four faults lift the residual above its 0.29 px floor, from 0.76 px for the lens to 9.4 px for the lever arm. The typo leaves it at 0.29 px while every depth is 8% wrong. A fault that scales the whole world is invisible to any test that compares images with images.

Symptom: grasps and measured distances are short by the same percentage at every range, and every calibration check passes.

Measure: measure a known length with the calibrated sensor: a 1.000 m bar reads 0.920 m.

Fix: measure the printed squares with calipers, because printers rescale pages. Store the size with the board's ID, and put the bar check in the acceptance test.

The road

  1. One view: a flat board seen by a camera is a homography.
  2. Zhang: two equations per view pin down K.
  3. Scale: the board size lands only in the translation.
  4. Tilt: why face-on views teach nothing.
  5. Coverage: the reprojection error covers only where you looked.
  6. Hand-eye: the same motion, seen by two sensors.
  7. Lever arm: you cannot see it without turning.
  8. Time offset: a clock offset as an estimated state.
  9. Showcase: a residual monitor that names each fault.
  10. Field guide: the table, the code and the checks.
Which fault leaves the reprojection residual exactly where it was?

Chapter 1

One Board View Is a Homography

Turn a flat board's known corners into a 3 by 3 matrix, and read a test for K out of it

Hold a printed checkerboard in front of the camera. You know each inner corner's place on the board in metres; the detector finds its place in the image in pixels. One view of a 9 by 6 board links 54 known points to 54 pixels.

Put the board's frame on the board: x and y along the squares, z out of the board. Then every corner has Z = 0. The camera model from VNAV Lecture 5 multiplies the point by K [r₁ r₂ r₃ t], and the zero removes r₃. What is left is a 3 by 3 matrix acting on (X, Y, 1). It is a homography: a map from one plane to another.

Name the parts. K holds the focal length f and the principal point c. r₁ and r₂ are the board's x and y directions in the camera frame, and t is its origin. λ (lambda) is a scale no pixel can see. The homography H is:

Say it aloud

H equals lambda times K times the matrix whose columns are r-one, r-two and t.

H
H the homography: takes a board point (X, Y, 1) to a pixel, up to scale. Its columns are h-one, h-two, h-three.
λ
lambda an unknown scale. Pixels are ratios, so multiplying H by any number changes no pixel.
K
K the intrinsic matrix: f-x, f-y, c-x, c-y. Here f = 800 px and c = (320, 240).
r₁
r-one the board's x direction seen from the camera: a unit vector.
r₂
r-two the board's y direction: a unit vector at right angles to r-one.
t
t where the board's origin sits in the camera frame, in metres.
In plain words

Write the board's two axis directions r-one, r-two and its origin t as three columns. Multiply by K. Any scale lambda gives the same pixels. The detector's 54 matches pin down H up to that lambda.

With numbers

With made-up numbers: the board faces the camera 0.6 m away, so r-one = (1, 0, 0), r-two = (0, 1, 0), t = (0, 0, 0.6). With lambda = 1, H has columns (800, 0, 0), (0, 800, 0) and (192, 144, 0.6). The corner at X = 0.1 m, Y = 0 maps to (80 + 192, 144, 0.6), so u = 272 / 0.6 = 453.3 px and v = 240 px. The pinhole gives the same: 800 × 0.1 / 0.6 + 320 = 453.3.

Now undo K: K⁻¹h₁ = λ r₁ and K⁻¹h₂ = λ r₂. The two undone columns must have the same length and meet at 90°, because r₁ and r₂ do. With the right K they pass this test in every view. With a wrong K they fail it, unless the board faces the camera squarely.

Tilt the board, test a guess for K

Left: the board in the image. Right: the two columns after undoing your guessed K. Guess wrong, then tilt.

30°
−20°

Illustrative camera: f = 800 px, c = (320, 240). A 9 by 6 board, 0.6 m away, no noise, so the test is exact.

Face-on, every guess passes. With f = 700 px and 30° of tilt about x, the lengths differ by 3%; add 20° about y and the angle opens to 92.2°. Tilt creates this information (Chapter 4).

Symptom: one view's reprojection error is 3 px while the others sit near 0.4 px.

Measure: print the error per view, and fit a plane to that view's corners in 3-D.

Fix: a bent board breaks Z = 0, so no homography fits it. Mount the print on glass or flat aluminium, and drop views where the board flexed.

Why does the third rotation column r₃ drop out of a board view?

Chapter 2

Two Equations per View: Zhang's Method

Stack each view's test into a linear system, and count how many views it needs

Chapter 1's test has K inside it twice, which is hard to solve. Zhang's trick (IEEE TPAMI, 2000) is to name the product instead. Call B the matrix K⁻¹ transposed times K⁻¹. B is symmetric, so it has 6 entries, and we know it only up to scale: 5 numbers to find. Call the first two columns of a view's homography h₁ and h₂. The test becomes two equations:

Say it aloud

h-one transpose B h-two equals zero; and h-one transpose B h-one equals h-two transpose B h-two.

h₁
h-one the first column of this view's homography, measured from the corners.
h₂
h-two the second column of the same homography.
B
B K inverse transposed times K inverse: the unknown. Six entries, five once the scale is free.
T
transpose turns the column into a row, so row times B times column is one number.
In plain words

Measured through B, column h-one times column h-two must give zero: the board's axes are square. Column h-one times itself must equal h-two times itself: the axes have equal length. Lambda appears on both sides and cancels, so it never needs to be known.

With numbers

With Chapter 1's face-on view, h-one = (800, 0, 0) and h-two = (0, 800, 0). The first equation gives 800 × 800 × B₁₂ = 0, so B₁₂ = 0: no skew. The second gives 640,000 B₁₁ = 640,000 B₂₂, so f-x = f-y. Neither says what f is. A face-on view only confirms the shape of K.

Each equation is linear in the 6 entries of B, so each view adds two rows to a matrix V, and we solve V b = 0 with an SVD. Count: 5 unknowns, 2 rows per view, so 3 views give a unique answer. Two views work if you also assume zero skew, which modern sensors justify. Zhang's paper states both cases.

Add views until K locks

Each bar is a singular value of V, on a log scale. A unique answer needs five of them above zero. Add views and watch the fifth bar rise.

From our run of the lab's kernel: views tilted 20° about different axes, 0.3 px corner noise, 120 seeded trials per row. The spread of f is the standard deviation over the trials. The zero-skew row is scaled to match the others.

With 3 views, f comes out with a spread of 29 px at 0.3 px of corner noise. With 6 views it drops to 6.3 px. The closed form is a first guess. OpenCV's calibrateCamera then refines K, the distortion and every pose together, by minimising the reprojection error with Levenberg-Marquardt (VNAV Lecture 9). You write the closed form in the lab.

Symptom: the closed form returns NaN for f, or a focal length of several thousand pixels.

Measure: the fifth singular value of V over the first. Near zero means B is not pinned, and noise can make it non-positive, so a square root fails.

Fix: add views tilted in different directions, well beyond the minimum of three.

With skew left free, why does Zhang's method need at least three views?

Chapter 3

The Board Size Lands Only in t

Follow a wrong square size through Zhang's equations, and see why only a measured length catches it

Tell the solver the squares are 23 mm. The corners in the image do not move: they are photons. Only the model coordinates shrink, from (X, Y) to (sX, sY) with s = 23/25 = 0.92. To send smaller coordinates to the same pixels, the fitted H multiplies h₁ and h₂ by 1/s and keeps h₃. The fit is exact, so the residual does not change.

Now put the new columns into Zhang's two equations. Each side has one h₁ or h₂ on the left and one on the right, so each side picks up 1/s², and it cancels. B is unchanged, so K is unchanged, and so is the lens model. The scale has to go somewhere. It goes into the translation, which we recover from one view like this:

Say it aloud

t equals K inverse times h-three, divided by the length of K inverse times h-one.

t
t the board's origin in the camera frame, in metres: the only metric output of a view.
K⁻¹
K inverse undoes the intrinsics: turns pixels back into ray directions.
h₃
h-three the third column of H: lambda K t.
‖K⁻¹h₁‖
the length of K inverse h-one equal to lambda, because r-one has length 1. Dividing by it removes lambda.
In plain words

Undo K on h-three to get lambda times t. Find lambda as the length of K inverse h-one, since r-one is a unit vector. Divide. If a typo made h-one longer by 1/s, lambda grows by 1/s, and t shrinks by s.

With numbers

From the lab's run: the board in view 0 is 0.6004 m away. Told 23 mm, the solver puts it at 0.5524 m: 0.5524 / 0.6004 = 0.920, and f stays 800.000 px. Our OpenCV cross-check on 20 views agrees: RMS 0.4067 px both times, f-x 804.373 px both times, and every view's distance scaled by exactly 0.920.

Every metric number downstream inherits s. A stereo calibration recovers the baseline from board poses: ours came out 0.1199 m at 25 mm and 0.1104 m at 23 mm. Depth is focal length times baseline over disparity, so every depth shrinks by 0.92. A hand-eye calibration that uses board poses shrinks its lever arm the same way.

Sweep the typo, see what moves

Three ratios against the truth. Purple is the focal length, yellow the reprojection error, warm the recovered distance. Drag the typed size.

23.0 mm

Numbers from the lab's noiseless kernel (focal length and distance) and our noisy OpenCV run (residual 0.41 px). The true squares are 25 mm and the true distance is 0.600 m.

Symptom: the map of a 40 m by 25 m hall comes out 36.8 m by 23.0 m, and loop closures look perfect.

Measure: one external length: a surveyed bar, two fiducials a known distance apart, or the stereo depth against a LiDAR range.

Fix: measure the board, type its size once into a board file, and fail the calibration if the bar check is off by more than 0.5%.

You type 27 mm for a board with 25 mm squares, then calibrate a stereo pair. What happens?

Chapter 4

Tilt Is What Makes K Observable

Measure how fast the focal length's spread falls as the board tilts, and why one tilt axis is never enough

Chapter 1's face-on board could not tell f = 700 from f = 800. A tilted board foreshortens, and how much it foreshortens depends on f. Tilt is the information.

Each view's two rows of V depend only on r₁, r₂ and K, not on t. So eight views tilted the same way about the same axis give the same two rows eight times. V keeps rank 2 at any tilt, and K has a whole family of answers. Tilt the views about different axes and the rows differ. A matrix is observable here when its fifth singular value is clearly above zero.

How fast does it improve? We ran the lab's experiment: eight views, the tilt axis turning 45° from view to view, 0.3 px corner noise, 120 trials per tilt.

TiltSpread of fSpread of c-xFailed solves
1.1°3,172.8 px74.3 px30 of 120
5.7°31.4 px3.2 px0
11.5°10.6 px1.9 px0
20.1°5.4 px1.5 px0
28.6°3.9 px1.4 px0

From 1.1° to 20.1° the spread of f falls 589 times, from 3,173 px to 5.4 px. At 1.1° a quarter of the solves return no real number. The noiseless fifth singular value, divided by the tilt squared, stays flat to within 7.4%: observability grows as the tilt squared.

Tilt the views, watch f settle

Left: the eight board views. Right: the spread of f against tilt, and 30 trial answers as dots around the true 800 px. Drag the tilt, then make all views share one axis.

4°

From our run of the lab's kernel at 14 tilts, seeded. With one shared axis the noiseless fifth singular value is about 10⁻¹⁷ of the first: machine zero, so the answer is arbitrary and no spread is quoted.

Symptom: two calibrations of the same camera, an hour apart, disagree by 30 px in f.

Measure: the standard deviations OpenCV's calibrateCameraExtended returns for each intrinsic, or the fifth singular value of V.

Fix: tilt the board 20° or more, toward and away, left and right, so the tilt axis changes between views.

Eight views are all tilted 30° about the same horizontal axis. What does Zhang's method return?

Chapter 5

The Reprojection Error Covers Only Where You Looked

Read the one number a calibration reports, and see a lens model go wrong where the board never went

A calibration reports one number. It projects each board corner through the fitted model and compares it with the detected corner. Call the number of corners N, the detected pixel of corner i xi, and the reprojected pixel x̂i (x-hat-i). The RMS reprojection error is:

Say it aloud

RMS equals the square root of one over N times the sum over i of the squared length of x-i minus x-hat-i.

1/N
one over N divide by the number of corners, to average.
Σi
the sum over i add one term for every corner in every view.
‖xi − x̂i‖²
the squared length of x-i minus x-hat-i the squared pixel distance from the detected corner x-i to where the model puts it, x-hat-i.
In plain words

For each corner, measure the distance in pixels between x-i and x-hat-i. Square each distance, average over the N corners, and take the square root.

With numbers

With corner noise of 0.3 px on each axis, a perfect model leaves distances of about the square root of 2 times 0.3 = 0.42 px, because OpenCV measures the 2-D distance. Our 20-view run reported 0.407 px: slightly less, because the fitted parameters absorb a little of the noise.

The sum runs only over corners you showed it. Lens distortion is a polynomial in the distance r from the image centre (Lesson 4, VNAV Lecture 5). A polynomial fitted on small r says nothing reliable about large r.

Calibrate in the centre, read the corners

The curves show how far the lens moves a point, against its distance from the image centre. Pink is the true lens, purple the fit. Blue marks where corners were seen. Pick a coverage.

From our OpenCV run: a lens with k₁ = −0.28 and k₂ = 0.10, f = 800 px, 640 by 480, 15 seeded views (12 stayed in frame at full coverage), 0.3 px noise, five distortion terms fitted. The image corner is 400 px from the centre.

Centre-only views give an RMS of 0.405 px, the same as the half-frame run. Yet at the image corner the fit says the lens moves a point 1.4 px outward, while the truth is 25.5 px inward: 27 px wrong. The full-frame fit gives −25.3 px there. Fixing the third coefficient at zero, a normal choice for a non-fisheye lens, cuts the centre-only error to 6 px but does not remove it.

Symptom: straight shelf edges bow near the image borders after undistortion, and the calibration reported 0.4 px.

Measure: plot every detected corner on one image. Note the largest radius reached against the 400 px corner radius.

Fix: put the board in all four corners and along the edges, and fix k₃ (OpenCV's CALIB_FIX_K3) unless the lens is a fisheye.

Two calibrations both report 0.40 px. One used views near the centre only. What can you say about the image corners?

Chapter 6

Hand-Eye: The Same Motion, Seen Twice

Recover the rotation between two sensors by lining up their motion arrows

A LiDAR sits under a camera. We need the rigid transform between them, but the LiDAR cannot see printed squares. Both sensors ride one rigid body, so they feel the same motion, each in its own frame.

Call A the camera's motion between two instants, from the board or from visual odometry. Call B the LiDAR's motion over the same interval, from scan matching. Call X the LiDAR's pose in the camera frame, TCL in Lesson 1's notation. All three are 4 by 4 rigid transforms:

Say it aloud

A times X equals X times B.

A
A the camera's own motion from one instant to the next.
X
X the unknown: the LiDAR's pose in the camera frame. It never changes, because the mount is rigid.
B
B the LiDAR's own motion over the same interval.
In plain words

Take a point in the LiDAR frame. Route one: move it with B, then carry it into the camera frame with X. Route two: carry it with X, then move it with A. A rigid mount makes the routes agree.

With numbers

With made-up numbers, on the floor: X turns 90° and shifts (0.30, 0.10) m. The LiDAR turns 90° and moves (0.50, 0) m, so the camera reports a 90° turn and (0.40, 0.30) m. Translations: A X gives (−0.10, 0.30) + (0.40, 0.30) = (0.30, 0.60); X B gives (0, 0.50) + (0.30, 0.10), the same.

Split it. The rotation part says RA RX = RX RB, and it has no translation in it, so solve it first. Write each rotation as its rotation vector, axis times angle. Then each motion i gives a pair of arrows with ai = RX bi: RX turns the LiDAR's arrows onto the camera's.

Finding the rotation that best lines up matched arrows is the orthogonal Procrustes problem. Sum the outer products, take an SVD, and keep a rotation, not a mirror:

M = Σi ai biT  →  M = U Σ VT  →  RX = U · diag(1, 1, det(U VT)) · VT

By hand: let RX be 90° about z. LiDAR turns of 0.40 rad about z and 0.55 rad about y give a1 = 0.40 ez and a2 = −0.55 ex. M has singular values 0.3025, 0.16 and 0; the determinant fixes the last direction, and RX comes back exactly. This is Park and Martin's method (1994). Tsai and Lenz (1989) showed that it takes two motions with non-parallel axes.

Line up the arrows

Blue: the camera's rotation vectors. Dashed light blue: the LiDAR's. Purple: the LiDAR's after the estimated rotation. Pick a motion set.

The lab's rig: X turns about 90°; noiseless motions of 0.35 to 0.70 rad; our NumPy run. On a separate test, OpenCV's calibrateHandEye (Tsai, Park, Daniilidis) matched this solve to within 10⁻¹²°.

Symptom: a ground robot's camera-to-LiDAR yaw changes by degrees between calibration drives.

Measure: the singular values of M. A second value near zero means every motion turned about one axis, so the turn of the mount about that axis is free.

Fix: a robot that only yaws cannot observe it from motion, nor the lever arm's height. Add a target both sensors see, or tilt the rig by hand during the run.

What is the least the hand-eye rotation needs?

Chapter 7

The Lever Arm Needs Rotation

Solve for the offset between two sensors, and price how much turning it needs

An intern drives 60 m down a straight aisle, logs both sensors and runs the extrinsic solve. It converges, and reports a lever arm of zero.

With RX known, the translation half of A X = X B is linear. Call tX the lever arm: where the LiDAR sits in the camera frame. Call RA and tA the camera's rotation and move, and tB the LiDAR's move:

Say it aloud

R-A minus I, times t-X, equals R-X times t-B, minus t-A.

RA
R-A the camera's rotation during the motion.
I
I the identity: the rotation that does nothing.
tX
t-X the unknown lever arm, in metres.
RX
R-X the mount rotation, solved in Chapter 6.
tB
t-B the LiDAR's move during the motion.
tA
t-A the camera's move during the motion.
In plain words

Turn the LiDAR's move t-B into the camera frame and subtract the camera's move t-A. What is left is the extra arc the offset t-X swept while the robot turned by R-A. Stack this for every motion and solve by least squares.

With numbers

Chapter 6's floor example: R-A minus I is [−1 −1; 1 −1], with determinant 2. The right side is (0, 0.50) − (0.40, 0.30) = (−0.40, 0.20). Solving gives t-X = (0.30, 0.10) m, the truth.

Now drive straight. RA = I, so the left side is zero times tX, and every lever arm fits. Two points on a body that translates without turning move the same way. Only a turn makes the farther sensor sweep a larger arc. The least-squares solver returns the smallest answer that fits: zero, both sensors in one place.

How much turning? In the plane, both singular values of R(θ) − I equal 2 sin(θ/2). So 1 cm of error in a measured move becomes 1 cm / (2 sin(θ/2)) of lever-arm error: 0.29 m at 2°, 5.7 cm at 10°, 1.9 cm at 30°, 0.7 cm at 90°. Our 3-D Monte Carlo with 10 random-axis motions agrees: 0.19 m at 2°, 1.3 cm at 30°.

Turn more, pin the lever arm

Left: the true LiDAR place in pink, 30 trial estimates in purple. Right: error against turn; yellow is the one-motion law. Drag the turn.

5°

Illustrative planar solve, live in your browser: 6 motions per trial, turning ±θ with seeded random moves, 1 cm of noise on each measured camera move, RX known, 30 trials. True lever arm (0.30, 0.10) m.

When both sensors can see a target, it is faster. A board with holes or sharp edges gives matched points in the image and the scan, and one rigid alignment solves the extrinsic. Targetless methods align image edges with depth jumps (Levinson and Thrun, 2013), or maximise mutual information between LiDAR intensity and image brightness (Pandey et al., 2012). Lesson 1, Chapter 6 shows each error in pixels: 1° of rotation moves every point 14 px; a 2 cm shift moves points 16 px at 1 m.

Symptom: the lever arm reads (0, 0, 0), or changes by tens of centimetres between runs.

Measure: the smallest singular value of the stacked (RA − I). Near zero means some direction of the lever arm is not pinned.

Fix: drive figure-eights with sharp turns, or take the lever arm from the CAD model and calibrate only the rotation.

Each calibration motion turns 10° and each measured move has 1 cm of error. About how large is the lever-arm error?

Chapter 8

The Time Offset Is a State

Estimate a clock offset from image motion, price its precision, and see when it hides behind a bias

Lesson 2 built the clocks, the stamps and a cross-correlation for a recorded bag. Here the offset becomes one more state the estimator solves for.

The camera stamps a frame t, but it took the frame at t + td. A feature that crosses the image at image velocity u̇ (u-dot), in pixels per second, lands that much motion away from the prediction. Call the leftover r:

Say it aloud

r equals u-dot times t-d.

r
r the residual from the offset, in pixels.
u̇
u-dot the feature's image velocity, in pixels per second. The tracker already has it.
td
t-d the time offset between the camera's clock and the estimator's, in seconds.
In plain words

Multiply the feature's speed u-dot by the stamp's lateness t-d. The slope of r against u-dot is t-d, so the estimator adds one Jacobian column.

With numbers

With illustrative numbers: f = 800 px and a 0.30 rad/s turn give u-dot = 240 px/s. With t-d = 18.4 ms, r = 240 × 0.0184 = 4.42 px, 14.7 times a 0.3 px tracker noise. Driving straight, r is near zero.

The Cramér-Rao bound (Fisher Information) gives the smallest possible spread. Call the tracker noise σpx and the feature count N:

Say it aloud

sigma t-d equals sigma pixels over root N times u-dot.

σtd
sigma t-d the best possible standard deviation of the offset estimate, in seconds.
σpx
sigma pixels the tracker's noise per feature, 0.3 px here.
√N
root N the square root of the number of features in the frame.
u̇
u-dot the image velocity, as above.
In plain words

Divide the tracker noise sigma-pixels by the image speed u-dot and by the square root of the feature count N. Ten times more features buys about 3.2 times; ten times more motion buys 10.

With numbers

With illustrative numbers: 0.3 / (√200 × 240) = 88 µs from one frame. At 5 px/s, 200 features and a 5 ms prior leave 3.2 ms. At u-dot = 0 the frame teaches nothing.

A steady turn is a worse trap. Over a 1 s window, a gyro bias b also shifts every feature by a constant, f · b pixels. When u̇ is the same everywhere, the two columns are proportional and the data cannot split the residual. Rate reversals separate them.

Turn steadily, then reverse

Dashed: the prior, 5 ms by 10 mrad/s. Purple: the posterior after 200 features. Raise the speed, then add reversal.

240 px/s
0%

Illustrative linear-Gaussian update, exact in your browser: f = 800 px, a 1 s window (so each bias unit moves pixels by 800), σpx = 0.3 px, 200 features. Our NumPy run gives the same: constant rate 4.945 ms with correlation −0.9998; half reversed 0.088 ms with correlation 0.

At a constant rate, 200 features at 240 px/s move the offset's spread from 5.000 ms only to 4.945 ms, with correlation −0.9998. With half turning the other way: 0.088 ms. The bias converges in both cases, so a dashboard that watches it stays green. Kalibr (Furgale et al., 2013) estimates the offset over a recording; Li and Mourikis (2014) estimate it online. Both need this kind of motion.

From a bag, the quickest estimate is a correlation of gyro rate against camera rate. The lab adds a parabola through the peak, which finds 18.384 ms from 5 ms samples. A rolling shutter adds a per-row offset (Lesson 4). Clocks drift too: an illustrative 40 ppm crystal gains 2.4 ms a minute, so let td wander slowly.

Symptom: the offset estimate walks by milliseconds every frame while the robot stands still.

Measure: its spread is not shrinking while its correlation with the gyro bias is near −1. A 0.5 px noise residual then moves it 1.96 ms, through the cross-covariance alone.

Fix: freeze the offset when the window has no rate change: zero its row of the gain. Inflating the noise 100 times still moves it 0.28 ms.

A robot turns at a steady 0.3 rad/s for the whole recording, with 200 good features. Why is the time offset still poorly known when a gyro bias is estimated too?

Chapter 9

Showcase: The Fault Injector

Regress the residual on four covariates, and let each slope name a fault in its own units

Calibration does not stay done. A bump knocks a mount, heat bends a bracket, a driver update moves the time stamp. A running robot can watch its own residuals, because each fault multiplies a different physical quantity. That quantity is the fault's covariate.

FaultThe residual grows withSlope means
Mount yaw δθ (or principal point)nothing: a constantintercept a = f δθ
Lever arm δt1/Z, inverse depthb = f δt
Time offset tdu̇, image speedc = td
Lens δk₁r³/f², radius cubedd = δk₁
Board size or baselinenothing at allinvisible: needs a measured length

Fit all four at once by least squares: residual = a + b (1/Z) + c u̇ + d r³/f². Each coefficient comes with a t-statistic, its value over its standard error. Far above about 5 means the fault is real. Fitting them together matters: one slope fitted alone soaks up the others.

Break the calibration, read the diagnosis

Inject faults. The scatter shows the residual against one covariate, with the other fitted terms removed, and the purple fitted line. The bars show each fault found, with pink ticks for the truth.

Illustrative drive, seeded, the same model our NumPy script fits: 300 features, 1/Z from 0.05 to 1 per metre, radius up to 400 px, image speed ±300 px/s, 0.3 px noise, f = 800 px. A fault is flagged when its |t| exceeds 5.

With an intercept, each fault comes back alone: yaw 0.299° with t = 94, lever 2.00 cm with t = 260, offset 18.44 ms with t = 191, lens 0.0146 with t = 25. Now turn the intercept off with only the yaw injected. The constant has nowhere to go, so it leaks: a 0.55 cm lever arm (t = 20) and a lens error (t = 12.5) appear that do not exist.

The monitor can also live inside the estimator. OpenVINS (Geneva et al., ICRA 2020) can carry the intrinsics, the camera-IMU extrinsics and the time offset as filter states. Keep an independent check anyway: a state that absorbs a fault also hides it, and nothing absorbs the square typo.

Symptom: after a bump, the monitor flags a lever-arm error and a lens error at the same time.

Measure: refit with an intercept. If the intercept carries it all, the mount yawed.

Fix: re-run only the extrinsic rotation. Leave the lens alone.

The residual against image speed is a line through zero with slope 0.012 s. Everything else is flat. What is wrong?

Chapter 10

Field Guide

Keep the calibration table, the code and the checks in one place

Every calibration solves for numbers that its own data must be able to see. Zhang's equations see K but not the board size, so only a measured length checks the scale. Hand-eye sees the rotation after two axes of turning and the lever arm only after real turns. The time offset shows only while the image moves at changing rates. A running robot names its faults by regressing residuals on their covariates, and still needs one external length.

CalibrationNeedsBlind whenCheck it with
Intrinsics (Zhang)3 or more views, tilted 20°+ about changing axesface-on or one tilt axis; corners never reachedfifth singular value of V; per-intrinsic spread; a coverage plot
Board scalethe true square sizealways, to every residuala measured bar: 1.000 m must read 1.000 m
Extrinsic rotationturns about 2 non-parallel axesyaw only (a ground robot)second singular value of M
Lever arm30°+ of turn per motionstraight drivingsmallest singular value of the stacked (RA − I)
Time offsetimage motion that changes rate and signstanding still; a steady turnits spread, with its correlation to the gyro bias
In servicefeatures across depth, radius and speedno intercept; no range diversitythe four-term regression, |t| > 5
python
import numpy as np

def v_ij(H, i, j):
    """Zhang's row: v_ij . b == h_i^T B h_j, with b = [B11, B12, B22, B13, B23, B33]."""
    return np.array([H[0,i]*H[0,j], H[0,i]*H[1,j] + H[1,i]*H[0,j], H[1,i]*H[1,j],
                     H[2,i]*H[0,j] + H[0,i]*H[2,j], H[2,i]*H[1,j] + H[1,i]*H[2,j], H[2,i]*H[2,j]])

def zhang_rows(H):
    """Two rows per view: r1 and r2 orthogonal, and equal in length."""
    return [v_ij(H, 0, 1), v_ij(H, 0, 0) - v_ij(H, 1, 1)]

def board_translation(K, H):
    """t = K^-1 h3 / |K^-1 h1|: the only metric output, and the only place the board size lands."""
    Ki = np.linalg.inv(K)
    return Ki @ H[:, 2] / np.linalg.norm(Ki @ H[:, 0])

def handeye_rotation(a_list, b_list):
    """Procrustes on rotation vectors: find R with a_i = R b_i. Returns R and the singular values."""
    M = sum(np.outer(a, b) for a, b in zip(a_list, b_list))
    U, S, Vt = np.linalg.svd(M)
    return U @ np.diag([1.0, 1.0, np.linalg.det(U @ Vt)]) @ Vt, S

def lever_arm(RA_list, tA_list, tB_list, RX):
    """Stack (R_A - I) t_X = R_X t_B - t_A. Returns t_X and the smallest singular value (the turn check)."""
    A = np.vstack([RA - np.eye(3) for RA in RA_list])
    b = np.concatenate([RX @ tB - tA for tA, tB in zip(tA_list, tB_list)])
    return np.linalg.lstsq(A, b, rcond=None)[0], np.linalg.svd(A, compute_uv=False)[-1]

def td_bound(sigma_px, n_features, u_dot):
    """Best possible spread of the time offset, in seconds."""
    return sigma_px / (np.sqrt(n_features) * u_dot)

def calibration_monitor(res, inv_z, u_dot, r_px, f):
    """Regress residuals on [1, 1/Z, u_dot, r^3/f^2]. Returns yaw (rad), lever (m), t_d (s), dk1, and t-statistics."""
    X = np.column_stack([np.ones_like(res), inv_z, u_dot, r_px ** 3 / f ** 2])
    beta = np.linalg.lstsq(X, res, rcond=None)[0]
    s2 = np.sum((res - X @ beta) ** 2) / (len(res) - 4)
    tstat = beta / np.sqrt(np.diag(s2 * np.linalg.inv(X.T @ X)))
    return beta[0] / f, beta[1] / f, beta[2], beta[3], tstat

We ran every function above in NumPy on this lesson's examples. board_translation scales by exactly 0.920 under the typo. handeye_rotation recovers X to 10⁻¹⁴ degrees from five motions. lever_arm returns (0.30, 0.10) on Chapter 6's floor example. td_bound(0.3, 200, 240) gives 88 µs, and the monitor names each injected fault with |t| above 25.

Where it sits. A production robot calibrates intrinsics on a bench, extrinsics and the time offset in one recorded session (Kalibr, or OpenCV's calibrateHandEye for an arm), then watches residuals in service. Lesson 6 builds the front end that consumes these numbers; a wrong one shows up there as drift that no tuning removes.

Keep going

Read next

The habit. For every calibrated number, ask what motion or view makes it visible, and what external measurement would catch it if it were wrong.
Which single check catches the fault that every residual misses?

Now teach it: press Present or Teach and explain why a wrong square size leaves K and the residual untouched but shrinks every depth. Then go back to the grasp and predict the miss at 27 mm before you drag there.

Calibration: Intrinsic, Extrinsic, Temporal · Robotics Engineering, Lesson 5
Previous: The Sensor Suite · Next: The SLAM Frontend · Back to Gleams