Calibrate ESC
Automated ESC (Electronic Stability Control) calibration tool that iterates through vehicle configs and runs measurement tests.
Automated ESC (Electronic Stability Control) calibration tool that iterates through vehicle configs and runs measurement tests.
Overview
util_calibrateESC automates ESC calibration by loading each vehicle configuration on a test level, spawning the vehicle, and running the vehicle-side escMeasurement extension. Uses the job system for async operation with watchdog timeouts.
Extension path: lua/ge/extensions/util/calibrateESC.lua
Exports (M)
| Function | Signature | Description |
|---|---|---|
onInit | () | Logs initialization. |
onExtensionLoaded | () | Sets physics speed to 2x, loads blacklist. |
onExtensionUnloaded | () | Logs unload. |
vehicleDone | () | Called by vehicle-side code to signal test completion. |
heartbeat | () | Called by vehicle-side code to reset the watchdog timer. |
onClientStartMission | (levelPath) | Marks the level as ready when the test level is loaded. |
work | (pcFile, vehicle) | Starts the calibration process for a given config/vehicle. |
Internals
Test Pipeline
work(pcFile, vehicle)is called with optional filters.- If the test level (
/levels/smallgrid/info.json) is not loaded, it loads it. - A job system coroutine iterates through all vehicle configs:
- Filters by
vehicleToTestandpcFileToTestif specified. - Skips configs in
vehicleBlacklist. - Skips configs that already have a
.touchedinfo file.
- Filters by
- For each config:
- Replaces the current vehicle with
core_vehicles.replaceVehicle(). - Waits for the new vehicle to appear.
- Positions it at origin
(0, 0, 0.5). - Loads and runs
escMeasurement.performTests()on the vehicle. - Waits until
moveNextis set, watchdog triggers (20s no heartbeat), or max runtime (10M ms) exceeded.
- Replaces the current vehicle with
Blacklist
Loaded from blacklist.json or blacklistDefault.json at extension load. Vehicles in the blacklist are skipped entirely.
Watchdog
The vehicle-side code must call heartbeat() periodically. If no heartbeat arrives within 20 seconds, the test is aborted and moves to the next config.
How It Works
- Load the extension and call
work()with optional filters. - The system loads the smallgrid test level.
- Each config is tested sequentially via the job system.
- The vehicle-side
escMeasurementextension performs the actual tests. - Results are written as
.touchedfiles to prevent re-testing. - After all configs, the game shuts down with
shutdown(0).
Lua Examples
-- Run calibration on all vehicles
extensions.util_calibrateESC.work()
-- Run calibration for a specific vehicle
extensions.util_calibrateESC.work(nil, "pickup")
-- Run calibration for a specific config
extensions.util_calibrateESC.work("sport_config", "pickup")
-- Vehicle-side heartbeat (called from escMeasurement)
extensions.util_calibrateESC.heartbeat()
extensions.util_calibrateESC.vehicleDone()Additional Exports
M.heartbeat- (undocumented)M.onClientStartMission- (undocumented)M.onExtensionLoaded- (undocumented)M.onExtensionUnloaded- (undocumented)M.onInit- (undocumented)M.vehicleDone- (undocumented)M.work- (undocumented)