Skip to content

GT Telemetry is a module for reading Gran Turismo race telemetry streams in Go.

License

Notifications You must be signed in to change notification settings

vwhitteron/gt-telemetry

Repository files navigation

GT Telemetry

Build Status codecov Go Report Card

GT Telemetry is a module for reading Gran Turismo race telemetry streams in Go.

Features

  • Support for all fields contained within the telemetry data packet.
  • Access data in both metric and imperial units.
  • An additional field for the differential gear ratio is computed based on the rolling wheel diameter of the driven wheels.
  • A vehicle inventory database for providing the follwing information on a given vehicle ID:
    • Manufacturer
    • Model
    • Year
    • Drivetrain
    • Aspiration
    • Type (racing or street)
    • Racing category
    • Open cockpit exposure

Installation

To start using gt-telemetry, install Go 1.21 or above. From your project, run the following command to retrieve the module:

go get github.com/vwhitteron/gt-telemetry

Usage

import telemetry_client "github.com/vwhitteron/gt-telemetry"

Construct a new GT client and start reading the telemetry stream. All configuration fields are optional with the default values show in the example.

config := telemetry_client.GTClientOpts{
    Source: "udp://255.255.255.255:33739"
    LogLevel: "warn",
    StatsEnabled: false,
    VehicleDB: "./internal/vehicles/inventory.json",
}
gt, _ := telemetry_client.NewGTClient(config)
go gt.Run()

If the PlayStation is on the same network segment then you will probably find that the default broadcast address 255.255.255.255 will be sufficient to start reading data. If it does not work then enter the IP address of the PlayStation device instead.

Read some data from the stream:

    fmt.Printf("Sequence ID:  %6d    %3.0f kph  %5.0f rpm\n",
        gt.Telemetry.SequenceID(),
        gt.Telemetry.GroundSpeedKPH(),
        gt.Telemetry.EngineRPM(),
    )

Replay files

Offline saves of replay files can also be used to read in telemetry data. Files can be in either plain (*.gtr) or compressed (*.gtz) format.

Read telemetry from a replay file by setting the Source value in the GTClientOpts to a file URL, like so:

config := telemetry_client.GTClientOpts{
    Source: "file://examples/simple/replay.gtz"
}

Saving a replay to a file

Replays can be captured and saved to a file using cmd/capture_replay/main.go. Captures will be saved in plain or compressed formats according to the file extension as mentioned in the section above.

A replay can be saved to a default file by running:

make run/capture-replay

Alternatively, the replay can be captured to a compressed file with a different name and location by running:

go run cmd/capture_replay/main.go -o /path/to/replay-file.gtz

Examples

The examples directory contains example code for accessing most data made available by the library. The telemetry data from a sample saved replay can be viewed by running:

make run/live

The example code can also read live telemetry data from a PlayStation by removing the Source field in the GTClientOpts.

asciicast

Acknowledgements

Special thanks to Nenkai for the excellent work documenting the Gran Turismo telemetry protocol.

About

GT Telemetry is a module for reading Gran Turismo race telemetry streams in Go.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published