get_lap_telemetry
Retrieve high-frequency telemetry data for specific Formula 1 laps, including speed, throttle, brake, gear, RPM, and DRS usage to analyze driver performance and compare lap execution.
Instructions
Get detailed telemetry data for a specific lap.
Retrieves high-frequency telemetry data including speed, throttle, brake, gear, RPM, and DRS usage throughout a lap. Essential for detailed performance analysis and driver comparison.
Args: year: The season year (2018 onwards) gp: The Grand Prix name or round number session: Session type - 'FP1', 'FP2', 'FP3', 'Q', 'S', 'R' driver: Driver identifier - 3-letter code (e.g., 'VER') or number (e.g., 1) lap_number: The specific lap number to analyze
Returns: LapTelemetryResponse: High-frequency telemetry data in JSON-serializable format
Examples: >>> # Get telemetry for Verstappen's lap 15 in 2024 Monza race >>> telemetry = get_lap_telemetry(2024, "Monza", "R", "VER", 15)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| driver | Yes | ||
| gp | Yes | ||
| lap_number | Yes | ||
| session | Yes | ||
| year | Yes |
Implementation Reference
- tools/telemetry/lap_telemetry.py:10-62 (handler)The core handler function for the get_lap_telemetry tool. Fetches FastF1 session data, loads lap telemetry, processes it into structured TelemetryPoint objects, and returns a LapTelemetryResponse.def get_lap_telemetry(year: int, gp: Union[str, int], session: str, driver: Union[str, int], lap_number: int) -> LapTelemetryResponse: """ Get high-frequency telemetry for a lap - speed, throttle, brake, gear, RPM, DRS. Args: year: Season year (2018+) gp: Grand Prix name or round session: 'FP1', 'FP2', 'FP3', 'Q', 'S', 'R' driver: Driver code or number lap_number: Specific lap number Returns: LapTelemetryResponse with telemetry points Example: get_lap_telemetry(2024, "Monza", "R", "VER", 15) → VER lap 15 telemetry """ session_obj = fastf1_client.get_session(year, gp, session) session_obj.load(laps=True, telemetry=True, weather=False, messages=False) event = session_obj.event driver_laps = session_obj.laps.pick_drivers(driver) lap = driver_laps[driver_laps['LapNumber'] == lap_number].iloc[0] telemetry_df = lap.get_telemetry() # Convert to Pydantic models telemetry_points = [] for idx, row in telemetry_df.iterrows(): point = TelemetryPoint( session_time=str(row['SessionTime']) if pd.notna(row.get('SessionTime')) else None, distance=float(row['Distance']) if pd.notna(row.get('Distance')) else None, speed=float(row['Speed']) if pd.notna(row.get('Speed')) else None, rpm=float(row['RPM']) if pd.notna(row.get('RPM')) else None, n_gear=int(row['nGear']) if pd.notna(row.get('nGear')) else None, throttle=float(row['Throttle']) if pd.notna(row.get('Throttle')) else None, brake=float(row['Brake']) if pd.notna(row.get('Brake')) else None, drs=int(row['DRS']) if pd.notna(row.get('DRS')) else None, x=float(row['X']) if pd.notna(row.get('X')) else None, y=float(row['Y']) if pd.notna(row.get('Y')) else None, z=float(row['Z']) if pd.notna(row.get('Z')) else None, ) telemetry_points.append(point) return LapTelemetryResponse( session_name=session_obj.name, event_name=event['EventName'], driver=str(lap['Driver']), lap_number=lap_number, lap_time=str(lap['LapTime']) if pd.notna(lap.get('LapTime')) else None, telemetry=telemetry_points, total_points=len(telemetry_points) )
- server.py:158-158 (registration)Registers get_lap_telemetry as an MCP tool using the FastMCP decorator.mcp.tool()(get_lap_telemetry)
- tools/__init__.py:55-55 (registration)Exports get_lap_telemetry in the tools package __all__ for easy import in server.py."get_lap_telemetry",
- tools/telemetry/__init__.py:1-1 (helper)Re-exports the get_lap_telemetry function from lap_telemetry.py module.from .lap_telemetry import get_lap_telemetry
- Type annotations define the input schema (parameters) and output schema (LapTelemetryResponse Pydantic model).def get_lap_telemetry(year: int, gp: Union[str, int], session: str, driver: Union[str, int], lap_number: int) -> LapTelemetryResponse: