Visual & Visual-Inertial Odometry

A drone flies a 98 m figure-eight with one camera and one IMU. The camera alone draws the right shape at 62% of its size. The IMU alone is 1.9 m off after 10 s. Fused, the estimate stays within 25 cm for the whole flight and reads the scale as 0.621, against a true 0.620.

Fly the loop with the camera only, then the IMU only, then both. Watch where each one goes wrong. Then we build it piece by piece: chaining frames, the missing metre, drift, the IMU, scale from acceleration, preintegration, the back end, and what no sensor here can see.

You need Lecture 7 (two-view geometry), Lecture 9 (least squares), a little matrix algebra and a little Python. We build the rest from zero.

Lecture 11 of 14 in our follow-along of MIT 16.485, Visual Navigation for Autonomous Vehicles (VNAV, taught by Luca Carlone). Every idea is re-taught here in our own words and devices. Previous: Lecture 10, optimization on manifolds. Next: Lecture 12, place recognition.

Fly the loop three ways

Illustrative toy flight, seeded: IMU at 100 Hz with a consumer-grade bias (0.05 m/s², 0.004 rad/s), camera keyframes at 10 Hz with 2% step noise, VO scale 0.62 units per metre. The fused filter starts from a 4 s alignment (Chapter 5). It runs in your browser; our NumPy copy gives the same numbers.

Chapter 0

Odometry: A Path Built From Steps

Step a drone around a loop one frame at a time and watch a tiny turn error open the loop

A drone flies indoors. There is no GPS. It has one camera and one IMU, an inertial measurement unit that measures turn rate and acceleration. It must still know where it is.

Odometry answers that from the drone's own sensors. The drone compares each new camera frame with the last one. The comparison gives one small step: how far the drone moved and how much it turned. Chain the steps and you get a path. Visual odometry (VO) takes the steps from the camera; visual-inertial odometry (VIO) also uses the IMU.

Chain the steps around a loop

Pink diamonds are landmarks; blue rays are the features the camera sees in this frame. Press Step to add one frame, or Run the lap. Then add a turn error to every step.

0.30°

Illustrative: 40 frames around a 5 m circle. Each step also gets 0.1° of turn noise and 2% of length noise from a fixed seed. Here the toy knows the scale; Chapter 1 takes it away.

Write the drone's pose at frame k as TW,k: the rotation and position of the body frame B in the world frame W. It is a 3 × 3 matrix for a planar drone, 4 × 4 in 3D. The step from frame k to frame k+1, measured in frame k, is Tk,k+1.

Say it aloud

T-W-k-plus-one equals T-W-k times T-k-k-plus-one.

TW,k+1
T-W-k-plus-one the new pose: where frame k+1 sits in the world.
TW,k
T-W-k the pose we already have for frame k.
Tk,k+1
T-k-k-plus-one the measured step: the motion from frame k to frame k+1, written in frame k's own axes. The inner letters touch, so the chain is valid.
In plain words

Take the last pose T-W-k. Rotate the new step T-k-k-plus-one by the drone's current heading, then add it. The result is the new pose. Every earlier turn shapes every later step.

With numbers

With made-up numbers: start at the origin facing east. Step 1: 1 m forward, then turn 5° right. Step 2: 1 m forward. The second step points at −5°, so frame 2 sits at (1 + cos 5°, −sin 5°) = (1.996, −0.087) m.

In the device, a turn error of 0.3° per frame is invisible in any one step. Over 40 frames it adds to 12°, and the loop misses its start by 0.95 m after 31.4 m. Nothing in the chain can notice: each step looks only at the frame before it. This is drift.

Symptom: a loop that does not close; a robot that comes home and thinks it is a metre away.

Measure: the gap between the start and the end of a known loop, as a share of the distance flown.

Fix: nothing in pure odometry. The IMU slows drift (Chapter 9); recognising the start removes it (Lectures 12 and 13).

The road

  1. Up to scale: frame-to-frame motion from one camera, and the metre it cannot see.
  2. Drift: how fast chained errors grow.
  3. The IMU: turn rate and specific force, with bias, noise and gravity.
  4. Dead reckoning: integrating the IMU, and how long it can bridge a gap (the hero's IMU-only path).
  5. Scale: recovering the metre from acceleration by linear least squares.
  6. Preintegration: many IMU samples, one summary between keyframes.
  7. Coupling: loose or tight, filter or fixed-lag smoother.
  8. Observability: what VIO can never know.
  9. Showcase: the hero's flight with motion, IMU grade and a camera dropout.
  10. Field guide: the formulas, the code and the credit.
Each VO step has a 0.3° turn error and is otherwise perfect. Why does the position error keep growing?

Chapter 1

Frame to Frame, Up to Scale

Grow the whole world and watch every pixel stay where it was

The VO front end makes each step. It tracks corners from frame k into frame k+1 (Lecture 6). It feeds the matches to the five-point algorithm and RANSAC (Lecture 7, Lecture 8), which return the rotation R and the direction of travel t. Once it has triangulated points, the front end can use PnP instead: the pose from known 3D points and their pixels.

The matches obey the epipolar constraint. Write a feature in frame k as the ray x, and the same feature in frame k+1 as x′. Both are (u, v, 1), with the focal length divided out.

Say it aloud

x-prime transpose, times t-cross, times R, times x, equals zero.

x′⊤
x-prime transpose the feature's ray in frame k+1, laid on its side so it can multiply from the left.
[t]×
t-cross the 3 × 3 matrix that takes a cross product with the translation t. [t]×R is the essential matrix E.
R
R the rotation from frame k to frame k+1.
x
x the same feature's ray in frame k.
In plain words

The two rays x and x-prime and the translation t lie in one plane. The product is zero exactly when they do. Multiply t by any number s: the product is s times zero, still zero. So the matches fix the direction of t, never its length.

With numbers

With made-up numbers: a point 4 m ahead, the camera slides 1 m right, R = I, t = (−1, 0, 0). Then x = (0.125, −0.05, 1) and x′ = (−0.125, −0.05, 1). [t]×x = (0, 1, 0.05), and x′ · (0, 1, 0.05) = −0.05 + 0.05 = 0. With t doubled, the product is still 0.

Grow the world, keep the picture

The map shows, from above, the camera at frame k and frame k+1 and three pink points. The strips show where each point lands in each image. Slide the world scale. Then switch on the IMU reading.

× 1.00

Illustrative: focal length 400 pixels. The move takes 1 s, half speeding up and half braking, so its peak acceleration is 4 times the distance per second squared.

So monocular VO picks a unit. It calls the first baseline 1, triangulates points in that unit, and measures later steps against those points. The path has the right shape and an unknown size. If VO reports 47 units for a flight that was 9.4 m long, its unit is 0.2 m: 5 units per metre. The hero's VO unit is 1.61 m, so it draws the loop at 62% of its size.

Symptom: a map and a path with a good shape whose size slowly changes along the flight (scale drift).

Measure: the ratio of a known length, such as a doorway, at the start and at the end.

Fix: a sensor that measures metres: a stereo baseline, wheel encoders, or an accelerometer (Chapter 5).

A monocular VO run reports a path 47 units long. The true path was 9.4 m. What is one VO unit?

Chapter 2

How Drift Grows

Fly a straight line many times with noisy turns and measure how far the ends scatter

Chapter 0 used the same turn error every frame. Real errors are random: one frame turns 0.1° too far, the next 0.05° too little. Do random errors cancel? Partly, for the heading. Not for the position.

Follow one straight flight. The heading error after k frames is the sum of k random turn errors, so it wanders like a random walk. Each step of length d then moves the drone sideways by about d times that heading error. The sideways error at the end is the sum of all those small slips.

Scatter 300 straight flights

Top: 300 flights, each 0.5 m per frame, with seeded random turn errors. Their end points form a purple cloud; the yellow bar is ± one predicted spread. Bottom: spread against distance, simulated (dots) and the formula (curve).

0.10°
400

Illustrative: turn noise only; step lengths are exact so the effect stands alone. 300 seeded runs per setting.

Call the step length d, the turn noise per frame σθ ("sigma-theta", in radians) and the number of frames N. The turn error at frame m pushes every later step sideways, so it counts N − m + 1 times. Adding the variances gives d2σθ2(12 + 22 + … + N2), and that sum is close to N3/3.

Say it aloud

Sigma-perp of N is about d times sigma-theta times the square root of N cubed over three.

σ⊥(N)
sigma-perp of N the spread of the sideways error after N frames, in metres (one standard deviation).
d
d the length of one step, in metres.
σθ
sigma-theta the random turn error of one frame, in radians.
√(N3/3)
the square root of N cubed over three how the slips add up: it grows as N to the power 1.5.
In plain words

Multiply the step d by the turn noise sigma-theta. Multiply by the square root of N cubed over three. Double the distance and the spread grows 2.8 times, so drift as a share of distance gets worse as you fly.

With numbers

d = 0.5 m, σθ = 0.1° = 0.001745 rad, N = 400 frames (200 m). √(4003/3) = 4,619, so σ⊥ = 0.5 × 0.001745 × 4,619 = 4.03 m: 2.0% of the distance. 2,000 simulated flights give 4.08 m.

At 100 m the same front end drifts 1.4% of the distance; at 400 m, 2.9%. A fixed "percent of distance" describes one trip length, not a front end. Benchmarks that quote a percentage average it over set segment lengths for this reason. Errors in step length alone grow more slowly, as √N: 2% length noise on 0.5 m steps gives 0.2 m along the track after 400 frames.

Symptom: a VO run that looks fine for one lap and is far off after five.

Measure: the spread of end points against distance on a log-log plot. A slope of 1.5 means heading noise rules; 0.5 means length noise.

Fix: a better heading. A gyroscope measures turn rate directly, so VIO takes its heading largely from the IMU.

With heading noise only, you fly twice as far. By about how much does the sideways spread grow?

Chapter 3

What the IMU Measures

Tilt the drone's belief by one degree and watch gravity leak into a phantom push

An IMU holds two sensors. The gyroscope measures the body's turn rate about each axis. The accelerometer measures specific force: every force on the body except gravity, divided by mass. At rest on a table it reads 9.81 m/s² upward, because the table pushes up. In free fall it reads zero.

Both sensors have a bias, a slowly changing offset, and white noise. Name the true turn rate ω ("omega"), the true acceleration in the world a, gravity g = (0, 0, −9.81) m/s², and the body's rotation RWB.

Say it aloud

Omega-tilde equals omega plus b-g plus n-g. A-tilde equals R-W-B transpose times a minus g, plus b-a plus n-a.

ω̃
omega-tilde what the gyroscope reports, in radians per second, in the body frame.
ω
omega the true turn rate of the body.
bg, ba
b-g, b-a the gyroscope and accelerometer biases: offsets that drift slowly with time and temperature.
ng, na
n-g, n-a white noise: a fresh random number in every sample.
ã
a-tilde what the accelerometer reports, in m/s², in the body frame.
RWB⊤
R-W-B transpose turns a world vector into body axes. RWB maps body numbers to world numbers.
a
a the true acceleration of the body in the world.
g
g gravity in the world: 9.81 m/s² straight down.
In plain words

The gyro reports the true turn rate omega plus its bias b-g and some noise. The accelerometer takes the true acceleration a, subtracts gravity g, turns the result into body axes with R-W-B transpose, then adds its own bias and noise.

With numbers

A level drone hovers: a = 0, RWB = I. Then ã = −g + ba = (0, 0, 9.81) + ba. With a 0.05 m/s² bias on x, it reads (0.05, 0, 9.81) while standing still.

To get acceleration back, the estimator turns ã into the world with its belief of RWB and adds g. If that belief is off by a small tilt, gravity no longer cancels. A sideways piece g sin(tilt) is left over.

Tilt the belief, keep the drone level

The drone hovers level. Blue: the force the accelerometer measures. Pink: gravity. The estimator believes the drone tilts by the slider's angle, so its blue arrow leans. The red arrow is what is left after adding gravity.

1.0°

Exact for a fixed tilt error: phantom acceleration g sin(tilt), position error half of that times t². The curve covers 10 s.

One degree of tilt error leaves 0.171 m/s² of phantom acceleration. In 10 s the drone believes it moved 8.56 m. Tilt matters that much. Gravity also helps: at rest, the accelerometer shows which way is down, so it gives roll and pitch.

Symptom: a still drone whose estimate slides away in one direction.

Measure: the estimate's acceleration while the drone hovers. A steady 0.17 m/s² means about 1° of tilt error.

Fix: estimate tilt and bias together with the path, as VIO does; calibrate the axes (Calibration and Time Sync).

A drone hovers level and still. What does its accelerometer read (no bias)?

Chapter 4

Dead Reckoning, and How Long It Lasts

Blind the camera for a few seconds and measure how far the IMU alone slides

Dead reckoning integrates the IMU on its own. Every sample, it subtracts the bias estimate and turns the heading by the gyro rate. It turns the specific force into the world and adds gravity. Then it adds the acceleration to the velocity, and the velocity to the position. The hero's warm path does exactly this at 100 Hz.

Integration is a sum, so a constant error adds up. A bias error in acceleration becomes a velocity error that grows with time, and then a position error that grows with time squared. A turn-rate bias tilts the belief a little more each second, and Chapter 3's gravity leak then grows with time cubed. IMU and Inertial Navigation races those curves in full.

VIO uses dead reckoning in a smaller job: to bridge the gap between camera frames, or through a blur or a dark doorway. Over a gap of t seconds, name the velocity error at the start δv ("delta-v") and the accelerometer bias the estimator has not removed ba.

Say it aloud

E of t is about delta-v times t, plus one half b-a t squared.

e(t)
e of t the position error after t seconds of IMU alone, in metres.
δv
delta-v the velocity error when the camera drops out, in m/s.
t
t the length of the gap, in seconds.
ba
b-a the accelerometer bias the estimator has not removed, in m/s².
In plain words

A wrong start velocity delta-v moves you off at a steady rate: delta-v times t. A leftover bias b-a adds a push that grows: half of b-a times t squared. Delta-v rules short gaps; b-a rules long ones.

With numbers

δv = 0.02 m/s, ba = 0.05 m/s², t = 3 s: 0.02 × 3 + 0.5 × 0.05 × 9 = 0.06 + 0.225 = 0.285 m. 500 simulated gaps with noise average 0.286 m. If VIO has estimated the bias down to 0.005 m/s², the same gap costs 0.083 m.

Bridge a camera gap

Thin warm lines show simulated IMU-only runs through the gap; the yellow curve is the formula. Slide the gap length, then compare a raw bias with one VIO has already estimated.

3.0 s

Illustrative: 1-D, δv = 0.02 m/s, accelerometer noise 0.02 m/s² per sample at 100 Hz, 40 seeded runs drawn. The noise adds about a millimetre over 1 s; bias rules.

A blurred half second costs 16 mm. A 3 s doorway costs 0.29 m with the raw bias. A 10 s corridor costs 2.7 m. So VIO estimates the bias all the time. The camera frames before a gap decide how long the IMU can carry the drone.

Symptom: after a dark stretch, the estimate jumps when the camera returns.

Measure: the size of the jump against the gap length. A jump that grows as t² points at the bias.

Fix: estimate the bias continuously; keep gaps short; use a better IMU for long gaps.

An accelerometer has an unremoved bias of 0.05 m/s² and no other error. How far off is dead reckoning after 10 s?

Chapter 5

The Metre Comes From Acceleration

Solve one linear least-squares problem for the scale, and watch it fail when the drone stops accelerating

The camera knows the shape of the path in VO units. The IMU knows displacement in metres, but only if you know the starting velocity. Put them together and both unknowns fall out. This is the visual-inertial alignment that VINS-Mono runs at start-up.

Call the VO position of keyframe i ci, in VO units, and the unknown scale s, in metres per VO unit. Call the velocity at keyframe i vi, also unknown. From the IMU samples between keyframes i and j, the drone computes Δpij: the displacement the measured accelerations alone produce, in the body frame of i. Chapter 6 shows how.

Say it aloud

S times c-j minus c-i equals v-i delta-t, plus R-i delta-p-i-j.

s
s the scale: metres per VO unit. Unknown.
cj − ci
c-j minus c-i the camera's step between the two keyframes, in VO units, in world axes.
vi
v-i the velocity at keyframe i, in m/s. Unknown.
Δt
delta-t the time between the keyframes: 0.1 s here.
Ri
R-i the rotation of keyframe i. The camera measures rotation without any scale problem, so we know it.
Δpij
delta-p-i-j the IMU's displacement from the measured accelerations alone, in metres, in the body frame of i.
In plain words

The camera step times the scale s must equal the IMU's account of the same step: coasting at v-i for delta-t, plus what the accelerations added. Write one such row per keyframe pair, plus a row v-j minus v-i equals R-i delta-v-i-j. Every row is linear in s and the velocities, so one least-squares solve gives them all (Lecture 9).

With numbers

With made-up numbers: vi = 1.0 m/s east, Δt = 0.1 s, and the accelerations add 0.005 m. The right side is 0.100 + 0.005 = 0.105 m. The camera says 0.0651 units. So s = 0.105 / 0.0651 = 1.613 m per unit.

Recover the scale from a window

Choose how the drone moves and how good its IMU is, then slide the window. Left: the camera path times your s, over the teal truth. Right: s with ±2 standard deviations, against the true 1.613.

4 s

Illustrative: the hero's simulator. The bias is not estimated in this step (VINS-Mono also leaves it out here), so it shows up as a scale error. Error bars come from the least-squares residuals.

On the figure-eight with the phone-grade IMU, a 4 s window gives s = 1.564 ± 0.023: 3.1% low, because the unmodelled bias leaks in. Flying straight and steady gives −0.01 ± 0.20, which means nothing. With no acceleration, the IMU's Δp is zero, and a larger s with a faster v fits every row equally well. Speeding up in a straight line works with the good IMU: 0.5% off. With the phone-grade one it is 28% off, because a constant push in one direction looks exactly like a bias.

Symptom: VIO that will not start, or starts with a wildly wrong scale, on a cart or a car moving steadily.

Measure: the error bar on s, or the smallest eigenvalue of A⊤A in the alignment.

Fix: move with changing acceleration, in more than one direction, before trusting the scale.

A drone flies straight at a constant 1.2 m/s for 8 s. Why can the alignment not find the scale?

Chapter 6

Preintegration: Many Samples, One Summary

Turn the keyframe and change the bias, and watch the summary stay put or move by a predicted amount

Between two keyframes 0.1 s apart, a 100 Hz IMU gives 10 samples. The back end keeps changing its guess of keyframe i's rotation and velocity. If each change meant integrating every sample again in the world frame, the IMU would dominate the cost of every iteration.

Preintegration (Lupton and Sukkarieh, 2012; on the rotation manifold by Forster and colleagues, 2017) integrates in the body frame of keyframe i instead. The result depends only on the samples and the bias guess, not on where keyframe i is. Name the samples between i and j ω̃k and ãk, their spacing δt, and the rotation from keyframe i to sample k ΔRik.

Say it aloud

Delta-R-i-j is the product over k of Exp of omega-tilde-k minus b-g, times delta-t. Delta-v-i-j is the sum over k of delta-R-i-k times a-tilde-k minus b-a, times delta-t. Delta-p-i-j is the sum over k of delta-v-i-k delta-t, plus one half delta-R-i-k times a-tilde-k minus b-a, times delta-t squared.

ΔRij
delta-R-i-j the rotation from keyframe i to keyframe j, from the gyro alone.
∏k
the product over k multiply one small rotation per sample, in time order.
Exp
Exp turns a small rotation vector into a rotation matrix (Lecture 2).
bg, ba
b-g, b-a the current bias guesses, subtracted from each sample.
δt
delta-t the time between IMU samples: 0.01 s here.
Δvij
delta-v-i-j the velocity change from the measured specific force, in the body frame of i.
Σk
the sum over k one term per IMU sample from i to j.
Δpij
delta-p-i-j the displacement the samples produce, in the body frame of i, not counting the start velocity or gravity.
In plain words

Start at keyframe i with zero rotation, velocity and position. For each sample, turn its specific force by the rotation so far, add it to delta-v, and add delta-v to delta-p. The start velocity, rotation and gravity go back in later, in the residual.

With numbers

One second of the hero's flight, from t = 12 s, 100 samples: Δθ = 0.054 rad (3.1°) and Δp = (−0.082, 0.049) m in the body frame of i. The truth is (−0.084, 0.050) m: noise and the 100 Hz steps account for the 1 mm gap.

Turn the keyframe, change the bias

Left: the path the samples produce, laid in the world from keyframe i. Right: the preintegrated summary in keyframe i's own axes. Turn keyframe i; then change the gyro bias guess and compare the first-order fix with a full re-integration.

40°
0.000 rad/s

Illustrative: the hero's samples from t = 12 to 13 s, true bias removed. A larger bias change curls the path more; the summary on the right is redrawn from the first-order fix.

Turning keyframe i turns the world path, but Δp does not change: zero samples to redo. A new bias guess does change it, since bg sits inside every term. Forster's fix is a first-order correction with Jacobians stored during preintegration. A 0.01 rad/s change moves Δp by 0.47 mm here; the correction misses by 0.001 mm. For ba it is exact, because Δp is linear in ba.

Symptom: a back end that slows down as the IMU rate goes up.

Measure: IMU samples integrated per iteration. It should be zero after the first.

Fix: preintegrate once per keyframe pair; update for bias changes with the stored Jacobians; re-integrate only after a large bias change.

The back end changes its guess of keyframe i's rotation. What must it do with the preintegrated Δpij?

Chapter 7

Loose or Tight, Filter or Smoother

Fly past a blank wall with only a few features and see which back end still uses them

There are two ways to join the camera and the IMU. Loosely coupled: run VO on its own, then fuse its pose output with the IMU, as the hero does. Tightly coupled: put every pixel residual and every preintegrated IMU summary into one estimator of poses, velocities, biases and landmarks.

The difference shows when features are scarce. The five-point algorithm needs five matches to make a pose. With three, a loose front end outputs nothing and the filter coasts on the IMU. A tight estimator still uses each of the three.

Fly past the blank wall

The shaded stretch, from 10 to 20 s, has few features. Choose how many the camera finds there and choose the coupling, then Run.

3

Illustrative toy: the filter knows the landmark positions, to keep it small; 0.5° bearing noise, an IMU bias of 0.036 m/s² the filter does not estimate. The loose front end follows the five-match rule; outside the stretch the camera sees 8.

With 3 features by the wall, the loose filter coasts for 10 s and drifts 3.07 m. The tight filter stays within 0.21 m. With 5 or more, both stay within 0.17 m. A tight VIO minimises this cost over a window of keyframes:

Say it aloud

X-hat equals the arg min over X of r-zero squared, plus the sum of the IMU residuals squared, plus the sum of the camera residuals squared.

X̂
X-hat the estimate of everything in the window: keyframe poses, velocities, biases and landmarks.
argminX
the arg min over X the X that makes the total smallest.
‖r0‖2
r-zero squared the prior: what the window keeps from states that left it.
Σ
the sum over keyframe pairs i, j for the IMU, and over keyframes i and landmarks l for the camera.
‖rIMU,ij‖2Σ
the IMU residual i-j squared how far the keyframe guesses disagree with the preintegrated summary, divided by its covariance.
‖rcam,il‖2Σ
the camera residual i-l squared the gap between where landmark l projects in keyframe i and the pixel seen, divided by the pixel noise.
In plain words

Add three kinds of disagreement: with the prior r-zero, with each IMU summary, with each pixel. Weight each by how much you trust it. Find the X that makes the total smallest, by Gauss-Newton on the manifold (Lecture 10).

With numbers

A window of 10 keyframes with 30 features in each: 10 × 30 × 2 = 600 rows of pixel residuals. 9 keyframe pairs with 9 rows each (rotation 3, velocity 3, position 3) give 81 IMU rows.

The back end comes in two kinds. A filter keeps the present state, linearizes once and moves on. The MSCKF (Mourikis and Roumeliotis, 2007) keeps a window of past camera poses in an EKF and no landmarks, so its cost grows linearly with the number of features. A fixed-lag smoother re-solves the cost above over a window of keyframes, relinearizing each time, and marginalizes old keyframes into r0. OKVIS (Leutenegger and colleagues, 2015) and VINS-Mono (Qin and colleagues, 2018) are smoothers.

Symptom: VIO that loses track along a white wall, though the camera still sees a few corners.

Measure: features tracked per frame against the front end's minimum.

Fix: couple tightly, so each feature counts; or lower the minimum with a better motion prior from the IMU.

The camera sees 3 features for 10 s. Which back end keeps using them?

Chapter 8

What VIO Can Never Know

Move the whole estimate four ways and see which moves the sensors notice

A quantity is observable if the measurements change when it changes. Test it on a finished estimate: move the path, velocities and landmarks together, and score the move against the same data. If no residual changes, no amount of data can find that quantity.

Move the whole world

Faint: the estimate. Bright: the same estimate moved as one piece. Pick a move and slide its size. Read the two costs. Then switch the flight to steady.

…

Illustrative: 6 s of the hero's flight, 8 landmarks, accelerometer noise 0.02 m/s² per sample. Costs are sums of squared residuals over noise. Tilt is a rotation about a level axis, worked in 3D.

Every move leaves the camera cost at zero: bearings do not change when the whole scene shifts, turns or grows together. The IMU breaks some ties. A 1° tilt makes gravity point the wrong way in every sample, a cost of about 44,000 over 6 s. A 10% stretch changes every acceleration by 10% (cost about 11,000), unless the flight has none.

Shifting and spinning about gravity change nothing, because gravity is the same vector after a turn about itself.

So VIO has four unobservable directions: the three of global position, and yaw, the rotation about gravity (Hesch and colleagues, 2014). Gravity makes roll and pitch observable; acceleration makes scale observable. Position and yaw drift without bound until a fix from outside: GPS, a known map, or a loop closure (Lecture 13).

Symptom: a filter that grows more confident about its yaw over time while its yaw error grows.

Measure: the yaw variance against the true yaw error. Variance that shrinks with no outside fix is a lie.

Fix: keep the unobservable directions unobservable in the linearized model, as the observability-constrained filters do; or use a smoother that relinearizes.

Which of these can a camera plus an IMU never observe, however the drone moves?

Chapter 9

Showcase: Break the Flight

Change the motion, the IMU and the camera, and watch which estimate survives

The hero's simulator with every knob. Choose the motion and the IMU, black out the camera from 12 to 17 s, and fly. The map shows the truth and the three estimates; the plot shows each error over the 48 s.

Fly it your way

Pick the motion and the IMU, toggle the dropout, then Fly. Toggle each estimate to compare.

Illustrative toy, seeded; same models as the hero. When the alignment finds no usable scale, the filter falls back to a guess of 1 unit per metre.

Things to try. With the dropout on, the camera-only path freezes for 5 s and ends 15.8 m off, while the fused estimate coasts through and stays within 0.32 m. Switch to straight and steady: the alignment finds no scale, the filter keeps its guess, and the fused path ends 20 m off. Straight and speeding up works with the good IMU (within 1.0 m) and fails with the phone-grade one: its bias poses as acceleration.

Chapter 10

Field Guide

Keep the formulas, the numbers and the code side by side

Visual odometry chains frame-to-frame motions: it gets the shape, never the metre, and drifts faster than the distance grows. The IMU measures turn rate and specific force at a high rate, but integrating it alone drifts as t² or worse. Fused, the IMU gives the metre whenever the drone accelerates, gravity gives roll and pitch, and the camera keeps the IMU's bias in check. Preintegration turns many IMU samples into one summary per keyframe pair. Position and yaw stay unobservable.

PieceFormulaNumber on this pageWatch out
Chain the stepsTW,k+1 = TW,k Tk,k+10.3° per frame: 0.95 m gap after 31.4 morder matters
Epipolar constraintx′⊤[t]×R x = 047 units for 9.4 m: 0.2 m per unitt only up to scale
Heading driftσ⊥ ≈ d σθ √(N3/3)4.03 m after 200 m at 0.1°grows as N1.5
IMU modelã = RWB⊤(a − g) + ba + na1° tilt error: 0.171 m/s²specific force, not acceleration
Gap errore ≈ δv t + ½ ba t23 s: 0.285 m raw, 0.083 m estimatedbias rules after 1 s
Alignments(cj − ci) = viΔt + RiΔpij4 s: 1.564 ± 0.023 (true 1.613)needs acceleration
PreintegrationΔRij, Δvij, Δpij in frame i1 s: Δp = (−0.082, 0.049) mbias Jacobians
Tight costprior + IMU + camera residuals3 features: 0.21 m tight, 3.07 m loosemarginalize old states
Observability4 directions: x, y, z, yaw1° tilt costs about 44,000; spin costs 0overconfident filters

The core, as code

python
import numpy as np

def rot(psi):                                        # planar R, maps body numbers to world numbers
    c, s = np.cos(psi), np.sin(psi); return np.array([[c, -s], [s, c]])

def preintegrate(gyro, acc, dt, bg=0.0, ba=np.zeros(2)):     # samples i..j -> summary in frame i
    th, dv, dp = 0.0, np.zeros(2), np.zeros(2)
    for w, f in zip(gyro, acc):
        a = rot(th) @ (f - ba)
        dp = dp + dv * dt + 0.5 * a * dt**2
        dv = dv + a * dt
        th = th + (w - bg) * dt
    return th, dv, dp

def align(c, heads, summaries, Dt):                     # c: K+1 VO positions (units), heads: K+1 headings
    K = len(summaries); n = 1 + 2 * (K + 1)                   # unknowns: s, then v_0 .. v_K
    A, b = [], []
    for q, (th, dv, dp) in enumerate(summaries):
        R = rot(heads[q])
        for r in range(2):                                   # s (c_j - c_i) - v_i Dt = R dp
            row = np.zeros(n); row[0] = c[q + 1][r] - c[q][r]; row[1 + 2 * q + r] = -Dt
            A.append(row); b.append((R @ dp)[r])
        for r in range(2):                                   # v_j - v_i = R dv
            row = np.zeros(n); row[1 + 2 * (q + 1) + r] = 1; row[1 + 2 * q + r] = -1
            A.append(row); b.append((R @ dv)[r])
    A, b = np.array(A), np.array(b)
    x, *_ = np.linalg.lstsq(A, b, rcond=None)
    return x[0], x[1:3], np.linalg.eigvalsh(A.T @ A)[0]   # scale, v_0, weakest direction

Run on the hero's first 4 s, this returns s = 1.5635, and the smallest eigenvalue of A⊤A shows how well the motion pins it. On the steady straight flight the same code returns a meaningless s near zero. The page runs the same steps in JavaScript and matches NumPy to the printed digits.

Where it sits

Lecture 7 and Lecture 8 give the frame-to-frame front end. Lecture 9 and Lecture 10 give the solver this lecture's back end runs. Lecture 12 recognises places already seen, and Lecture 13 uses those loop closures to remove the drift VIO cannot.

Keep going

The takeaway. One camera gives the shape; the IMU gives the metre, but only while the drone accelerates. Preintegrate the IMU between keyframes, put its summaries and the pixels into one estimator, estimate the bias as you go, and expect position and yaw to drift until something outside the drone fixes them.

Now press Present or Teach. Show why the epipolar constraint loses the scale, derive why heading noise drifts as N1.5, write the alignment rows, and say why a steady flight leaves the scale unknown. Then go back to the hero and explain why the camera's loop is too small and the IMU's loop slides away.

Credit

VNAV Lecture 11: Visual and Visual-Inertial Odometry
MIT 16.485 VNAV · Previous: optimization on manifolds · Next: place recognition · Back to Gleams