Search

Search papers and lessons

Planning-oriented Autonomous Driving

Yihan Hu, Jiazhi Yang, Li Chen et al. · 2023

UniAD links tracking, mapping, motion forecasting, occupancy prediction and planning in one transformer, passing learned queries rather than boxes between them, and plans the ego car's path around predicted occupancy.

On this page

  • Colour = topic mix
  • Linear algebra
  • Discrete math
  • Probability
  • Calculus
  • Architectures
  • Computer vision
  • ReadReady to readNot yet

TL;DR

A self-driving system is usually built as a chain of separate models: one finds objects, one tracks them, one predicts where they will go, and one plans the car's path. UniAD puts these tasks into one network built from Transformer decoders. Each task hands the next one a set of learned query vectors rather than hard bounding boxes, and the planner is tuned to avoid the occupied space that the occupancy module predicts. On the nuScenes driving benchmark, using camera images only, the paper reports gains over earlier vision-based end-to-end methods on tracking, motion forecasting, near-range occupancy and planning.

Builds on: Transformer, Object Detection, Multi-Object Tracking, bird's-eye view representations, Deformable Attention · Leads to: no lesson in the graph builds on it yet.

Why it mattered

Driving stacks need to answer several questions at once: what is around the car, what will each thing do next, and what is safe to do now. In most production systems each question has its own model, trained for its own target. The paper's authors argue that this separation causes information loss between modules, error accumulation and feature misalignment.

The other extreme optimises planning directly, end to end. The paper counts that as one earlier attempt, and a partial design that keeps only some components as another. UniAD takes a middle path. It keeps every stage that a planner needs to see, and it makes the stages talk through shared queries, so that the whole system is trained with the planning goal in mind.

The paper was published at CVPR in 2023 and has been widely cited.

The problem

The authors look at two earlier designs. Multi-task learning shares one backbone across tasks, which is efficient, but the tasks can pull the shared features in conflicting directions, which the paper calls negative transfer. Standalone modules avoid that conflict but lose information at each hand-off, because a box or a single predicted trajectory discards most of what the module knew.

Their question is which intermediate tasks a planner needs in order to be safe, and how to connect them so that the information survives. Their answer is that motion forecasting and occupancy prediction both matter for safety, and that queries, which are learned vectors that stand for an agent or a map element, carry more information than a box and can model interactions between many agents.

How it works

The steps below follow the order in which the model runs, from camera images to a planned path. The example scene has one ego car and one other car ahead, so there is one agent query.

  1. Encode the scene. Images from several cameras go through a feature extractor. An off-the-shelf bird's-eye-view encoder, BEVFormer in the paper, turns the image features into one top-down feature map BB of size 200×200×256200 \times 200 \times 256. Check: 200×200×256200 \times 200 \times 256 is the stated shape, so every cell has a 256-number feature.
  2. Track the agents. TrackFormer uses detection queries for newly seen objects and track queries for objects seen earlier. Each query attends to BB, and the track queries also attend to one another, so they keep a memory of each agent across frames. The other car gets one track query, and the ego car gets a special ego query. Check: a query for the other car persists while it stays in view.
  3. Map the road. MapFormer uses map queries for lanes, dividers, crossings and the drivable area. It is based on a panoptic segmentation method, so it outputs a map and its elements. Check: the map is used only as queries and not as a fixed picture for the rest of the system.
  4. Forecast motion. MotionFormer takes each agent query and attends to the other agents, to the map queries and to a goal point on the predicted trajectory. It outputs several possible trajectories per agent, six modalities in the paper, each 12 steps long. Check: the other car gets six candidate paths, not one.
  5. Predict occupancy. OccFormer uses the bird's-eye-view features as queries and the agent features as keys and values. It predicts which cells will be occupied in the next five steps and keeps each agent's identity, so the planner knows which occupied cell belongs to which car.
  6. Plan. The planner takes the ego query from MotionFormer and adds a command embedding for the navigation signal (turn left, turn right or keep forward). This plan query attends to BB, and it outputs six future waypoints. Check: the plan is a set of six points for the ego car.
  7. Refine the plan. At inference only, the waypoints are adjusted by minimizing a cost that keeps them close to the first plan and away from occupied cells. The paper uses Newton's method for this step. Check: when no cell is occupied on the path, the cost is just the distance to the first plan, so the refinement leaves the plan unchanged.
flowchart LR
  C["Multi-camera images"] --> B["Bird's-eye-view features B"]
  B --> T["TrackFormer: detection and track queries"]
  B --> M["MapFormer: map queries"]
  T --> F["MotionFormer: agent trajectories"]
  M --> F
  T --> O["OccFormer: future occupancy"]
  B --> O
  F --> P["Planner: plan query to waypoints"]
  O --> R["Refinement against occupancy"]
  P --> R
  R --> W["Planned path"]

Worked examples

Example
1. One waypoint and one occupied cell (tiny)

Use a simplified version of the planner cost, for illustration only: the cost of a candidate point τ\tau is f=λcoord∥τ−τ^∥+λobs⋅(number of occupied cells within distance 1 of τ)f = \lambda_{\text{coord}} \lVert \tau - \hat\tau \rVert + \lambda_{\text{obs}} \cdot (\text{number of occupied cells within distance } 1 \text{ of } \tau). Take λcoord=1\lambda_{\text{coord}} = 1 and λobs=2\lambda_{\text{obs}} = 2. The first plan is τ^=(0,0)\hat\tau = (0, 0), and one cell at (0,0.5)(0, 0.5) is occupied.

  1. Candidate (0,0)(0, 0): the distance to the first plan is 0. The occupied cell at (0,0.5)(0, 0.5) is within distance 1, so the count is 1. Cost: 0+2×1=20 + 2 \times 1 = 2.
  2. Candidate (1.5,0)(1.5, 0): the distance to the first plan is 1.5. The occupied cell is at distance 1.52+0.52≈1.58\sqrt{1.5^2 + 0.5^2} \approx 1.58, which is more than 1, so the count is 0. Cost: 1.5+0=1.51.5 + 0 = 1.5.
  3. The lower cost is 1.51.5, from the candidate (1.5,0)(1.5, 0). So the refinement moves the waypoint sideways, away from the occupied cell.
  4. Interpretation: the planner accepts a small detour to avoid the occupied cell, because the collision term costs more than the extra distance.
Example
2. Measuring the effect of the occupancy module (standard case)

Table 2 of the paper compares the full model (row 12) with a multi-task baseline (row 0) on average planning L2 error in metres and average collision rate in percent over the planning horizon.

  1. Average L2 error, baseline: 1.1541.154. Full model: 1.0041.004.
  2. Reduction: (1.154−1.004)/1.154=0.150/1.154≈0.130(1.154 - 1.004) / 1.154 = 0.150 / 1.154 \approx 0.130, so about 13.0 percent lower.
  3. Average collision rate, baseline: 0.9410.941. Full model: 0.4300.430.
  4. Reduction: (0.941−0.430)/0.941=0.511/0.941≈0.543(0.941 - 0.430) / 0.941 = 0.511 / 0.941 \approx 0.543, so about 54.3 percent lower.
  5. Interpretation: the gain in collision rate is much larger than the gain in trajectory error. The modules that predict motion and occupancy mostly help the plan stay out of the way of other agents.
Example
3. Three-second errors against a prior system (realistic)

Table 7 reports the planning L2 error at three seconds, in metres, for the full model and for ST-P3, a prior vision-based planner: 1.65 for UniAD and 2.90 for ST-P3.

  1. Difference: 2.90−1.65=1.252.90 - 1.65 = 1.25 metres.
  2. Ratio: 2.90/1.65≈1.762.90 / 1.65 \approx 1.76, so ST-P3's three-second error is about 1.76 times UniAD's.
  3. Interpretation: the gap grows with the horizon. The paper reports a 51.2 percent reduction in average L2 error against ST-P3, which is the average over all horizons.
  4. Try it: what is UniAD's three-second error as a percentage lower than ST-P3's?

Answer: (2.90−1.65)/2.90=1.25/2.90≈0.431(2.90 - 1.65) / 2.90 = 1.25 / 2.90 \approx 0.431, so about 43.1 percent lower.

The math

Step 2 in symbols: tracking with queries

Let QAQ_A be the agent features and PAP_A their positions, one per valid agent in the scene, with NaN_a agents. Track queries carry an agent's state from one frame to the next. Newly seen objects enter through detection queries, and the paper matches predictions to ground truth with bipartite matching, as DETR does, so each object has one query. The paper reports 900 initial object queries, each of width D=256D = 256.

Step 4 in symbols: motion forecasting

Each motion query Qi,kQ_{i,k} is updated by three attention terms: attention to other agents, Qa=MHCA(MHSA(Q),QA)Q_a = \mathrm{MHCA}(\mathrm{MHSA}(Q), Q_A), attention to map elements, Qm=MHCA(MHSA(Q),QM)Q_m = \mathrm{MHCA}(\mathrm{MHSA}(Q), Q_M), and deformable attention to the goal point of the previous layer's trajectory, Qg=DeformAttn(Q,x^T l−1,B)Q_g = \mathrm{DeformAttn}(Q, \hat{\mathbf{x}}_T^{\,l-1}, B). Here MHSA and MHCA are multi-head self-attention and cross-attention, and deformable attention looks only at a few points around a reference point. The three results are concatenated and passed through an MLP to give the context QctxQ_{\text{ctx}}.

The output for agent ii and modality kk is a trajectory of T=12T = 12 points,

x^i,k∈RT×2,k=1,…,K,\hat{\mathbf{x}}_{i,k} \in \mathbb{R}^{T \times 2}, \qquad k = 1, \dots, \mathcal{K},

with K=6\mathcal{K} = 6 modalities in the paper. The query position combines the scene anchors, the agent anchors, the agent's current location and the predicted goal point, each through a sinusoidal position encoding and a small MLP.

Step 6 in symbols: the planner's cost

The planner first predicts six waypoints τ^\hat\tau. Refinement searches over candidate trajectories τ\tau for the one that minimizes

f(τ,τ^,O^)=λcoord∥τ−τ^∥2+λobs∑tD(τt,O^t),f(\tau, \hat\tau, \hat O) = \lambda_{\text{coord}} \lVert \tau - \hat\tau \rVert_2 + \lambda_{\text{obs}} \sum_t \mathcal{D}(\tau_t, \hat O^t),

where O^t\hat O^t is the occupancy map at future step tt. The collision term is a sum of Gaussian weights over the occupied cells S\mathcal{S} that lie within a distance dd of the waypoint,

D(τt,O^t)=∑(x,y)∈S1σ2πexp⁡ ⁣(−∥τt−(x,y)∥222σ2).\mathcal{D}(\tau_t, \hat O^t) = \sum_{(x,y) \in \mathcal{S}} \frac{1}{\sigma \sqrt{2\pi}} \exp\!\left(-\frac{\lVert \tau_t - (x,y) \rVert_2^2}{2\sigma^2}\right).

The first term keeps the plan close to the prediction, and the second pushes it away from occupied cells. The paper gives the form of the cost; λcoord\lambda_{\text{coord}}, λobs\lambda_{\text{obs}} and σ\sigma are hyperparameters. The worked example above uses a hard count of occupied cells instead of the Gaussian weights, to keep the arithmetic by hand.

Training in two stages

The perception modules, tracking and mapping, are first trained together for six epochs. The whole system is then trained end to end for twenty epochs, with all perception, prediction and planning losses. The authors report that this two-stage schedule was more stable than training everything at once.

Results

Joint ablation. The table below is a subset of the paper's Table 2 on the nuScenes validation set. Row 0 is a multi-task baseline with separate heads. Row 12 is the full system. Lower is better for minADE, minFDE, MR, the collision rate and the L2 error. Higher is better for IoU and VPQ.

RowModulesminADE (m)minFDE (m)MRIoU farAverage L2 (m)Average collision (%)
0Multi-task baseline0.8581.2700.18634.61.1540.941
10Planning onlynot reportednot reportednot reportednot reported1.1310.773
11Track, map, motion, plannot reportednot reportednot reportednot reported1.0140.717
12All five tasks0.7281.0540.15439.51.0040.430

The paper's conclusion is that the motion and occupancy modules are both needed for a safe plan. Row 10 plans directly from the features with no intermediate tasks, and row 12 adds all of them. The authors report that, against the multi-task baseline, row 12 lowers minADE by 15.2 percent and minFDE by 17.0 percent, and lowers the collision rate by 0.51 points.

Perception. On the nuScenes tracking benchmark (Table 3), UniAD reaches an AMOTA of 0.359, against 0.294 for MUTR3D and 0.217 for ViP3D. The paper notes that it is still behind Immortal Tracker, a tracking-by-detection method with 0.378, which uses a separate association step. On online mapping, its lane segmentation score is 31.3, against 23.9 for BEVFormer, but its scores on some other map classes trail perception-only methods.

Motion forecasting and occupancy. On motion forecasting (Table 5), UniAD reports minADE 0.71 m and minFDE 1.02 m, against 1.15 m and 1.95 m for PnPNet with vision input. In occupancy (Table 6), the near-range IoU is 63.4, against 59.4 for FIERY and 61.4 for BEVerse. BEVerse is better in the far range.

Planning. On the planning table (Table 7), UniAD's average L2 error is 1.03 m, against 2.11 m for ST-P3. Its average collision rate is 0.31 percent, against 0.71 percent for ST-P3. The table caption states that UniAD also outperforms several LiDAR-based methods in most cases.

Limits. The experiments use one benchmark, nuScenes, and the paper reports results on its validation split. The system is large and needs substantial compute, especially when trained with temporal history, and the authors list lighter deployment as future work. Some comparisons use LiDAR methods, which have a different sensor setup. The paper also points out that the tracking and mapping modules are tuned to help planning, so they are not always the best on their own tasks.

Reading guide

Read the paper in this order, with these prerequisites:

  • Section 1, Introduction, and Table 1: the design options and the task taxonomy. Needs Object Detection for the idea of boxes and Trajectory Prediction for forecasting.
  • Section 2 overview: the five modules and the queries that connect them. Needs Transformer and bird's-eye view representations.
  • Section 2.1, Perception: tracking and mapping: the track and detection queries and the panoptic map queries. Needs Multi-Object Tracking, DETR and Image Segmentation.
  • Section 2.2, Motion forecasting: attention types and the goal-point refinement. Needs Deformable Attention and Positional Encoding.
  • Section 2.3, Occupancy prediction: the pixel-to-agent attention. Needs the transformer background above.
  • Section 2.4, Planning: the command embeddings and the Newton refinement. Needs Newton-Raphson Method and Behavior Cloning for the planner's baselines.
  • Section 2.5, Learning: the two-stage schedule and bipartite matching. Needs Bipartite Matching.
  • Section 3, Experiments: Tables 2 to 7, which are the core results.
  • Appendices A to F: task definitions, implementation details, and the full notation table, which is useful for checking shapes.

Check yourself

QuestionWhich module produces the ego car's future waypoints, and what does it take as input?Show answer
The planner. It takes the plan query, which is the ego query from MotionFormer with a navigation command embedding added, and attends to the bird's-eye-view features before decoding six future waypoints.
QuestionIn Table 2, the average L2 error falls from 1.154 m to 1.004 m between the baseline and the full model. What is the percentage reduction?Show answer
(1.154−1.004)/1.154=0.150/1.154≈0.130(1.154 - 1.004) / 1.154 = 0.150 / 1.154 \approx 0.130, so about 13.0 percent.
QuestionWhy do the modules pass learned queries to one another rather than bounding boxes?Show answer
A query can carry a larger receptive field than a box, which softens the errors that build up from upstream predictions. Queries are also flexible enough to encode interactions, such as the relations between several agents, which a single box cannot describe.
QuestionA team builds a planner that uses only the outputs of a separate detector and planning, with no motion forecasting or occupancy. The collision rate is high. What does the paper suggest, and what does Table 2 show?Show answer
The paper argues that both motion forecasting and occupancy prediction are needed for a safe plan, not just perception. Table 2 shows that planning alone, with no intermediate tasks, has an average collision rate of 0.773 percent, and that the full system with all five tasks reduces it to 0.430 percent. The team should therefore add both prediction modules and use occupancy in the planner, rather than only improving the detector.

Sources

Read the full paper

Yihan Hu, Jiazhi Yang, Li Chen et al., 2023. arXiv:2212.10156