Track progress s
Source engine/src/dtta/engine/track/{centerline,projection}.py · parameters centerline_*, proj_*.
The shared coordinate for every comparison is the distance s (metres) along a fixed closed
centerline, measured from the start/finish gate in the direction of travel. It is not the racing
line: a lap's lateral offset from the centerline is a measured quantity, and two laps taking different
lines are aligned at physically identical places.
Centerline construction
- Valid GPS points of the racing laps are ordered by a provisional progress parameter (unwrapped polar angle about the track centroid, which works for ovals).
- They are binned into
centerline_bins(180) angular bins; the median x, y of each bin forms a closed polyline (empty bins are filled by circular interpolation, then a circular median over ±1 bin is applied). - The polyline is smoothed with a least-squares Fourier series of the closed curve: the smallest number
of harmonics (from 4 up to
centerline_max_harmonics= 32) whose RMS residual to the bin medians is at mostcenterline_smooth_rms_m(1 m). - The curve is resampled at uniform arc length
centerline_ds_m(1 m): , , with heading and signed curvature from central differences. s = 0is placed at the gate; direction is the direction of travel.
The centerline is versioned (its hash is an input of every downstream artifact). Segment boundaries are stored as fractions of so they survive a rebuild.
Continuity-constrained projection
Independent nearest-neighbour projection can snap a noisy point to the opposite straight of a narrow oval or to a parallel pit lane. Instead, each lap is projected sequentially with a prediction window:
- Predicted progress: .
- Search window: with =
proj_sigma_s_m(3 m). - Among the centerline points in the window the one with the smallest perpendicular distance is
chosen, provided
proj_n_max_m(30 m) andproj_back_tol_m(2 m). - Confidence: .
- If no candidate qualifies the sample is marked lost, , confidence 0. More than
proj_lost_limit(5) consecutive lost samples invalidates the lap (projection_lost). - The gate crossing pins and so
sunwraps continuously through the gate.
The signed lateral offset is positive to the left of the direction of travel.
From samples to a grid
t(s) for a lap is a monotone piecewise-cubic interpolant (PCHIP) through the running maximum of the
projected s values, anchored at and , evaluated on the 1 m grid. PCHIP preserves
monotonicity and cannot overshoot. Speed, path accelerations, lateral offset and projection confidence
are linearly interpolated onto the same grid. Every chart, the map cursor and the readout use these grid
values directly; the browser never interpolates between them.
Verified
- Real fixtures:
proj_lost_count = 0and mean projection confidence 0.85–0.96 on every racing lap. - Synthetic (
engine/tests/synthetic): a 40 m-wide oval with 3 m GPS noise never projects to the wrong straight; a pit lane 8 m outside the front stretch creates no lap; a 20 m infield excursion is lost for ≤ 5 samples and the lap survives; crossing the gate with ±3 m noise unwrapsswithout a discontinuity. - Centerline arc length on a synthetic ellipse within 0.1 % of the analytic value; curvature sign tested.