[PR #132] fix(ui): Implement Dynamic Velocity-Based Time Gap Calculation #163

Open
opened 2026-05-07 00:18:59 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/IAmTomShaw/f1-race-replay/pull/132
Author: @shash-hq
Created: 12/27/2025
Status: 🔄 Open

Base: mainHead: fix/time-gaps


📝 Commits (2)

  • aaadd31 Fix: Implemented dynamic time gap calculation based on telemetry speed
  • b80ff53 Fix(ui): Add missing Time Gap rendering to Leaderboard

📊 Changes

1 file changed (+39 additions, -15 deletions)

View changed files

📝 src/ui_components.py (+39 -15)

📄 Description

Analysis of Issue

The DriverInfoComponent in src/ui_components.py calculated time gaps using a static constant velocity model (REFERENCE_SPEED_MS = 55.56 or ~200 km/h). This resulted in substantial deviations from reality during non-standard race phases (e.g., Safety Car, cornering, pit maneuvers).

Implementation Details

  • Dynamic Calculation: Refactored the calculate_gap function to accept instantaneous velocity inputs.
  • Vectorized Logic:
    • Gap Ahead: Now calculated as ΔDistance / Velocity_Self.
    • Gap Behind: Now calculated as ΔDistance / Velocity_Opponent.
  • Safety Constraints: Implemented a minimum velocity floor (10.0 m/s) to prevent division-by-zero errors or asymptotic time values during low-speed intervals.

Verification

  • Tested scenarios with varying speed deltas (e.g., fast approaching car vs. slow leading car).
  • Validated that gap times correlate accurately with spatial distance and current telemetry speed.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/IAmTomShaw/f1-race-replay/pull/132 **Author:** [@shash-hq](https://github.com/shash-hq) **Created:** 12/27/2025 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/time-gaps` --- ### 📝 Commits (2) - [`aaadd31`](https://github.com/IAmTomShaw/f1-race-replay/commit/aaadd31d941d37ad86c62a8ded59e2a8c3723337) Fix: Implemented dynamic time gap calculation based on telemetry speed - [`b80ff53`](https://github.com/IAmTomShaw/f1-race-replay/commit/b80ff5350eb4f15d277188adb7c0210a34b6d873) Fix(ui): Add missing Time Gap rendering to Leaderboard ### 📊 Changes **1 file changed** (+39 additions, -15 deletions) <details> <summary>View changed files</summary> 📝 `src/ui_components.py` (+39 -15) </details> ### 📄 Description ## Analysis of Issue The `DriverInfoComponent` in `src/ui_components.py` calculated time gaps using a static constant velocity model (`REFERENCE_SPEED_MS = 55.56` or ~200 km/h). This resulted in substantial deviations from reality during non-standard race phases (e.g., Safety Car, cornering, pit maneuvers). ## Implementation Details - **Dynamic Calculation:** Refactored the `calculate_gap` function to accept instantaneous velocity inputs. - **Vectorized Logic:** - **Gap Ahead:** Now calculated as `ΔDistance / Velocity_Self`. - **Gap Behind:** Now calculated as `ΔDistance / Velocity_Opponent`. - **Safety Constraints:** Implemented a minimum velocity floor (`10.0 m/s`) to prevent division-by-zero errors or asymptotic time values during low-speed intervals. ## Verification - Tested scenarios with varying speed deltas (e.g., fast approaching car vs. slow leading car). - Validated that gap times correlate accurately with spatial distance and current telemetry speed. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/f1-race-replay#163
No description provided.