A real-time F1 telemetry visualization tool built with Python, FastF1, and Pygame. This application allows you to replay F1 race sessions with live-updating driver positions, track visualization, and session information.
- Real-time Telemetry Playback: Replay F1 sessions with synchronized telemetry data
- Live Position Tracking: Dynamic leaderboard that updates driver positions during the race based on progress
- Track Visualization: White track outline drawn from telemetry data
- Session Information Panel: Displays lap count, fastest lap, safety car status, and race control messages
- Final Race Results: Automatically displays official final positions from FastF1 data once the race is complete
- Interactive Controls: Play/pause, speed control, scrubbing, point size adjustment, label toggling
F1-python/
├── main.py # Entry point for the application
├── src/
│ ├── config.py # Configuration variables (screen dimensions, FPS, etc.)
│ ├── helpers.py # Utility functions (time formatting, color generation, coordinate normalization)
│ ├── telemetry.py # Functions for collecting and processing F1 telemetry data
│ ├── viewer.py # Pygame-based telemetry viewer and playback engine
│ └── selector.py # Tkinter GUI for selecting F1 sessions
├── requirements.txt # Python dependencies
├── README.md # This file
└── .gitignore # Git ignore rules
The codebase is organized into a src/ directory for better modularity and maintainability.
- Python 3.11.9 (tested and working 100% - other versions not tested)
- Windows/macOS/Linux
fastf1- F1 data APIpygame- Graphics and GUInumpy- Numerical computationspandas- Data manipulationtkinter- Selection interface
- Clone or download the repository
- Install Python 3.11.9 if not already installed
- Install the required packages:
pip install fastf1 pygame numpy pandasNote: tkinter is typically included with Python installations.
pip install -r requirements.txtpython main.py- Session Selection: Choose year, Grand Prix, and session type (R for Race, Q for Qualifying, etc.)
- "Launch Viewer": Start the telemetry viewer for the selected session
- SPACE: Play/Pause
- ESC or Q: Quit
- ↑/↓: Increase/Decrease playback speed
- ←/→ (when paused): Scrub 1 second forward/backward
- +/-: Adjust driver dot size
- L: Toggle driver labels
- Left Panel (600px): Track visualization with driver positions and white track outline
- Middle Panel (300px): Session information (lap count, fastest lap, safety car, race control)
- Right Panel (240px): Live position leaderboard
- FastF1 API loads session data including telemetry, lap times, positions, and messages
- Telemetry data from all drivers is collected and synchronized by time
- Track coordinates are normalized and scaled for screen display
- Telemetry is pre-processed into driver-specific data arrays for fast lookup
- Real-time simulation driven by wall-clock time for smooth playback
- Driver positions calculated using progress scores (lap * margin + distance)
- Dynamic switching between live progress tracking and official race results
- During Race: Leaderboard shows current positions based on race progress
- At Race End: Automatically switches to official final positions once all drivers complete the race
- Session Info: Safety car status, race control messages, lap counts update in real-time based on session data
- Pre-normalized coordinates for efficient rendering
- Numpy arrays for fast telemetry lookups
- Progress score-based sorting avoids expensive dataframe operations per frame
- Driver Positions: FastF1 session.laps with position data per lap
- Telemet ry: X/Y coordinates from car telemetry systems
- Timing: Synchronized using session time offsets
- Status Messages: Safety car deployments, yellow flags from status_data
- Race Control: Official messages from race control team
Screen layout can be adjusted in the main.py file:
MAIN_W = 600# Track area widthINFO_W = 300# Session info panel widthSIDEBAR_W = 240# Positions panel widthSCREEN_H = 800# Screen heightFPS = 60# Target frame rate
- All timing data is normalized to simulation time (0 = race start)
- Status messages and race control messages are time-filtered for relevance
- Track coordinates are projected onto 2D screen space with padding
- Graceful handling of missing telemetry data
- Defaults for drivers without telemetry (shown as "DNF")
- Caching system reduces API load for repeated sessions
- Requires active internet connection for FastF1 data (first-time load)
- Telemetry quality depends on session data availability
- Designed primarily for race sessions; qualifying sessions have limited data
- Python 3.11.9 confirmed working - other versions may have compatibility issues
This project is for educational and personal use only. F1 data is provided through the FastF1 API with proper attribution to Formula 1.