AnyLearn
All lessons
Roboticsintermediate

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.

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

Progress1 / 10

From a snapshot to a decision

Perception (the previous lesson) delivers a snapshot: tracked objects, lanes, the car's own pose. Turning that into motion takes three more stages, each working on a different timescale.

  1. Prediction: for every nearby road user, a set of possible futures over the next several seconds, each with a probability.
  2. Planning: one trajectory for the car itself, a path with a speed profile, chosen to be safe and comfortable across those futures.
  3. Control: steering, throttle and brake commands that make the real vehicle follow that trajectory.

The whole loop reruns many times per second. Each cycle the planner produces a plan for several seconds ahead, the car executes only the first fraction of it, and then everything is recomputed from fresh perception. This is receding-horizon planning, and it is why a plan never has to be perfect, only safe for the next slice and recoverable afterwards.

Key idea: prediction and planning are not separable in principle. Other drivers react to what the car does, so the car's plan changes the futures it is trying to predict.

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. From a snapshot to a decision

Perception (the previous lesson) delivers a snapshot: tracked objects, lanes, the car's own pose. Turning that into motion takes three more stages, each working on a different timescale.

  1. Prediction: for every nearby road user, a set of possible futures over the next several seconds, each with a probability.
  2. Planning: one trajectory for the car itself, a path with a speed profile, chosen to be safe and comfortable across those futures.
  3. Control: steering, throttle and brake commands that make the real vehicle follow that trajectory.

The whole loop reruns many times per second. Each cycle the planner produces a plan for several seconds ahead, the car executes only the first fraction of it, and then everything is recomputed from fresh perception. This is receding-horizon planning, and it is why a plan never has to be perfect, only safe for the next slice and recoverable afterwards.

Key idea: prediction and planning are not separable in principle. Other drivers react to what the car does, so the car's plan changes the futures it is trying to predict.

2. Stating the prediction problem

Given each agent's recent track and the map, a predictor outputs not one future but a small set of weighted ones:

Y^i={(τik, pik)}k=1K,∑k=1Kpik=1\hat{Y}_i = \{(\tau_i^{k},\, p_i^{k})\}_{k=1}^{K}, \qquad \sum_{k=1}^{K} p_i^{k} = 1

where each τik\tau_i^{k} is a trajectory for agent ii and pikp_i^{k} its probability. Several hypotheses are needed because the future is genuinely multimodal: a car at a junction will turn left, go straight or turn right, and averaging those gives a path no one drives.

The Waymo Open Motion Dataset makes the setup concrete. Waymo describes it as 103,354 segments of 20 seconds of tracks at 10 Hz with map data, cut into windows of 1 second of history and 8 seconds of future. Its prediction challenge accepts up to 6 trajectories per agent, each with a confidence, and ranks entries by soft mean average precision at 3, 5 and 8 seconds, with miss rate as a secondary metric.

Why multimodality is unavoidable, and how displacement metrics can mislead, is treated in depth in the Predicting Human Motion cursus; this lesson focuses on how vehicles use the predictions.

3. Representing the scene

A vehicle's future is shaped mostly by the road: lanes, junction topology, traffic-light states. How the map and agents are encoded is therefore the main design choice in a predictor.

RepresentationHow it worksExample
Rasterised imageDraw map and agent histories into a top-down picture; a CNN reads itMultiPath (Chai et al., CoRL 2019), which pairs it with fixed anchor trajectories
Vectorised polylinesLanes and tracks become sequences of points; a graph network relates themVectorNet (Gao et al., CVPR 2020)
Query-based transformerLearned queries, seeded at likely destinations, attend to map and agents and each decode one modeMTR, Motion Transformer (Shi et al., NeurIPS 2022)
Motion tokensTrajectories are discretised into tokens and generated autoregressively, like textMotionLM (Seff et al., ICCV 2023)

The trend across these is away from pictures and toward structured inputs, because a rasterised map spends most of its pixels on empty space and blurs precise lane geometry. Seeding modes at plausible destinations, as anchors or intention points do, also stops all K hypotheses collapsing onto the single most common manoeuvre.

4. Interaction: marginal, joint, conditional

Predicting each agent separately misses the fact that road users negotiate. Three framings are in use:

  • Marginal prediction: each agent's futures are predicted independently. Cheap, but two predicted cars may both "take" the same gap, a combination that cannot happen.
  • Joint prediction: futures are predicted for several agents together, so each scenario is internally consistent: if the cyclist goes first, the car waits. The Waymo Open Dataset runs a separate interaction challenge that scores joint predictions for pairs of agents.
  • Conditional prediction: futures are predicted given a candidate plan for the ego car: if we merge here, does the truck behind slow down? This lets the planner ask what-if questions instead of treating others as moving obstacles.

Gotcha: conditional prediction is powerful and dangerous. A model trained on human logs may learn that other drivers always yield to an assertive merge, because in the data they usually did. A planner that trusts it can bully its way into gaps that a real driver will not give. Stacks bound this with rules that keep a safe fallback even if the predicted yield never happens.

5. The planning hierarchy

Planning is usually layered. A route planner searches the road network for the sequence of roads to the destination (graph search, as in the lesson on Dijkstra and A*). A behaviour layer picks the manoeuvre, often as an explicit state machine like the one shown. A motion planner then turns the chosen manoeuvre into a precise trajectory, which the next step builds.

stateDiagram-v2
  [*] --> LaneFollow
  LaneFollow --> PrepareLaneChange: slower lead or route needs other lane
  PrepareLaneChange --> LaneChange: gap accepted
  PrepareLaneChange --> LaneFollow: no safe gap
  LaneChange --> LaneFollow: change complete
  LaneFollow --> YieldOrStop: crossing, signal or blocked lane
  YieldOrStop --> LaneFollow: path clear
  LaneFollow --> MinimalRiskStop: fault or condition outside design limits
  MinimalRiskStop --> [*]

6. Motion planning in the Frenet frame

Roads curve, which makes planning in plain x and y awkward. A widely used trick, from Werling, Ziegler, Kammel and Thrun (ICRA 2010), is to plan in the Frenet frame of the lane: ss is distance along the lane centre and dd is lateral offset from it. Keeping a lane becomes "hold dd at zero"; changing lanes becomes "move dd by one lane width".

The planner samples many candidates, each a smooth polynomial in time for dd and for ss, then scores them. A quintic lets you fix position, speed and acceleration at both ends:

d(t)=a0+a1t+a2t2+a3t3+a4t4+a5t5d(t) = a_0 + a_1 t + a_2 t^2 + a_3 t^3 + a_4 t^4 + a_5 t^5

A typical cost of this family trades comfort, speed and final offset:

J=wj∫0Td...(t)2 dt  +  wT T  +  wd d(T)2J = w_j \int_0^{T} \dddot{d}(t)^2 \, dt \;+\; w_T\, T \;+\; w_d\, d(T)^2

The integral of squared jerk penalises uncomfortable motion, TT penalises slow manoeuvres, and d(T)2d(T)^2 penalises ending away from the target lane centre. Candidates that collide with predicted agents or break speed and curvature limits are discarded before scoring, and the cheapest survivor wins.

7. A sampling planner in code

Here is the idea at toy scale: sample end offsets and speeds, build a minimum-jerk lateral profile, and charge each candidate for discomfort, lost speed and probability-weighted collision risk against every predicted future.

import numpy as np

def lateral_profile(d0, dT, T, t):
    # Minimum-jerk quintic from d0 to dT, zero lateral speed and acceleration at both ends
    tau = t / T
    return d0 + (dT - d0) * (10 * tau**3 - 15 * tau**4 + 6 * tau**5)

def plan(ego_s, ego_d, v_target, predictions, T=4.0, dt=0.5, lane=3.5):
    # predictions: list of (probability, (N, 2) array of future (s, d) at the same dt)
    t = np.arange(dt, T + dt, dt)
    best = None
    for dT in (-lane, 0.0, lane):                # right lane, keep lane, left lane
        for v in (v_target - 3.0, v_target):     # slow down, or hold target speed
            s = ego_s + v * t
            d = lateral_profile(ego_d, dT, T, t)
            risk = sum(p * (np.hypot(f[:len(t), 0] - s, f[:len(t), 1] - d).min() < 2.5)
                       for p, f in predictions)
            cost = 0.3 * abs(dT - ego_d) + 0.2 * (v_target - v) ** 2 + 100.0 * risk
            if best is None or cost < best[0]:
                best = (cost, dT, v)
    return best    # (cost, chosen end offset, chosen speed)

Real planners sample far more densely, check the vehicle's full footprint rather than a point, and add constraints on curvature and acceleration, but the shape is the same: generate, filter, score, pick.

8. Planning when the future is uncertain

The code above used an expected-risk rule: weight each predicted future by its probability. That is only one of several policies, and the choice matters most when a low-probability future is dangerous.

PolicyRuleBehaviour
Expected costMinimise the probability-weighted cost over futuresEfficient, but can accept a rare collision if it is unlikely enough
Worst caseMinimise the cost of the worst plausible futureSafe on paper, but treats everyone as adversarial and can freeze
ContingencyCommit to a shared first segment, keep a separate fallback branch per futureProceeds smoothly while staying able to react if the rare future starts to happen

Contingency planning exploits receding horizon: the car only has to execute the next fraction of a second, so it can move forward as long as every branch it might need still exists from where it will be. When a pedestrian on the kerb has a 10 percent chance of stepping out, a contingency planner slows just enough that braking remains possible, rather than stopping dead or ignoring them. How planners should consume probabilistic predictions safely is also discussed in the lesson Robustness and Deployment.

9. Rules versus learned planners

Learned planners trained by imitating human driving logs score well when judged on how closely they match the logged human trajectory. Driving, though, is closed loop: the planner's own choices change what happens next.

Predict first

On the nuPlan benchmark, run closed loop in simulation, how did state-of-the-art learned planners compare with the Intelligent Driver Model, a simple car-following rule published in 2000?

The lesson is not that learning is useless; their winning hybrid used learning. It is that open-loop imitation scores do not measure driving, and a well-engineered rule-based planner is the baseline any learned planner must beat in closed loop. The end-to-end lesson in this cursus returns to this evaluation gap.

10. Control: making the car follow the plan

The controller converts the planned trajectory into actuator commands, correcting for the gap between plan and reality at a higher rate than the planner runs. Most designs reason with the kinematic bicycle model, which treats each axle as a single wheel:

x˙=vcos⁡ψ,y˙=vsin⁡ψ,ψ˙=vLtan⁡δ\dot{x} = v\cos\psi, \qquad \dot{y} = v\sin\psi, \qquad \dot{\psi} = \frac{v}{L}\tan\delta

where ψ\psi is heading, LL the wheelbase and δ\delta the front-wheel steering angle.

ControllerIdeaTrade-off
Pure pursuit (Coulter, CMU, 1992)Steer along the arc that reaches a look-ahead point on the pathSimple and stable, but cuts corners; look-ahead must grow with speed
Stanley (Thrun et al., 2006, from Stanford's DARPA Grand Challenge winner)Steer to cancel heading error plus a term for sideways offsetTracks paths well at moderate speed, ignores tyre dynamics at the limit
Model predictive controlOptimise steering and acceleration over a short horizon with a vehicle model, apply the first step, repeatHandles limits and dynamics explicitly, needs a solver that finishes within the cycle

Longitudinal control (throttle and brake) is often a separate loop tracking the planned speed. Trajectory tracking in general is covered in the lesson Trajectory Generation and Tracking.

Check your understanding

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

  1. Why does a motion predictor output several weighted trajectories per agent instead of one best guess?
    • Because sensors report each object several times per frame
    • Because averaging distinct possible manoeuvres, such as turning left or going straight, yields a path no one would drive
    • Because the planner needs one trajectory per lane on the road
    • Because regulators require a fixed number of predictions per agent
  2. What does conditional prediction add over marginal prediction?
    • It predicts other agents' futures given a candidate plan for the ego vehicle
    • It predicts only the most likely future for each agent
    • It removes the need for a map
    • It predicts the ego vehicle's own trajectory from its past
  3. In the Frenet frame of a lane, what does a lane change correspond to?
    • Holding the along-lane distance s constant
    • Rotating the heading by 90 degrees
    • Moving the lateral offset d by about one lane width
    • Setting the jerk term in the cost to zero
  4. A pedestrian on the kerb has a small chance of stepping out. Which planning policy keeps moving while preserving the ability to brake if they do?
    • Worst-case planning
    • Pure pursuit
    • Marginal prediction
    • Contingency planning
  5. What did Dauner et al. (CoRL 2023) find on the nuPlan closed-loop benchmark?
    • Learned planners beat every rule-based baseline by a wide margin
    • Open-loop and closed-loop scores ranked planners identically
    • A rule-based car-following baseline outperformed the state-of-the-art learned planners they tested
    • Model predictive control was required for any planner to finish a route

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

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.

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