mirror of
https://github.com/ArduPilot/ardupilot.git
synced 2026-10-06 19:00:27 +08:00
The rangefinder_quality_test.lua example (driving the Sub RngfndQuality autotest) pushes a distance/quality/status through the scripting range finder driver interface, waits UPDATE_PERIOD_MS, then reads it back through the client interface and checks it matches. The value is copied from the driver state to the client-facing state by a periodic task on the main loop, which is a different thread to the scripting VM. Under host load (e.g. parallel autotest) or high SIM_SPEEDUP that copy can land after the read, so the client still reports the previous test's value and the script emits a spurious failure -- reproduced at --speedup=40, where the 28m test read back 27m and reported "#complete#: !!failure!!". Retry the read up to MAX_EVAL_RETRIES times (UPDATE_PERIOD_MS apart) before declaring a mismatch, so a slow cross-thread copy is waited out while a genuine mismatch still fails once the retries are exhausted. With this RngfndQuality passes 20/20 at --speedup=40 and 100 (was ~1 in 6 failing). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
LUA Examples
This directory contains some script examples. For simulation the scripts should be placed in the simulation's "scripts" directory located in the root directory from which the sim is run. Note: if an example uses auxillary files (mission list, other scripts,etc.) the user will have to determine where the files should be placed from the script. If no path name is specified in the file name, then it should be placed one directory level above the "scripts" directory.