Racing Simulator: Telemetry Collect & Query in Google Cloud

Summarizing Data Flow

There are (4) files involved in the collecting of telemetry from the LFS simulator:

 

    • cfg.txt – outflow needs to be modified to communicate w/ mock_track_telemetry.py 

    • mock_track_telemetry.py: This script runs a UDP server that listens for the packets sent by the LFS game on port 9996 and receives the data from the simulator.

    • gcp_publisher.py: This file communicates w/ GCP. It contains the TelemetryPublisher class, which acts as a robust wrapper around the official Google Cloud client library. It’s this file’s job to actually send the data.

    • main.py: Activates the google cloud function that places the data in Big Query.

Step-by-Step

LFS Game -> mock_track_telemetry.py -> gcp_publisher.py -> Google Cloud Pub/Sub -> f1-turn-function in main.py-> Google Cloud BigQuery

 

    1. mock_track_telemetry.py Receives Data: This script runs a UDP server that listens for the packets sent by the LFS game.

    1. mock_track_telemetry.py Uses the Publisher: After receiving and processing a data packet, mock_track_telemetry.py uses a helper class called TelemetryPublisher to handle the cloud communication. You can see this in the code:python Show full code block # c:\Users\pgmav\Desktop\f1_hpc_budget\mock_track_telemetry.py # It imports the class from the other file from gcp_publisher import get_gcp_config, TelemetryPublisher # It creates an instance of the publisher telemetry_publisher = TelemetryPublisher(project_id, topic_id) # ... later in the loop, it calls the publish method telemetry_publisher.publish(data_point)

Communicating w/ GCP

The gcp_publisher.py script is the bridge from your local machine to the Google Cloud ecosystem.

 

    1. It initializes the pubsub_v1.PublisherClient.

    1. Its publish method takes your data, encodes it, and sends it to your Google Cloud Pub/Sub topic (f1-telemetry).

    1. Google Cloud Function (f1-turn-function/main.py) Takes Over: Once the data arrives in the Pub/Sub topic, a serverless Google Cloud Function is automatically triggered. This function:

       

        • Reads the new message from the Pub/Sub topic.

        • Validates the data to make sure it’s in the correct format.

        • Inserts the validated data as a new row into your BigQuery table (f1_analysis.monaco_data).

Scripts

Leave a Reply

Your email address will not be published. Required fields are marked *