AnyLearn
All lessons
Roboticsintermediate

How a Self-Driving Car Perceives the Road

The first stage of a driving stack: which sensors a self-driving car carries and why, how cameras, lidar and radar are calibrated, synchronised and fused into a bird's-eye view, and how detections become tracked objects on a map that prediction and planning can use.

Updated · AI-authored, review-gated · how lessons are made

Progress1 / 10

What perception has to deliver

A self-driving car does not need to see the way a person does. It needs to hand the rest of its software a compact, numerical description of the world, many times per second. In a classic modular stack that description has five parts:

  • Objects: every car, cyclist and pedestrian as a 3D box with position, heading, size, velocity and class.
  • Tracks: identities that persist across frames, so the cyclist now is known to be the cyclist from a second ago.
  • Free space and occupancy: where the ground is drivable, including clutter that fits no class.
  • Road structure: lanes, crossings, signs and traffic-light states.
  • Ego pose: where the car itself is, precisely enough to know its lane and its place in it.

Prediction reads the tracks; planning reads all of it. This cursus follows that pipeline: perception here, then prediction, planning and control, then the end-to-end designs that dissolve these interfaces, then how safety is argued.

Key idea: perception is judged by what planning needs, not by benchmark scores. Missing one pedestrian about to cross matters more than misplacing a dozen parked cars.

Sign in free to save your progress and earn certificates.

Full lesson text

All 10 steps on one page, for reading, reference, and search.

Show

1. What perception has to deliver

A self-driving car does not need to see the way a person does. It needs to hand the rest of its software a compact, numerical description of the world, many times per second. In a classic modular stack that description has five parts:

  • Objects: every car, cyclist and pedestrian as a 3D box with position, heading, size, velocity and class.
  • Tracks: identities that persist across frames, so the cyclist now is known to be the cyclist from a second ago.
  • Free space and occupancy: where the ground is drivable, including clutter that fits no class.
  • Road structure: lanes, crossings, signs and traffic-light states.
  • Ego pose: where the car itself is, precisely enough to know its lane and its place in it.

Prediction reads the tracks; planning reads all of it. This cursus follows that pipeline: perception here, then prediction, planning and control, then the end-to-end designs that dissolve these interfaces, then how safety is argued.

Key idea: perception is judged by what planning needs, not by benchmark scores. Missing one pedestrian about to cross matters more than misplacing a dozen parked cars.

2. The sensor suite

No single sensor covers every condition, so production vehicles carry several kinds.

SensorMeasuresStrong atWeak at
CameraColour and texture in 2DSigns, lights, lane paint, classifying objectsNo direct depth; glare, darkness, dirty lenses
Lidar3D points by laser time of flightPrecise range and shape, day or nightCost; fog, heavy rain and snow; no colour
RadarRange, angle and radial speedSpeed, long range, poor weatherCoarse angular detail; clutter from metal
UltrasonicDistance at very short rangeParking, kerbsOnly a few metres of reach
GNSS and IMUGlobal position, acceleration, rotationMotion between position fixesSatellite signals drop in tunnels and dense cities
MicrophonesDirection of soundsSirens, hornsA narrow, supporting role

Two published rigs show the typical mix. The nuScenes research dataset (Caesar et al., CVPR 2020) was recorded with 6 cameras, 5 radars and 1 lidar. Waymo's description of its sixth-generation system lists 13 cameras, 4 lidars, 6 radars and an array of external microphones. Camera-only designs also exist: they replace measured depth with learned depth estimation, trading sensor cost for a harder perception problem. The lidar mechanics themselves are covered in the lesson LiDAR and Point Clouds.

3. Why overlap the sensors

The suite is chosen so that the sensors fail differently. A survey of perception in adverse weather (Zhang et al., ISPRS Journal of Photogrammetry and Remote Sensing, 2023) describes the camera as one of the most vulnerable sensors in bad weather and notes that radar holds up in fog far better than lidar or cameras, while lidar pulses scatter off droplets and snowflakes and return phantom points. Lidars at 1550 nm can emit more power than 905 nm units within eye-safety limits, which buys range, but neither wavelength sees through dense fog the way radar does.

Overlap also covers geometry: blind spots close to the bumper, objects hidden behind a truck from one mounting point but visible from another.

Predict first

A car 60 m ahead is slowing, but its brake lights are not visible. Which sensor can tell from a single measurement that it is decelerating relative to you?

4. Calibration: putting every sensor in one frame

Each sensor reports in its own coordinate frame. Before anything can be fused, the stack needs two kinds of calibration:

  • Intrinsics: a camera's focal length, optical centre and lens distortion, which map a 3D direction to a pixel.
  • Extrinsics: the rotation and translation of every sensor relative to a common vehicle frame.

With both, a lidar point can be projected into an image, which is how lidar depth is attached to camera pixels:

import numpy as np

def project_lidar_to_image(pts_lidar, T_cam_from_lidar, K):
    # pts_lidar: (N, 3) points in the lidar frame. Returns (M, 2) pixel coordinates.
    pts_h = np.hstack([pts_lidar, np.ones((len(pts_lidar), 1))])  # homogeneous (N, 4)
    pts_cam = (T_cam_from_lidar @ pts_h.T).T[:, :3]                # rotate and translate
    pts_cam = pts_cam[pts_cam[:, 2] > 0.1]                         # keep points in front
    uvw = (K @ pts_cam.T).T                                        # pinhole projection
    return uvw[:, :2] / uvw[:, 2:3]                                # divide by depth

Gotcha: small angular errors grow with range. A rotation error of half a degree moves a point 50 m away by about 0.44 m, since 50 times tan(0.5 degrees) is 0.436. Mounts flex with heat and vibration, so fleets monitor calibration continuously rather than trusting the factory values.

5. Time: the calibration people forget

Sensors also disagree about when. Cameras, lidar and radar run on different clocks and rates; in the nuScenes rig the cameras capture at 12 Hz and the lidar spins at 20 Hz (Caesar et al., 2020). If two measurements of the same object are fused with a timing mismatch, the error is simply speed times offset:

e=v Δte = v \, \Delta t

At 30 m/s, roughly motorway speed, a 50 ms mismatch places an object 1.5 m from where it really is, which is enough to put a car in the wrong lane.

Two further effects follow from the same arithmetic:

  • Lidar sweep skew. A spinning lidar takes a full rotation period to scan the scene, so points at the start and end of one sweep were captured at different moments. Stacks deskew each sweep using the vehicle's own measured motion.
  • Rolling shutter. Many cameras read rows sequentially, so fast lateral motion bends straight edges.

The fix is shared hardware time stamping, often from a common clock disciplined by satellite timing, plus explicit motion compensation in software.

6. Three places to fuse

Once sensors share a frame and a clock, the design question is where to combine them.

Fusion levelWhat is combinedUpsideDownside
EarlyRaw points and pixels, for example colouring lidar points with image valuesNothing is discarded before fusionVery sensitive to calibration; heavy to compute
Mid (feature)Learned features from each sensor, mapped into one shared gridKeeps camera semantics and lidar geometry togetherNeeds a learned transform from image view to the grid
Late (object)Each sensor's own list of detected objectsModular; a failed sensor drops out cleanlyEach detector has already thrown information away

Late fusion was the classic approach because each sensor team could ship its own detector. Its weakness is that a camera detector that misses a dark-clothed pedestrian at night passes nothing on, even if the lidar saw a vague shape that the camera could have helped classify. Mid fusion in a shared bird's-eye-view grid has become the common research default because it lets the network weigh evidence from every sensor before committing to an object.

7. Fusing in a bird's-eye view

The bird's-eye-view (BEV) grid is a top-down map around the car. Lidar points fall into it naturally. Camera features must be lifted: Lift-Splat-Shoot (Philion and Fidler, ECCV 2020) predicts a depth distribution for each pixel and spreads its features along the ray. BEVFusion (Liu et al., MIT and NVIDIA, ICRA 2023) fuses both in this shared grid and reports making the camera-to-BEV pooling step more than 40 times faster; one grid then feeds detection, map segmentation and occupancy heads.

flowchart LR
  C["Camera images"] --> E1["Image encoder"]
  E1 --> V["Lift pixels to 3D using predicted depth"]
  V --> B1["Camera BEV features"]
  L["Lidar sweep"] --> E2["Voxel encoder"]
  E2 --> B2["Lidar BEV features"]
  B1 --> F["Fused BEV grid"]
  B2 --> F
  F --> H1["3D box detection"]
  F --> H2["Lane and map segmentation"]
  F --> H3["Occupancy grid"]

8. From detections to tracks

A detector works frame by frame. Prediction needs tracks: the same object, with a stable identity and a smoothed velocity, over seconds. Each cycle a tracker does four things:

  1. Predict every existing track forward to the current time, usually with a Kalman filter (covered in the lesson The Kalman Filter).
  2. Associate predicted tracks with new detections.
  3. Update matched tracks with their detections.
  4. Manage the rest: unmatched detections start tentative tracks, and tracks unmatched for several cycles are deleted.

Association is an assignment problem, solved for the whole frame at once rather than greedily:

import numpy as np
from scipy.optimize import linear_sum_assignment

def associate(track_xy, det_xy, gate_m=2.0):
    # track_xy: (T, 2) predicted positions; det_xy: (D, 2) detections, metres.
    cost = np.linalg.norm(track_xy[:, None, :] - det_xy[None, :, :], axis=2)
    rows, cols = linear_sum_assignment(cost)          # globally cheapest pairing
    matches = [(r, c) for r, c in zip(rows, cols) if cost[r, c] < gate_m]
    used_t = {r for r, _ in matches}
    used_d = {c for _, c in matches}
    lost = [t for t in range(len(track_xy)) if t not in used_t]
    born = [d for d in range(len(det_xy)) if d not in used_d]
    return matches, lost, born

The gate stops a track from jumping to a far-away detection when its true object is occluded.

9. Localization and the map

Perception describes the surroundings; localization places the car within them. Satellite positioning alone is not precise enough, because signals reflect off buildings and vanish in tunnels. The common recipe fuses three sources:

  • A prior map, built in advance, holding lane geometry, stop lines, crossings and traffic-light positions.
  • Live scan matching, aligning current lidar or camera features to that map, which pins the pose to a specific lane.
  • Odometry, from wheel speeds and the inertial unit, bridging gaps between good matches.

The prior map is powerful because it turns hard perception problems into lookups: the car knows where a traffic light should be before it sees it. The cost is upkeep, since every changed lane marking must be re-mapped. An alternative line of work predicts the lane graph online from sensors, for example MapTR (Liao et al., ICLR 2023), trading map maintenance for a harder real-time perception task. The underlying estimation problem is the one covered in the lesson on SLAM.

In practice: maps go stale. A road-works zone can contradict the map on the day it appears, so stacks treat the map as a strong prior that live perception is allowed to override, and flag disagreements for re-mapping.

10. The long tail

Benchmarks measure average accuracy on common classes. Deployment is decided by rare cases, and a fleet driving millions of miles meets them constantly:

  • Objects outside the label set: a mattress in the lane, a fallen ladder, a horse and rider.
  • Misleading appearances: a person in a costume, a billboard showing a car, a reflection in a glass building.
  • Occlusion: a child behind a parked van, visible only as feet under the bumper.
  • Unusual agents: a police officer directing traffic against the signal, a wheelchair user in the road.
  • Sensor artefacts: steam from a manhole that looks solid to lidar, exhaust plumes on a cold morning.

Two design responses recur. Class-agnostic occupancy predicts which space is filled, whatever fills it, so an unknown obstacle still blocks the plan. Calibrated uncertainty lets perception say "something is here, identity unclear", which planning can treat cautiously instead of receiving a confident wrong label.

The next lesson takes these tracks and asks the harder question: where will each of them be in eight seconds?

Check your understanding

The lesson ends with a 5-question quiz. Take it in the player above to see your score.

  1. Why do self-driving cars usually carry cameras, lidar and radar rather than many copies of the best single sensor?
    • Regulations require at least three sensor types on every vehicle
    • Different sensor types fail under different conditions, so their weaknesses rarely coincide
    • Each sensor type is only legal to use at certain speeds
    • Three types are needed so that two can outvote a faulty one
  2. A camera and a lidar have a 50 ms timestamp mismatch. How far off is a fused position for a car moving at 30 m/s?
    • 0.15 m
    • 0.6 m
    • 1.5 m
    • 15 m
  3. What is the main drawback of late (object-level) fusion?
    • It cannot run in real time on vehicle hardware
    • It requires every sensor to share one physical mounting point
    • It only works with lidar, not with cameras
    • Each sensor's detector has already discarded information before the results are combined
  4. In a multi-object tracker, what does the gate in the association step prevent?
    • A track being matched to a distant detection when its real object is temporarily hidden
    • Two detections being produced for one object
    • The Kalman filter from predicting tracks forward in time
    • New objects from ever starting a track
  5. Why do stacks that rely on a prior high-definition map still let live perception override it?
    • Because maps are stored at lower resolution than camera images
    • Because satellite positioning makes maps unnecessary in cities
    • Because the road can change after mapping, for example at a new road-works zone
    • Because lidar cannot be matched against a stored map

Related lessons

Robotics
intermediate

How Self-Driving Safety Is Argued and Measured

What it takes to show a self-driving system is safe enough: SAE automation levels and operational design domains, why test miles alone cannot prove safety, how crash rates are compared with human benchmarks, why disengagement counts mislead, and how safety cases, crash reporting and remote assistance fit together.

10 steps·~15 min
Robotics
intermediate

Modular Stacks vs End-to-End Driving

Two ways to build a self-driving system: a pipeline of separately engineered modules, or one network trained from sensors to trajectory. Covers imitation learning, causal confusion, why open-loop scores mislead, joint designs like UniAD, foundation-model drivers, and what each approach costs when you must prove it safe.

11 steps·~17 min
Robotics
intermediate

Predicting Road Users, Planning, and Control

How a self-driving car turns tracked objects into motion: forecasting several possible futures for every road user, choosing a trajectory that is safe across them, and steering it with a controller. Covers scene representations, interaction, Frenet-frame planning, and why rule-based planners remain strong baselines.

10 steps·~15 min
AI
intermediate

Learned Simulators for Robots and Cars, and How World Models Fail

How world models train and test robots and driving systems, and where they break. Covers learning to walk in an hour with DayDreamer, driving world models, ranking robot policies in a video simulator, compounding error in code, model exploitation and its defences, hallucinated physics, and why evaluation is the hardest part.

10 steps·~15 min