inputTests¶
File: lua/vehicle/extensions/inputTests.lua · VM: Vehicle · 480 lines · BeamNG.drive 0.40.5 (buildbot 302427 on GitLab)
Access: extension inputTests: extensions.load (vehicle VM)("inputTests"), then the global inputTests
Test bench for latency and accuracy of steering wheel force feedback (FFB): measures USB hardware latency, wheel resolution and update frequency, simulation engine latency and vehicle latency, as well as steering oscillations. The tests run in a coroutine called by hydros via hydros.testHook; the results (statistics, 30-bucket histograms) are sent to the GE by the onInputTestStats hook, and the end by onInputTestStatus.
Example¶
extensions.inputTests.start('systemTest')
-- tests: systemTest, simulationTest, vehicleTest, vehicleOscillationTest
Notes¶
- Available tests (30 measurements each): 'systemTest' (results systemFrequencyTest, systemResolutionTest, systemLatencyTest: direct wheel measurements via hydros.getAngleFunction / getForceFeedbackFunction), 'simulationTest' (engineLatencyTest: FFB pulse until the simulated wheel moves, FFB computation disabled), 'vehicleTest' (vehicleLatencyTest: torsion pulse on the tread nodes of wheels whose name starts with 'F'), 'vehicleOscillationTest' (oscillationTest and vehicleFrequencyTest, with FFB force reduced to 10%).
- start(testId) requires a valid FFB id (hydros.getFFBID() >= 0), otherwise it sends empty statistics with an error message.
- The statistics sent contain: testId, sampleCount, unit, value (half-sample mode, or maximum for systemResolutionTest), modeError / modeErrorLow / modeErrorHigh, buckets (count, min, max), bucketPeakCount and optionally message. Latencies are converted to ms.
- Timings use the wall clock (os.clockhp), not simulation time.
- Constants: latency timeout 0.5 s, wheel considered stopped after 0.15 s (timeout 7 s), tread torsion force 5000 on the 5 lowest nodes.
- An internal error in the coroutine is logged, disables hydros.testHook and sends a failure message to the GE.
Functions¶
| Function | Description | Line |
|---|---|---|
inputTests.onExtensionUnloaded() |
Called on unload: removes hydros.testHook. (internal) (hook) | 478 |
inputTests.start(testId) |
Starts a test: fetches the FFB id, creates the coroutine and installs M.update in hydros.testHook. | 463 |
inputTests.update(dtSim, simWheelPos, hydroPos) |
Called by hydros at each FFB step via testHook: resumes the test coroutine with the real dt (wall clock) and the simulated and hardware wheel positions. Returns whether the normal FFB computation must run and the next hardware position. (internal) | 34 |
Parameter details¶
inputTests.start(testId)¶
Starts a test: fetches the FFB id, creates the coroutine and installs M.update in hydros.testHook.
testId(string) : 'systemTest', 'simulationTest', 'vehicleTest' or 'vehicleOscillationTest'.
inputTests.update(dtSim, simWheelPos, hydroPos)¶
Called by hydros at each FFB step via testHook: resumes the test coroutine with the real dt (wall clock) and the simulated and hardware wheel positions. Returns whether the normal FFB computation must run and the next hardware position.
dtSim(number) : Simulation time step (used only on the first call).simWheelPos(number) : Simulated wheel position (normalized, -1 to 1 inferred from code).hydroPos(number) : Target position of the hardware wheel.- returns: boolean true to run the vehicle FFB computation this step.
- returns: number Hardware position to apply next.
Calls into the engine (C++)¶
obj:applyForceVector,getNodePosition,queueGameEngineLua
tim19Atlas (Tim0219800) — derived from BeamNG GmbH Lua code (bCDDL 1.1, see LICENSE). Source: lua/vehicle/extensions/inputTests.lua.