Show HN:Undercutf1——带车手追踪和可变延迟的F1实时计时终端用户界面
Show HN: Undercutf1 – F1 Live Timing TUI with Driver Tracker, Variable Delay

原始链接: https://github.com/JustAman62/undercut-f1

Undercut-F1 是一款开源的、基于终端(TUI)的F1实时计时客户端,灵感来源于FastF1。它在比赛期间显示实时数据并将其记录下来以便回放,并通过可调节的数据延迟来解决广播延迟问题。 主要功能包括:带有实时扇区时间、轮胎磨损、时间差、进站策略和赛事控制信息的计时塔,以及赛道地图上的车手追踪器。您可以监控车手之间的时间差以预测进站窗口,查看逐圈计时历史,甚至使用本地机器学习模型来转录车队无线电通讯。 安装方式包括 .NET 工具安装或使用独立的可执行文件。使用时,启动应用程序,选择一个比赛阶段(实时或预录),然后监控计时塔。数据保存在 `~/undercut-f1/data` 目录中。配置可以通过JSON、命令行参数或环境变量进行自定义。还提供可调节的延迟、用于各种操作的全局光标和全面的日志记录。所有这些功能结合在一起,为您提供对比赛的深入了解。

“Undercutf1” 是一款基于终端(TUI)的F1实时计时应用程序,旨在提供比标准电视转播更详细的信息。 开发者厌倦了错过超车和解释不清的策略,因此构建了这个工具来显示实时数据,例如车手追踪器、计时塔、赛会控制、单圈/差距历史等等。它使用F1实时计时SignalR流。 用户可以回放过去的比赛,例如铃鹿赛道(说明已提供),或者在即将到来的吉达大奖赛等比赛中实时使用。应用程序需要大约110x30的终端大小才能获得最佳观看效果。一个关键功能是可以调整计时馈送延迟以匹配电视转播。开发者建议同步比赛计时,目标是在比赛期间通过将应用内计时与电视上的发车圈开始时间对齐,实现30-60秒的延迟。

原文

undercut-f1 is an open source F1 Live Timing client.

undercutf1 is a TUI application which uses UndercutF1.Data to show a Live Timing screen during sessions, and records the data for future session replays. F1 live broadcasts are usually delayed by some undeterminable amount (usually 30-60 seconds), so the TUI allows you to delay the data being displayed so that you can match up what you see on your screen to what you see on your TV.

The UndercutF1.Data library is provided to facilitate connectivity with the F1 Live Timing data stream, and handle all the processing of the incoming data. It also allows for "simulated" streams, where previously recorded data streams can be played back to allow for easy development/testing.

Feature Highlights:

Timing Tower during a Race

  • Timing Tower showing for each driver:
    • Live sector times, with colouring for personal/overall fastest
    • Last & Best Lap
    • Current tyre
    • Age of current tyre
    • Interval to driver in front
    • Gap to leader
    • Gap between a selected driver and all other drivers (useful for monitoring pit windows)
  • Pit Stop Strategy gives you at-a-glance information about all the drivers strategies
  • Race Control messages including investigations, penalties, lap deletions, and weather
  • Driver Tracker shows the position of selected drivers on a live track map
  • Lap-by-lap Timing History to observe gaps over time

This project is heavily inspired by the FastF1 project by theOehrly. They did a lot of the work understanding the SignalR stream coming from the F1 Live Timing service. Visit their project if you'd like to do any sort of data analysis on past F1 events, or gather live timing data using their module.

Timing Tower during a Race

Monitor sector times and gaps, see recent race control messages, capture position changes, observe pit strategies, and more with the standard Timing Tower view.

Timing Tower during a Race

Using a Cursor to Display Relative Gap for a Specific Driver

Use the cursor controlled by the / Cursor actions in the O Timing Tower screen to select a specific driver (in this case Norris) to see the relative interval between that driver and all other. This is useful for determining where a driver will fall to after a pit stop, or looking at pit windows during under cuts.

Additionally, the gap between the selected drivers and those around them over the last four laps will be displayed at the bottom of the screen. This allows you to easily see evolving gaps over time and evaluate how soon a driver may catch up or pull away.

Relative gaps for a specific driver

Timing Tower during Practice/Qualifying

Monitor live/best sector times, gaps, tyres, and lap deletions easily with the specialized timing tower for non-race sessions.

Timing Tower during Practice/Qualifying

The Race Control page shows all Race Control Messages for the session, along with other session data such as the Weather.

Race Control Page

The Driver Tracker page shows a track map overlayed with selected drivers. Use the / Cursor actions to choose drivers, then use the Toggle Select action to toggle the inclusion of the driver on the track map. The driver under the current cursor position will also be highlighted on the map, and timing gaps will switch to interval between that driver and all other drivers.

Driver Tracker Page

NOTE: Currently the track map is only supported in the iTerm2 terminal (by implementing the iTerm2's Inline Image Protocol), and terminals which implement the Kitty Graphics Protocol. Other protocols (such as Sixel) may be supported in the future. If the track map doesn't work in your terminal, please raise an issue and I will try and fix/implement support.

The Tyre Stint page shows the tyre strategy for all the drivers. At a glance, see what tyres the drivers have used, how old they are, and if they are on an offset strategy to any other drivers.

Use the / Cursor actions to view more information for a particular drivers strategy.

Tyre Stint

Using a Cursor to View Timing History by Lap

In the Timing by Lap page, you can use the cursor controlled by the / Cursor actions to view historical snapshots of the timing tower at the end of every lap. This view will show position changes during that lap, and relative changes in Gap and Interval. Scrolling through laps allows you to build a picture of how the race is unfolding.

Charts on the right display how Gap to Leader and Lap Time for all selected drivers over the last 15 laps, letting you see trends and catch strategies unfolding.

Using a Cursor to View Timing History by Lap

Listen to and Transcribe Team Radio

Listen to team radio clips from anytime in the session, and use a local ML model (Whisper) to transcribe the audio on demand. Transcription accuracy is fairly low, depending on the that days audio quality and driver. Suggestions welcome for improving this!

Listen to and Transcribe Team Radio

Getting Started with undercutf1

Install and run as a dotnet tool

undercutf1 is available as a dotnet tool from NuGet, which means it can be installed system-wide simply by running:

# Install globally using the -g flag
dotnet tool install -g undercutf1

# Assuming the dotnet tools directory is on your path, simply execute undercutf1
undercutf1

This method is recommended as it is easy to keep the app updated using dotnet tool update -g undercutf1. You'll need the .NET 9 SDK installed to use this installation method. If you'd rather not install the SDK, try the standalone installation option below.

Install and run the standalone executable

Standalone executables are attached to each GitHub release. Download the executable for your system OS/architecture and simply run it directly. The list of artifacts are available on the release page for the latest release.

# Download the latest executable (in this case for osx-arm64)
curl https://github.com/JustAman62/undercut-f1/releases/latest/download/undercutf1-osx-arm64 -o ./undercutf1 -L

# Execute undercutf1 to start the TUI
./undercutf1
# Checkout the git repository
git clone [email protected]:JustAman62/undercut-f1.git
cd undercut-f1

# Run the console project with `dotnet run`
dotnet run --project UndercutF1.Console/UndercutF1.Console.csproj

By default, data will be saved and read from the ~/undercut-f1 directory. See Configuration for information on how to configure this.

Start Timing for a Live Session

  1. Start undercutf1 as described above
  2. Navigate to the S Session Screen
  3. Start a Live Session with the L Start Live Session action.
  4. Switch to the Timing Tower screen with the T Timing Tower action

During the session, streamed timing data will be written to ~/undercut-f1/data/<session-name>. This will allow for future replays of this recorded data.

Start Timing for a Pre-recorded Session

Data for pre-recorded sessions should be stored in the ~/undercut-f1/data/<session-name> directory. Sample data can be found in this repos Sample Data folder. To use this sample data, copy one of the folders to ~/undercut-f1/data and then it will be visible in step 4 below.

  1. OPTIONAL: Download sample data to ~/undercut-f1/data. If you already have data, or have checked out the repository, skip to the next step.

    # Create the directory for the data if it doesn't exist
    mkdir -p ~/undercut-f1/2024_Silverstone_Race
    
    # Download the live and subscribe data files
    curl https://raw.githubusercontent.com/JustAman62/undercut-f1/refs/heads/master/Sample%20Data/2024_Silverstone_Race/live.txt -o ~/undercut-f1/2024_Silverstone_Race/live.txt
    
    curl https://raw.githubusercontent.com/JustAman62/undercut-f1/refs/heads/master/Sample%20Data/2024_Silverstone_Race/subscribe.txt -o ~/undercut-f1/2024_Silverstone_Race/subscribe.txt
  2. Start undercutf1 as described above

  3. Navigate to the S Session Screen

  4. Start a Simulated Session with the F Start Simulation action.

  5. Select the session to start using the Up/Down arrows, then pressing Enter

  6. Switch to the Timing Tower screen with the T Timing Tower action

  7. Optionally skip forward in time a bit by decreasing the delay with N (or ⇧ Shift + N to decrease by 30 seconds).

Download a previous session data for replay

F1 provides static timing data files for already completed sessions. This data can be downloaded and converted into the same format undercutf1 uses to save live recorded data. You can then replay the old session using the steps above.

  1. List the meetings that have data available to import with undercutf1 import <year>
  2. Review the list of meetings returned from the command, and list the available sessions inside the chosen meeting with undercutf1 import <year> --meeting-key <meeting-key>
  3. Review the list of sessions, and select one to import: undercutf1 import <year> --meeting-key <meeting-key> --session-key <session-key>
  4. Data that is imported will be saved to the configured DATA_DIRECTORY. See Configuration for information on how to change this.

All session data, whether live or pre-recorded, is sent to a Channel that acts as a delayed-queue. After a short delay, data points are pulled from the queue and processed, leading to updates on the timing screens. The amount of this delay can be changed with the M/N Delay actions whilst on the timing screens. Hold ⇧ Shift to change the delay by 30 seconds instead of 5. When using undercutf1 during a live session, you may wish to increase this delay to around ~50 seconds (actual number may vary) to match with the broadcast delay and avoid being spoiled about upcoming action.

Simulated sessions start with a calculated delay equal to the amount of time between the start of the actual session and now. This means you can decrease the delay with the N Delay action to fast-forward through the session.

There is a global cursor that is controlled with the / Cursor actions. What this cursor does depends on the screen, for example is can be used in the Timing Tower screen to scroll through Race Control Messages, or to select a driver on the Tower to see comparative intervals.

UndercutF1 can be configured using either a simple config.json file, through the command line at startup, or using environment variables. JSON configuration will be loaded from ~/undercut-f1/config.json, if it exists.

JSON Path Command Line Environment Variable Description
dataDirectory --data-directory UNDERCUTF1_DATADIRECTORY The directory in which JSON timing data is read or written from.
verbose -v|--verbose UNDERCUTF1_VERBOSE Whether verbose logging should be enabled. Default: false. Values: true or false.
apiEnabled --with-api UNDERCUTF1_APIENABLED Whether the app should expose an API at http://localhost:61937. Default: false. Values: true or false.
notify --notify UNDERCUTF1_NOTIFY Whether the app should sent audible BELs to your terminal when new race control messages are received. Default: true. Values: true or false.

UndercutF1.Data writes logs using the standard ILogger implementation. SignalR client logs are also passed to the standard ILoggerProvider.

When running undercutf1 logs are available in two places:

  • Logs are stored in memory and viewable the L Logs screen. Logs can be scrolled on this screen, and the minimum level of logs shown can be changed with the M Minimum Log Level action.
  • Log files are written to ~/undercut-f1/logs.

Default log level is set to Information. More verbose logging can be enabled with the verbose config option.

F1 live timing is streamed using SignalR. The UndercutF1.Data simply connects to this endpoint, subscribes to the data feed, and listens for messages. It subscribes to the following "topics":

  • Heartbeat
  • ExtrapolatedClock
  • TopThree
  • TimingStats
  • TimingAppData
  • WeatherData
  • TrackStatus
  • DriverList
  • RaceControlMessages
  • SessionInfo
  • SessionData
  • LapCount
  • TimingData
  • CarData.z
  • Position.z
  • ChampionshipPrediction
  • TeamRadio

Data Recording and Replay

All events received by the live timing client will be written to the configured Data Directory, see see Configuration for details. Files will be written to a subdirectory named using the current sessions name, e.g. ~/undercut-f1/data/Jeddah_Race/. In this directory, two files will be written:

  • subscribe.txt contains the data received at subscription time (i.e. when the live timing client connected to the stream)
  • live.txt contains an append-log of every message received in the stream

Both of these files are required for future simulations/replays. The IJsonTimingClient supports loading these files and processing them in the same way live data would be. Data points will be replayed in real time, using an adjustable delay.

undercut-f1 is unofficial and are not associated in any way with the Formula 1 companies. F1, FORMULA ONE, FORMULA 1, FIA FORMULA ONE WORLD CHAMPIONSHIP, GRAND PRIX and related marks are trade marks of Formula One Licensing B.V.

联系我们 contact @ memedata.com