telemetry

package module
v0.0.0-...-8e4b33f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 17, 2024 License: MIT Imports: 13 Imported by: 0

README

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

Known issues

  • The vehicle inventory database is missing information on some vehicles. Feel free to raise a pull request to add any missing or incorrect information.
  • The differential ratio may be incorrect for vehicles that are not defined in the inventory database. By default the ratio is based on the rolling diameter of the rear wheels so will result in an incorrect ratio for front wheel drive cars with staggered wheel diameters.

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.Config{
    IPAddr: "255.255.255.255",
    LogLevel: "info",
    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(),
    )

Examples

The examples directory contains an example for accessing most data made available by the library. The telemetry data can be viewed by running:

make run/live

Acknowledgements

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTransformer

func NewTransformer(inventory *vehicles.Inventory) *transformer

Types

type CornerSet

type CornerSet struct {
	FrontLeft  float32
	FrontRight float32
	RearLeft   float32
	RearRight  float32
}

type Flags

type Flags struct {
	ASMActive        bool
	GamePaused       bool
	HandbrakeActive  bool
	HasTurbo         bool
	HeadlightsActive bool
	HighBeamActive   bool
	InGear           bool
	Live             bool
	Loading          bool
	LowBeamActive    bool
	RevLimiterAlert  bool
	TCSActive        bool
	Flag13           bool
	Flag14           bool
	Flag15           bool
	Flag16           bool
}

type GTClient

type GTClient struct {
	Telemetry  *transformer
	Statistics *statistics
	// contains filtered or unexported fields
}

func NewGTClient

func NewGTClient(opts GTClientOpts) (*GTClient, error)

func (*GTClient) Run

func (c *GTClient) Run()

func (*GTClient) SendHeartbeat

func (c *GTClient) SendHeartbeat(conn *net.UDPConn)

type GTClientOpts

type GTClientOpts struct {
	IPAddr       string
	LogLevel     string
	Logger       *zerolog.Logger
	StatsEnabled bool
	VehicleDB    string
}

type RevLight

type RevLight struct {
	Min    uint16
	Max    uint16
	Active bool
}

type SymmetryAxes

type SymmetryAxes struct {
	Pitch float32
	Yaw   float32
	Roll  float32
}

type Transmission

type Transmission struct {
	Gears      int
	GearRatios []float32
}

type Vector

type Vector struct {
	X float32
	Y float32
	Z float32
}

type Vmax

type Vmax struct {
	Speed uint16
	RPM   uint16
}

Directories

Path Synopsis
examples
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL