Files
ardupilot/libraries/AP_Scripting/examples
Peter BarkerandClaude Opus 4.8 5810830961 AP_Scripting: retry stale reads in rangefinder_quality_test
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>
2026-07-07 09:59:00 +10:00
..
2024-08-06 14:03:27 +10:00
2024-10-01 10:45:10 +10:00
2025-09-29 16:20:10 +10:00
2024-08-06 14:03:27 +10:00

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.