← All projects

Lap Comparison & Driving-State Analysis Tool

FastF1 Python Race Engineering

A Python CLI tool for analysing and comparing Formula 1 telemetry.

Key Capabilities:

  • Classifies driving states (braking, cornering, accelerating, coasting).
  • Maps telemetry directly to specific track corners.
  • Cross-examines driver laps to automatically generate actionable coaching insights and improve lap times.
Hamilton's Silverstone qualifying lap coloured by driving state: braking, cornering, accelerating, coasting

Analytical Framework

  • Signal Processing: Speed, throttle, brake, and position are resampled to a 10 Hz grid and smoothed via a Savitzky-Golay filter to prevent acceleration spikes.
  • Kinematics: Lateral acceleration is derived from signed path curvature as a substitute for the steering channel.
  • Fail-Safes: Accelerations are clipped at ±8g as a backstop against residual differentiation noise.

Implementation

Raw and derived telemetry channels: time, speed, longitudinal and lateral acceleration, throttle, brake and DRS

1. Data Processing

The pipeline begins by extracting time, speed, throttle, brake, and DRS data directly from FastF1. All of these metrics are then aligned by distance, and acceleration profiles are derived using speed and track positioning.


def classify_state(mp):
    braking = mp['brake'] > BRAKE_THRESHOLD
    cornering = (~braking) & (mp['latAcc'].abs() > LAT_ACC_THRESHOLD)
    accelerating = (~braking) & (~cornering) & (mp['throttle'] > THROTTLE_THRESHOLD)

    state = pd.Series('Coasting', index=mp.index)
    state[accelerating] = 'Accelerating'
    state[cornering] = 'Cornering'
    state[braking] = 'Braking'
    return state

2. Driving-State Classification

The tool assigns a driving state to every sample using priority-based cut-offs. By evaluating brake pressure first, complex driver inputs like trail-braking deep into an apex are correctly identified as "Braking" rather than "Cornering".

Bottas's Silverstone qualifying lap coloured by driving state, with numbered corner markers

3. Corner Identification

Lateral acceleration is translated into mapped corners, bridging any straight gaps under 15m and numbering them sequentially from Turn 1. This process is kept entirely independent of the state labels, ensuring that braking and exit zones remain anchored to a single corner.

Braking Cornering Accelerating Coasting
Cumulative time delta between two drivers around the lap

4. Distance Alignment & Delta

To compare laps, both time-versus-distance curves are interpolated onto a common 5m grid. The smoothed delta gradients are then grouped into contiguous gain or loss segments of at least 15m to filter out any sample-by-sample noise.

Automated Coaching Insights

Track map coloured by which driver was faster at each point around the lap

Macro-Level Gains Mapping

These time-delta segments are superimposed back onto the circuit map. This provides an instant strategic overview of exactly where a lap was won or lost before needing to dive into the apex-level data.

Coaching Notes

For every gain segment, the tool audits key telemetry drivers such as minimum apex speed, initial braking distance, and throttle application. Any minor variances under 3 km/h or 3m are automatically rejected as noise to keep the feedback focused.

Example Output:

BOT +0.xxx s  Turn 9 (Right-hander)  (during Cornering)

→ HAM: try to carry more corner speed; brake later; get to full throttle sooner.