Time of flight

Instead of triangulating, a time-of-flight sensor measures how long its own light takes to reach a surface and come back. Light covers 30 cm in a nanosecond, so the timing has to be extremely precise. Measure the delay of a short pulse directly, or the phase shift of a modulated signal, and see where that phase starts to repeat.

A light pulse

A short pulse goes out at t=0t = 0 and comes back, weaker, after the round trip Δt=2d/c\Delta t = 2d / c.

Emitted and received light over time, in ns emitted received measured arrival, on the timer's steps

A modulated signal

The light is modulated with a frequency ff, and the sensor compares the phase of what comes back with what it sends, from four samples per period.

Emitted and received intensity over two periods, in ns emitted received, shifted by φ\varphi samples r0…r3r_0 \dots r_3
Measured over true distance, in m measured d^\hat d d^=d\hat d = d shaded: one ambiguity range c/2fc / 2f

Depth from travel time

Structured light and stereo triangulate: they need two viewpoints a baseline apart, and their depth error grows with the square of the distance. Time of flight needs no baseline. The sensor sends light and times its return; the light travels to the surface and back, so

d=c Δt2,c≈3⋅108 m/sd = \frac{c\,\Delta t}{2}, \qquad c \approx 3 \cdot 10^8\ \text{m/s}

A distance of 1 m means a round trip of 6.67 ns, and 1 mm of depth means 6.7 ps. Timing a single pulse that precisely needs fast detectors and electronics. This is how lidar works: one pulse, or a few, per point, scanned over the scene.

Phase instead of time

A time-of-flight camera measures every pixel at once and avoids timing single pulses. It modulates its light with a frequency ff, tens of megahertz, and each pixel compares the phase of the light that comes back with the phase of the light that went out. The round trip delays it by Δt=2d/c\Delta t = 2d/c, a phase shift of

φ=2πf Δt=4πf dc⇒d=c φ4πf\varphi = 2\pi f\,\Delta t = \frac{4\pi f\,d}{c} \qquad\Rightarrow\qquad d = \frac{c\,\varphi}{4\pi f}

The pixel samples the received intensity r(t)=B+acos⁡(2πft−φ)r(t) = B + a \cos(2\pi f t - \varphi) four times per period, a quarter period apart. The background light BB and the strength of the reflection aa are unknown, but they cancel:

φ=atan2⁡(r1−r3, r0−r2),a=12(r0−r2)2+(r1−r3)2\varphi = \operatorname{atan2}(r_1 - r_3,\ r_0 - r_2), \qquad a = \tfrac{1}{2}\sqrt{(r_0 - r_2)^2 + (r_1 - r_3)^2}

A higher frequency turns the same depth error into a larger phase change, so noise on the samples matters less.

The ambiguity range

A phase is only known up to whole periods. A surface at dd and one at d+c/2fd + c/2f give the same phase, so the sensor measures the distance modulo the ambiguity range

R=c2fR = \frac{c}{2f}

which is 7.5 m at 20 MHz and 1.5 m at 100 MHz. A higher frequency is more precise, but its range is shorter. Cameras resolve this by measuring with two or more frequencies: only the true distance fits all of them.

Try this