Autonomous Driving at CUEPIAC 2023
The competition
In the autonomous-driving simulation track of the China Undergraduate Engineering Practice and Innovation Ability Competition (CUEPIAC), the simulator does the seeing. 51Sim-One hands every entry ground-truth perception and an HD map, with each obstacle already labeled by an id, a type and a speed, and asks for throttle, brake and steering at every step. What is left is behavior: given a clean, complete picture of the road, what should the car do?
Each entry drives a fixed set of scenarios and is scored on every one of them: following a car, a blocker standing in the lane, junctions with and without lights, pedestrians on crosswalks, cars cutting in, lane changes, and one long continuous track.
Avoiding a collision is only the start of the score. A good run moves off promptly at a green light, stops at the stop line, and changes lanes only into a gap that is really there. Those demands pull against each other. The thresholds that make a car decisive at a junction make it pushy behind a slow truck, and the work lies in settling that conflict explicitly, one rule at a time.
A stack of plain functions
I wrote the driving stack by hand in C++, in four layers. Perception filters the simulator's obstacle list, assigns each obstacle to a lane, and picks out what matters: the obstacle directly ahead, speed-limit signs, anything blocking a junction, anyone on a crosswalk. Decision answers yes-or-no questions. Is the target lane occupied, is the light green, has the car passed the stop line, is this turn legal? Planning builds the reference path from the route and generates the paths for lane changes, and control turns that path and a target speed into throttle and steering.
Every layer is a set of free functions over simulator data and map queries, and the call graph stays flat. The payoff comes when the car does something unexpected: each decision it makes can be traced to the one named function that made it.
Decision and planning both reason in lane coordinates rather than map coordinates. A position becomes a distance along a lane and an offset across it, and the detection zones the stack draws around the car are rectangles in those terms. Whether a car is beside you in the next lane, on a curve, is an awkward question in map coordinates; in lane coordinates it is an interval test, because the map already carries the geometry. The same projection lets the stack look for obstacles along the path the car is about to take, so a car in the lane it is about to enter counts before it gets there.
Choosing a behavior
One variable decides what the car is doing, and it takes eight values: a start, following, the beginning and the middle of a lane change, avoiding an obstacle, approaching a junction, and two kinds of emergency braking. Every transition between them is an explicit condition on map and obstacle geometry. Junction handling runs as a guard ahead of all the states, so a junction takes over whatever the car was doing.
Most of the time the car is following, and it keeps a gap that grows with its own speed.
Leaving that state is where the judgment sits. A slow car ahead is a reason to change lane; a stopped one is a reason to steer around it. When neither move is legal, the car brakes, and the stack draws a distinction here that matters. Braking for a car ends as soon as that car moves again, while braking for anything else ends only once the distance has recovered, so the two get separate states.
Steering with a look ahead
The car follows its path with a pure-pursuit controller whose lookahead grows with speed: it aims at a point on the path ahead and turns toward it, reaching farther out the faster it drives.
A second, more distant lookahead point does not steer at all. When the path bends much more toward it than toward the near point, a curve is coming, and the state machine reads that as a sign of whether a lane change is safe to begin. It gives a purely reactive controller a glimpse of the road ahead at almost no cost. Speed is held by a proportional controller with output limits, and steering is clamped harder as speed rises.
On the track
In October 2023 the stack took First Prize, second place nationwide, in the simulation track.
Each of the four runs below exercises one branch of the state machine.
The team
I led a team of four—Zheng Zhang, Wentao Huang, Zeqi Yao and myself—advised by Prof. Yi Zhong, and wrote the perception, decision, planning and control code, about 3,900 lines of C++. The code itself, with every threshold and gain the car runs on, is in the repository below.