Real-Time Perception Pipeline for Autonomous Driving
Machine LearningModel answerLast updated
Design an ML pipeline that fuses camera, LiDAR, and radar data to detect obstacles with sub-100ms latency on edge hardware.
Problem: Building a Multi-Sensor Object Detection System
You're building the perception stack for an autonomous driving platform. The system ingests streams from cameras, LiDAR, and radar mounted on the vehicle and must output a unified view of the surrounding environment to downstream planning modules.
What the System Must Do
Core Functionality:
- Detect and classify dynamic objects: cars, pedestrians, bicycles
- Combine signals from different sensor types to improve accuracy
- Deliver results within a 50 millisecond cycle time
Operational Constraints:
- Safety-first detection: Missing a pedestrian is unacceptable; the system must achieve extremely high recall for vulnerable road users
- Embedded deployment: All processing happens on vehicle hardware with strict power and compute limits
- Continuous operation: The system runs in varied weather, lighting, and sensor health conditions
Design Challenges to Address
Your architecture should cover:
-
Cross-Sensor Integration: How do you align and synchronize data from sensors with different update rates, coordinate systems, and timing characteristics?
-
Fusion Architecture Trade-offs: Should you merge raw sensor data before processing, combine intermediate representations, or run separate detectors and merge their outputs? Justify your choice.
-
Latency Optimization: What techniques will you use to meet the 50ms requirement while maintaining detection quality on resource-constrained hardware?
-
Degraded Operation: How does your system behave when sensors malfunction, get blocked, or perform poorly due to environmental conditions like fog or direct sunlight?
Provide a concrete architecture with justifications for key decisions.
Hints
Hint 1
Start by quantifying the problem: sensor rates, data volumes, compute budget, and what 'near-zero false negatives' means numerically
Hint 2
Consider what information each sensor provides uniquely—cameras give texture and color, LiDAR gives precise 3D geometry, radar gives velocity through Doppler
Hint 3
The 50ms budget must cover the entire pipeline from sensor data arrival to output delivery; allocate time to each stage
Hint 4
Build redundancy into safety-critical systems: don't rely on a single inference path for detecting pedestrians
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
Solution: Multi-Sensor Perception Architecture
Evaluation Criteria
Strong answers demonstrate understanding of real-time safety-critical ML systems under resource constraints. The interviewer wants to see:
- Concrete numbers for throughput, latency budgets, and safety thresholds
- Informed choices between architectural alternatives with explicit trade-offs
- Specific optimization strategies beyond "use a faster model"
- Failure-mode planning, not just happy-path design
Allocate roughly 15% of time to scoping, 60% to the four technical deep-dives, and 25% to follow-up discussion.
1. Problem Scoping and Assumptions
Begin by establishing concrete parameters:
Sensor Configuration:
- LiDAR: roof-mounted unit producing 150k–250k points per scan at 10–20 Hz
- Cameras: 8 wide-angle cameras (2–8 MP each) running at 30 Hz covering 360°
- Radar: 5 units at ~20 Hz providing sparse range-velocity measurements
Performance Targets:
- Output frequency: 20 Hz (every 50ms)
- End-to-end latency: under 100ms (sensor capture to result availability)
- Detection range: 80m urban, 200m+ highway
- Safety metric: ≥99.9% recall for pedestrians and cyclists within 40 meters, measured at the track level (detected within 3 frames of appearing)
Compute Environment:
- Automotive-grade SoC: 200–500 TOPS (INT8), 60–100W thermal budget
- Shared with prediction, planning, and vehicle systems
- No cloud connectivity assumption for inference
Sample Time Budget (per 50ms cycle):
| Pipeline Stage | Allocation |
|---|---|
| Data ingestion, alignment, preprocessing | 10 ms |
| Parallel feature extraction (camera + LiDAR) | 18 ms |
| Feature fusion and detection | 10 ms |
| Tracking and post-processing | 7 ms |
| Buffer for thermal throttling, jitter | 5 ms |
2. System Architecture Overview
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ Cameras │ │ LiDAR │ │ Radar │
└──────┬──────┘ └──────┬──────┘ └──────┬──────┘
│ │ │
└────────────┬───┴────────────────┘
↓
┌─────────────────────┐
│ Synchronization & │ ← IMU/Odometry
│ Motion Correction │
└─────────┬───────────┘
↓
┌────────────┴────────────┐
│ │
┌────↓─────┐ ┌─────↓────┐
│ Camera │ │ LiDAR │
│ Encoder │ │ Encoder │
└────┬─────┘ └─────┬────┘
│ │
└────────┬───────────────┘
↓
┌──────────────────────┐
│ BEV Feature Fusion │
└──────────┬───────────┘
↓
┌──────────────────────┐
│ Detection Heads: │
│ • 3D bounding boxes │
│ • Velocities │
│ • Occupancy grid │
└──────────┬───────────┘
↓
┌──────────────────────┐
│ Multi-Object │
│ Tracking │
└──────────┬───────────┘
↓
[To Planner]
Parallel Safety Path:
LiDAR → Geometric Processing → Occupancy
Redundant Safety Layer: Run a lightweight geometric pipeline in parallel—simple LiDAR clustering and occupancy mapping—as a fallback detector that doesn't depend on learned models.
3. Data Synchronization and Calibration
Time Alignment
Challenge: Sensors have different frame rates and capture times. A LiDAR sweep takes 50–100ms during which the vehicle moves 1–2 meters at highway speed.
Solution:
- Hardware timestamping: Each sensor records capture time using GPS-disciplined PTP (IEEE 1588) for sub-millisecond synchronization
- Phase-lock cameras to LiDAR: Trigger camera exposures as the laser sweeps through each camera's field of view
- Motion compensation: Deskew LiDAR points using interpolated poses from IMU/wheel odometry, transforming each point to a common reference timestamp
- If a sensor frame arrives late (>10ms), use the previous frame with ego-motion compensation and flag the data as stale
Spatial Calibration
Factory calibration: Determine intrinsics (focal length, distortion) and extrinsics (6-DOF transforms between each sensor and vehicle frame) using calibration targets.
Online monitoring:
- Project LiDAR points onto camera images and measure edge alignment
- If reprojection error exceeds 2 pixels consistently, trigger a calibration warning
- Radar-LiDAR cross-checks: validate range measurements for static objects
4. Fusion Strategy Analysis
| Approach | Strengths | Weaknesses |
|---|---|---|
| Early Fusion (raw data combined first) | Preserves maximum information; model learns optimal feature combinations | Huge computational cost; very sensitive to calibration errors; brittle to missing sensors |
| Mid-Level Fusion (combine learned features in BEV space) | Retains cross-modal complementarity; encoders stay modular and upgradeable | Moderate compute; requires careful feature alignment |
| Late Fusion (independent detectors, merge boxes) | Cheapest per-modality; naturally handles sensor dropout | Loses weak evidence—isolated faint signals get filtered before fusion |
Recommended: Mid-level BEV fusion with geometric redundancy
Rationale:
- Safety requirement demands we detect faint signals—a barely-visible pedestrian in shadow plus a weak LiDAR return should combine into a confident detection. Late fusion discards exactly this complementary evidence.
- BEV (bird's-eye view) feature space provides a natural common representation: both camera features (lifted to 3D) and LiDAR features project cleanly into a top-down grid
- Modularity: Individual encoders can be optimized, pruned, or replaced without retraining the entire system
- The parallel geometric path provides the fault tolerance that late fusion normally offers
Implementation:
- Camera encoder outputs BEV features via learned depth estimation or transformer-based view transformation
- LiDAR encoder uses pillar-based or sparse voxel representation
- Concatenate or attend across features in BEV space (~0.2m resolution, 80m range = 400×400 grid)
- Radar contributes velocity cues directly to tracking rather than as spatial features
5. Meeting Real-Time Requirements
Model Optimization
Quantization:
- INT8 post-training quantization for backbone and most layers
- Keep critical paths in FP16: final box regression heads, small-object feature maps
- Validate per-class recall after quantization, especially for distant pedestrians (the first to degrade)
Structured Pruning:
- Remove entire channels/filters, not individual weights (unstructured sparsity rarely accelerates on automotive accelerators)
- Target 30–40% FLOPs reduction while keeping recall above threshold
Knowledge Distillation:
- Train a large offline teacher with multi-frame temporal context and high-resolution inputs
- Distill into a single-frame, lower-resolution student for onboard deployment
- Teacher also generates pseudo-labels for abundant unlabeled driving data
System-Level Efficiency
Parallel Execution:
- Run camera and LiDAR encoders simultaneously on separate compute units (e.g., GPU for cameras, dedicated accelerator for LiDAR point clouds)
- Overlap I/O and compute: start processing frame N while frame N+1 is being ingested
Operator Efficiency:
- Use fixed input shapes for TensorRT or similar compiler optimization
- Fused kernels for BEV pooling operations
- Sparse convolution for LiDAR (don't waste FLOPs on empty voxels)
Adaptive Computation:
- Dynamic resolution: reduce image size in low-complexity scenes (empty highway)
- Object-centric processing: allocate more compute to regions with detections
6. Handling Degraded Modes
Sensor Health Monitoring
Run continuous diagnostics:
- Camera: Check brightness histogram (whiteout/blackout), sharpness metrics, lens blockage via expected/actual feature counts
- LiDAR: Monitor return count (blockage), range distribution (fog detection), rotation rate
- Radar: Validate noise floor, check for interference patterns
Output includes per-sensor confidence scores so the planner can adjust behavior.
Graceful Degradation
Occlusion/Blockage:
- Reduce fusion weight for affected sensor in the BEV attention mechanism
- The geometric safety path remains active if LiDAR is healthy
- If cameras fail but LiDAR works: continue with geometry-only perception, reduce speed
Environmental Conditions:
- Heavy rain/fog: LiDAR range drops, cameras blur
- Increase following distance (via planner)
- Rely more on radar for leading vehicle detection
- Low sun angle: cameras saturate
- Upweight LiDAR in fusion, mask saturated image regions
Redundancy:
- The parallel occupancy grid from geometric processing catches objects the learned model misses
- Multi-sensor fusion means one failed sensor doesn't create a blind spot
- Track-level temporal filtering: brief single-frame misses are tolerated if the object was tracked before and is re-detected quickly
Failure Output
When confidence falls below safe thresholds, the perception module should:
- Signal planner to reduce speed or request driver takeover
- Never silently drop to zero detections—output low-confidence detections with uncertainty bounds rather than nothing
Common Mistakes
- Ignoring time synchronization: Proposing fusion without addressing that sensors capture at different moments and the vehicle is moving
- Vague safety claims: Saying "high recall" without numbers or explaining how to validate it
- Over-reliance on a single model: No redundant detection path for safety-critical objects
- Unrealistic compute assumptions: Suggesting models that require 10× the available TOPS
- Late fusion for safety-critical systems: Missing that late fusion discards exactly the weak cross-modal evidence needed for high recall
Follow-Up Directions
- Data pipeline: How do you label training data at scale? (Semi-supervised learning, offboard auto-labeling with human verification)
- Metrics: How do you evaluate in simulation vs. real-world? (Simulation for coverage of rare events, real-world for distribution accuracy)
- Continuous improvement: How does the model update over time? (Shadow mode testing, A/B tests with safety driver, phased rollout)
- Multi-frame temporal models: Should detection use history? (Yes for tracking and velocity, carefully for initial detection to avoid latency)