Get Grand Turismo telemetry data from the PlayStation console
Project description
GranTurismo
This package wraps the Gran Turismo 7's unofficial telemetry API. By providing this module with you're PlayStation's IP address (as found in the menu) you will be able to retrieve packets containing telemetry data.
Data
Because this is an unofficial API, the range expected min/max of each value is still unknown. As more effort is put into understanding this API, better information will be available. For now, here is what we know.
- int:
packet_id
- int:
car_id
- int or None:
lap_count
- int or None:
laps_in_race
- int or None:
best_lap_time
- int or None:
last_lap_time
- Vector:
position
- float:
x
- float:
y
- float:
z
- float:
- Vector:
velocity
- float:
x
- float:
y
- float:
z
- float:
- Vector:
angular_velocity
- float:
x
- float:
y
- float:
z
- float:
- Rotation:
rotation
- float:
pitch
- float:
yaw
- float:
roll
- float:
- Vector:
road_plane
- float:
x
- float:
y
- float:
z
- float:
- float:
road_distance
: Should match thebody_height
when car is on the ground - Wheels:
wheels
- Wheel:
front_left
- float:
suspension_height
: between 0-1. Lower number equates to uncompressed, higher number to a more compressed suspension - float:
radius
: Radius of the tire in meters - float:
rps
: Rotations per second - float:
ground_speed
: The speed the tire is traveling on the ground in meters per second. - float:
temperature
: The surface temperature of the tire in celsius
- float:
- Wheel:
y
- float:
suspension_height
: between 0-1. Lower number equates to uncompressed, higher number to a more compressed suspension - float:
radius
: Radius of the tire in meters - float:
rps
: Rotations per second - float:
ground_speed
: The speed the tire is traveling on the ground in meters per second. - float:
temperature
: The surface temperature of the tire in celsius
- float:
- Wheel:
z
- float:
suspension_height
: between 0-1. Lower number equates to uncompressed, higher number to a more compressed suspension - float:
radius
: Radius of the tire in meters - float:
rps
: Rotations per second - float:
ground_speed
: The speed the tire is traveling on the ground in meters per second. - float:
temperature
: The surface temperature of the tire in celsius
- float:
- Wheel:
x
- float:
suspension_height
: between 0-1. Lower number equates to uncompressed, higher number to a more compressed suspension - float:
radius
: Radius of the tire in meters - float:
rps
: Rotations per second - float:
ground_speed
: The speed the tire is traveling on the ground in meters per second. - float:
temperature
: The surface temperature of the tire in celsius
- float:
- Wheel:
- Flags:
flags
- float:
orientation
- float:
body_height
in meters - float:
engine_rpm
- float:
gas_level
- float:
gas_capacity
100 for gas cars, 5 for karts, 0 for electric - float:
car_speed
in meters per second - float:
turbo_boost
- float:
oil_pressure
in bars? - float:
oil_temperature
in celsius - float:
water_temperature
in celsius - int:
time_of_day
in seconds since midnight - Optional(int):
start_position
only available before race starts, otherwise None - Optional(int):
cars_in_race
only available before race starts, otherwise None - Bounds:
rpm_alert
- float:
min
- float:
max
- float:
- int:
car_max_speed
in meters per second - float:
transmission_max_speed
in terms of gear ratio? - int:
throttle
between 0-255 - int:
brake
between 0-255 - float:
clutch
between 0-1. This seems to correlate with the clutch peddle - float:
clutch_engagement
between 0-1 - float:
clutch_gearbox_rpm
- int:
current_gear
- Optional(int):
suggested_gear
. None if there's no suggested gear - List(float):
gear_ratios
1st - Nth gear. - int:
unused_0x93
- int:
unused_0xD4
Installation
To install, run pip install granturismo
Usage
The main function is the Listener, which is a closing object. You can use a with Listener(ip_address) as ...
clause to open and close the listener.
The Listener will spin up a background thread to maintain a heartbeat connection with the PlayStation, so it's important to always close the object.
Quickstart example
Grab a single packet from Gran Turismo and print it
from granturismo.intake import Listener
import sys
if __name__ == '__main__':
ip_address = sys.argv[1]
with Listener(ip_address) as listener:
print(listener.get())
Streaming data example
Stream all incoming data from Gran Turismo and print it to the terminal
import sys
from granturismo.intake import Listener
import matplotlib.pyplot as plt
import time
if __name__ == '__main__':
ip_address = sys.argv[1]
# setup the plot styling
plt.ion()
fig = plt.figure(figsize=(10, 10))
plt.xticks([])
plt.yticks([])
px, pz = None, None
prev_time = 0
with Listener(ip_address) as listener:
curr_time = time.time()
# only update graph every 10th of a second just cuz it doesn't matter for us, and it's easier on the computer
if curr_time - prev_time > 0.1:
packet = listener.get()
# note, we're negating z so the map will appear int he same orientation as it does in the game's minimap
x, z = packet.position.x, -packet.position.z
if px is not None:
# here we're adding 3 points on top of each other so that the final point will have the correct coloring for the car's speed range.
# we're plotting (min speed, max speed, current speed) and matplotlib will adjust the color map so that the final (current speed)
# color is accurate
plt.plot([px, x], [pz, z], s=1)
# pause for a freakishly shot amount of time. We need a pause so that it'll trigger a graph update
plt.pause(0.00001)
px, pz = x, z
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file granturismo-0.0.7.tar.gz
.
File metadata
- Download URL: granturismo-0.0.7.tar.gz
- Upload date:
- Size: 12.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c9a1ef7a3142883aaf3ee20bc28e2387b8fc4df7f24b7002a671184f6607e34a |
|
MD5 | 0923e13a69787717b61154d9b8baed5b |
|
BLAKE2b-256 | ab336e4272ef607bfcc6b4aac1c6a75db196e8dc3760ece99cd2f1b47e90aa69 |
File details
Details for the file granturismo-0.0.7-py3-none-any.whl
.
File metadata
- Download URL: granturismo-0.0.7-py3-none-any.whl
- Upload date:
- Size: 12.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2cfd7db08a68a3bbd5d6c122073ff393f5e8dfb766d5867d1b9e0446c0af5583 |
|
MD5 | 7f0687cb224ee9ce82ca640224d6962b |
|
BLAKE2b-256 | a117b2559f03377dc28845b9023c00e0137b0a2633be61933eae1fd3e9c1b4b2 |