Week 6 — Ego Vehicle Physics and Collision Detection
Overview
This week adds the ego vehicle — the car the autonomy stack controls — with a physics model meaningful enough to test planning against, and a collision system to detect contact efficiently. It consolidates the ego-physics and collision weeks: the ego’s motion and the collision queries that constrain it belong together. The physics is the kinematic bicycle model, the standard low-speed vehicle model in AV work: simple, stable, and accurate enough for planning, without the complexity of full tire dynamics. Collision detection uses a broad-phase/narrow-phase split with a spatial structure so it scales to many agents.
Course 5’s Newtonian mechanics is the foundation for the vehicle model; here we apply it and confront the engineering realities (integration stability on the fixed timestep, the broad/narrow-phase tradeoff). By the end the ego vehicle drives under control inputs and the world reports collisions.
Readings
- Morin (review): kinematics, constraints, acceleration, and friction intuition. Extract: the no-slip rolling constraint behind the bicycle model.
- FCG: bounding volumes and spatial data structures. Extract: AABB/OBB and broad-phase acceleration.
- DPV: trees and hashing. Extract: spatial hashing / BVH for broad-phase.
- Game-physics reference (optional): rigid-body and collision basics. (Newtonian dynamics: assumed from Course 5.)
Key Concepts
The kinematic bicycle model
Collapse the four wheels into two (front/rear) on a wheelbase \(L\). State: position \((x,y)\), heading \(\theta\), speed \(v\). Inputs: acceleration \(a\) and steering angle \(\delta\). The dynamics:
\[ \dot x = v\cos\theta,\quad \dot y = v\sin\theta,\quad \dot\theta = \frac{v}{L}\tan\delta,\quad \dot v = a. \]
It captures the essential nonholonomic constraint (a car can’t move sideways) at low/moderate speed and is the standard model AV planners assume. Integrate it on the fixed sim timestep (Week 1); semi-implicit Euler is stable here.
Integration on the fixed timestep
Because the bicycle model is integrated every kSimDt, the result is deterministic and reproducible (Week 1’s payoff). Verify the integrator against an analytic solution (constant steering = circular arc) to catch sign/units errors before they propagate into planning.
Broad phase vs narrow phase
Naive pairwise collision is \(O(n^2)\). Broad phase uses a spatial structure (uniform grid / spatial hash, or a BVH) to cheaply find candidate pairs whose bounding volumes overlap; narrow phase does the exact test (OBB overlap, separating-axis theorem) only on candidates. This split is what makes collision scale to dozens of agents within the frame budget.
Bounding volumes
AABBs are cheap to test but loose for rotated vehicles; OBBs fit tightly but cost more. A common choice: AABB for broad phase, OBB (via SAT) for narrow phase. Vehicles are boxes, so OBB-OBB via the separating-axis theorem is the natural exact test.
Theory Exercises
- Derive the kinematic bicycle model from the no-slip rolling constraint; identify the nonholonomic constraint.
- Show that constant steering \(\delta\) yields a circular arc of radius \(R=L/\tan\delta\); use it to validate the integrator.
- Relate max steering and speed to the curvature/lateral-accel limits from the road model (Week 4).
- State the separating-axis theorem for two OBBs and the axes that must be tested in 2D.
- Analyze broad-phase complexity for a uniform grid vs \(O(n^2)\) as agent count grows.
Implementation
Add the ego vehicle with the bicycle model integrated on the sim tick, driven by acceleration/steering inputs (keyboard or a scripted controller for now). Add a physics/ collision system: AABB broad-phase via spatial hash, OBB narrow-phase via SAT. Report collisions between ego, agents, and static geometry. Validate the integrator against the circular-arc solution.
Benchmark
Vehicle physics timestep cost; collision broad-phase time and candidate-pair count vs agent count (grid vs \(O(n^2)\)); narrow-phase cost. Integrator accuracy vs the analytic arc.
Expected baselines: physics step is negligible per vehicle; spatial-hash broad phase keeps candidate pairs near-linear while \(O(n^2)\) blows up; the integrator matches the circular arc within discretization error. Collisions are detected correctly in scripted contact scenarios.
Connections
The ego model is what the Week 9 planner commands and what the Week 10 demo drives; collision detection provides safety checks and the scenario-failure signal. The bicycle model’s feasibility limits tie back to Week 4’s road curvature. Course 5’s mechanics is the theory applied. Week 10 will scale the collision/agent systems with data-oriented storage.
Further Reading
- Morin chapters on constrained motion (Course 5 review).
- Ericson, Real-Time Collision Detection — broad/narrow phase and SAT.
- Kong et al., “Kinematic and Dynamic Vehicle Models for Autonomous Driving” — the bicycle model in AV context.