ac-telemetry-plugin/README.md
Jan-Peter v. Hunnius 3900d2a6b2 feat: initial AC telemetry Lua plugin
- CSP Lua app that reads telemetry via ac.* API
- Sends JSON over UDP to configurable target (default 127.0.0.1:5005)
- Purpose-built serializer with zero GC pressure at 60Hz
- Pre-allocated buffer tables, no per-frame allocations
- Graceful fallback when ac global is absent (testing outside AC)
- .gitignore for .idea/
2026-06-01 15:13:18 +02:00

70 lines
2.4 KiB
Markdown

# ACTelemetry
A Custom Shaders Patch (CSP) Lua application for Assetto Corsa that reads car telemetry data via the CSP Lua API and sends it as JSON over UDP.
## What It Does
The plugin runs inside Assetto Corsa under Proton/Linux. It collects telemetry at 60 Hz from the CSP Lua API and broadcasts a JSON datagram to a configurable UDP endpoint each frame (throttled to the configured rate).
## Installation
Copy the entire `ac-telemetry-plugin` directory into your CSP Lua apps folder:
```
<Assetto Corsa root>/extension/lua/apps/
```
Enable the app in the CSP in-game app launcher.
## Configuration
Edit `config.lua` to set the target UDP endpoint:
```lua
local config = {
target_host = "127.0.0.1", -- UDP receiver IP
target_port = 5005, -- UDP receiver port
send_interval = 1 / 60, -- 60 Hz send rate
}
```
## JSON Format
Each UDP datagram contains a JSON object with the following schema (sent to `target_host:target_port`):
```json
{
"timestamp": 1716123456.789,
"speed_kmh": 245.3,
"rpm": 8750,
"gear": 6,
"throttle": 0.85,
"brake": 0.0,
"steering": 0.12,
"g_forces": { "x": 0.5, "y": -0.2, "z": 1.0 },
"wheel_slip": [0.1, 0.1, 0.0, 0.0],
"suspension_travel": [0.15, 0.14, 0.16, 0.15],
"lap_time": 85.234,
"lap_count": 5
}
```
| Field | Type | Description |
|--------------------|------------------|------------------------------------|
| `timestamp` | number | `os.clock()` time |
| `speed_kmh` | number | Car speed in km/h |
| `rpm` | number | Engine RPM |
| `gear` | number | Current gear |
| `throttle` | number | Throttle input (0.0 - 1.0) |
| `brake` | number | Brake input (0.0 - 1.0) |
| `steering` | number | Steering input (-1.0 - 1.0) |
| `g_forces` | object | G-forces: `x`, `y`, `z` |
| `wheel_slip` | array[4] | Per-wheel slip (FL, FR, RL, RR) |
| `suspension_travel`| array[4] | Per-wheel suspension travel |
| `lap_time` | number | Current lap time in seconds |
| `lap_count` | number | Completed lap count |
## Dependencies
- CSP (Custom Shaders Patch) with Lua support
- LuaSocket (bundled with CSP)