Commit Graph
1430 Commits
Author SHA1 Message Date
Andrew Tridgell b1b18460f7 AP_Scripting: decode wide IDs and independent header targets
Support the widened mavlink_message_t layout and reconstruct CRCs for independent source-width and targeting flags. Share PARAM_SET header decoding so consumers use the correct layout threshold. Retain older layouts and test flag combinations, reduced payload storage and invalid frames.
2026-09-27 09:33:18 +10:00
Clyde McQueen 51cd2dd1c0 AP_Scripting: avoid divide by zero in Lua script 2026-09-12 19:46:43 -03:00
Peter BarkerandClaude Opus 5 805fa9f8d0 AP_Scripting: integrate the elapsed time in the GAT example
guided_above_terrain_posvelaccel_sub.lua integrates its position target
forward by the time since the last callback.  When a callback arrived
later than 2/RUN_HZ it substituted 1/RUN_HZ for the real interval:

    if (dt > 2.0 / RUN_HZ) then
        dt = 1.0 / RUN_HZ
    end

so a callback 243ms late advanced the target by 50ms and the remaining
193ms was discarded.  The position target then falls behind the clock,
and the vehicle - which tracks that target accurately - covers less
ground than the commanded speed implies.

Measured from a failing Sub.GuidedAboveTerrain run under autotest at
--parallel=16, over the 60 simulated seconds the test watches:

    GUIP updates      1047 at 17.2Hz (nominal 20Hz)
    late callbacks    76 of 1047 (7.3%), worst 243ms
    time discarded    5.82s, so 55.08s integrated of 60.90s elapsed
    distance          27.90m of an expected 30.00m, +-1.00m -> failed

The dataflash shows the loss is upstream of the controller, not in it:
the script commanded 0.495m/s and the position controller achieved
0.442m/s against a desired 0.443m/s - it tracked what it was given to
within 0.001m/s, and what it was given was slow.

Cap the step at a fixed MAX_DT instead, so ordinary jitter is
integrated honestly and only a real stall is bounded.  Pinning the
simulation speedup was tried first and is not a fix: at
context_set_speedup(10) the run still lost ground, reaching 28.93m,
because it reduces how often callbacks are late without changing what
happens when they are.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-08 10:34:59 +10:00
Thomas Watson 720771a723 AP_Scripting: Revert "Reduce lua stack usage"
This reverts commit 6e7367b86f.

These reductions reduce the usage of the Lua stack, which is stored in
the heap. This reverts back to the stock Lua values; some complex
scripts may desire extra locals. There is some increased risk of memory
fragmentation and so forth but presumably such scripts are prepared.

The actual C stack depth can be limited by `LUAI_MAXCCALLS`.
2026-09-08 09:26:50 +10:00
Andrew Tridgell 038fbbfed7 AP_Scripting: remove CANF logging options from CAN drivers
Every CAN driver had grown its own option bit to log raw frames as CANF
messages. That is now redundant: CAN_Pn_OPTIONS bit 0 (LogAllFrames)
logs every frame on the bus, and unlike the script option it covers
transmitted frames as well as received ones, as the logging callback is
run from both CANIface::receive() and CANIface::send().

Removed the option and its logging from BattMon_ANX, EFI_HFE,
EFI_Halo6000, EFI_NMEA2k and UltraMotion, and dropped the CAN_logger
example, which did nothing else.

BATT_ANX_OPTIONS, EFI_HFE_OPTIONS, EFI_H6K_OPTIONS and EFI_2K_OPTIONS
had no other bits defined, so those parameters are gone. UM_OPTIONS
keeps ParseTelemetry and SendPosAsNamedValueFloat at their existing bit
positions.
2026-09-04 11:11:33 +10:00
Andrew Tridgell 5535228454 AP_Scripting: add disarmed heap expansion option 2026-09-02 15:58:06 +10:00
Clyde McQueen 0dbad6eda0 AP_Scripting: add poscontrol to Sub, provide test helper 2026-08-31 19:59:47 -03:00
Iampete1 55c09f57f8 AP_Scripting: bindings: RangeFinder: update range check on setting rangefinder state 2026-08-26 17:54:30 +10:00
Andrew Tridgell c03653fb41 AP_Scripting: add CircuitStatus DroneCAN battery driver
maps uavcan.equipment.power.CircuitStatus circuits onto scripting
battery monitor instances, giving per-circuit voltage and current
monitoring from CAN power distribution nodes
2026-08-20 10:35:46 +10:00
Peter Barker 276c1338fb AP_Scripting: correct '#endif // COMMENT' comments
these should always match the opening #if
2026-08-04 11:59:14 +10:00
Peter BarkerandClaude Fable 5 8a0f0c1e4c AP_Scripting: nest parameter names one level below Parameters headings
Parameter-name headings in the driver and applet markdown docs were at
the same level as the "Parameters" heading they sit under, so they
rendered as siblings rather than being nested within that section.
Demote them one level throughout.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-03 08:16:58 +10:00
Peter Hall 7668c24104 AP_Scripting: add airspeed driver bindings 2026-07-29 20:16:37 +01:00
Peter Barker ff67931891 AP_Scripting: use ahrs:get_wind in examples and applets
ahrs:wind_estimate() is deprecated.  Scripts which already checked the
returned value for nil now get a check which actually means something;
the rest fall back to a zero wind vector, which is what they were
already getting from an invalid estimate in most cases.
2026-07-28 13:48:28 +10:00
Peter Barker cb74bdbe83 AP_Scripting: deprecate ahrs:wind_estimate binding
ahrs:get_wind() should be used instead.  The generator can not attach a
deprecation warning to a manual binding, so the warning is emitted from
the binding itself in the same manner as the generated bindings do it.
2026-07-28 13:48:28 +10:00
Peter Barker 9d9b5c5436 AP_Scripting: add ahrs:get_wind binding
Unlike ahrs:wind_estimate() this returns nil when the vehicle has no
valid wind estimate, rather than handing out a vector which may be zero
or stale.
2026-07-28 13:48:28 +10:00
Peter Barker 630372253a AP_Scripting: add manual binding for ahrs:wind_estimate
The Vector3f-returning AP_AHRS::wind_estimate() method is about to be
removed from the AHRS interface.  Scripting has no way of receiving
both the vector and the validity flag from AP_AHRS::get_wind(), so
provide the old shape as a compatibility binding here rather than
keeping a method in AP_AHRS purely for scripting's benefit.

No change to the Lua API.
2026-07-28 13:48:28 +10:00
Andy Piper 746e90cc18 AP_Scripting: exclude OSD bindings from AP_Periph builds
pre-commit / ci (push) Canceled after 0s
test scripts / build (astyle-cleanliness) (push) Canceled after 0s
test scripts / build (check_autotest_options) (push) Canceled after 0s
test scripts / build (logger_metadata) (push) Canceled after 0s
test scripts / build (param-file-validation) (push) Canceled after 0s
test scripts / build (param_parse) (push) Canceled after 0s
test scripts / build (python-cleanliness) (push) Canceled after 0s
test scripts / build (shellcheck) (push) Canceled after 0s
test scripts / build (validate_board_list) (push) Canceled after 0s
test scripting / test-scripting (push) Canceled after 0s
AP_Periph does not build AP_OSD, but OSD_ENABLED defaults to 1 so the
generated bindings failed to link with undefined references to
AP_OSD::_singleton
2026-07-24 11:22:29 +01:00
Iampete1 2bb996f4b1 AP_Scripting: add OSD example 2026-07-24 11:22:29 +01:00
Andy PiperandIampete1 584007f865 AP_Scripting: add OSD bindings and add semaphore protection for scripting bindings
Co-Authored-By: Iampete1 <iampete@hotmail.co.uk>
2026-07-24 11:22:29 +01:00
Andy PiperandIampete1 af61458600 AP_Scripting: generator: add get keyword for custom pointer string
Co-Authored-By: Iampete1 <iampete@hotmail.co.uk>
2026-07-24 11:22:29 +01:00
Andrew Tridgell b7ba8bca02 AP_Scripting: added actuator (ESC/Servo) chirp tool
used for measuring response bandwidth of a servo or ESC
2026-07-19 10:51:28 +10:00
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
Yuri Rage 4eabe72949 AP_Scripting: add is_crashed binding and applet 2026-07-07 08:33:58 +09:00
Iampete1 419538c761 AP_Scripting: applets: revert_param: add new fixedwing params to revert list 2026-07-07 00:29:57 +01:00
Randy Mackay 628db8cef0 AP_Scripting: failsafe detector example script 2026-07-03 17:23:55 -04:00
Marek S. Łukasiewicz 808b0d4f26 AP_Scripting: fix typo in parameter name in EFI driver docs 2026-07-03 16:24:36 +01:00
Pierre Kancir 9f5c45853e Tools: add LoggedNamedValueInt test 2026-06-27 08:07:35 +10:00
Ben ButterworthandPierre Kancir 81f23dbd75 AP_Scripting: add send_named_int function
Co-authored-by: Pierre Kancir <pierre.kancir.emn@gmail.com>
2026-06-27 08:07:35 +10:00
Andrew Tridgell 48644320dc AP_Scripting: revert_param: cover MOT_THST_EXPO and Q_M_THST_EXPO
pre-commit / ci (push) Has been cancelled
test scripts / build (astyle-cleanliness) (push) Has been cancelled
test scripts / build (check_autotest_options) (push) Has been cancelled
test scripts / build (logger_metadata) (push) Has been cancelled
test scripts / build (param-file-validation) (push) Has been cancelled
test scripts / build (param_parse) (push) Has been cancelled
test scripts / build (python-cleanliness) (push) Has been cancelled
test scripts / build (shellcheck) (push) Has been cancelled
test scripts / build (validate_board_list) (push) Has been cancelled
test scripting / test-scripting (push) Has been cancelled
This is useful when adjusting expo, allowing quick revert if becomes unstable
2026-06-21 16:42:23 +10:00
Pierre Kancir f9f4726ca4 AP_Scripting: update how generate docs 2026-06-17 14:36:22 +10:00
George Zogopoulos 7a88dc9835 AP_Scripting: Typo fix 2026-05-26 22:31:38 +10:00
George Zogopoulos c563caea6d AP_Scripting: EFI_DLA64: Fix temperature unit conversion 2026-05-26 22:31:38 +10:00
Iampete1 6883ccd2be AP_Scripting: add callback time test script 2026-05-19 10:53:31 +10:00
Iampete1 6c38e1b981 AP_Scripting: never try and delay for more than 65535ms 2026-05-19 10:53:31 +10:00
Andrew Tridgell c2e42377ce AP_Scripting: added example sending ADSB_VEHICLE
this is a useful example showing how to display an ADSB icon on the
GCS from lua. It also shows how to send mavlink messages with
string.pack()
2026-04-27 10:19:02 +01:00
Huibean 0deb22662c AP_Scripting: follow-target-send: guard poscontrol nil on non-Copter/Heli vehicles 2026-04-27 10:47:31 +10:00
Huibean ed7e99103d AP_Scripting: LTE modem: fix AP hot reboot can not process previous active connection 2026-04-24 14:30:20 +10:00
Peter Barker 664c3ebd22 AP_Scripting: correct spelling errors in markdown files 2026-04-20 19:25:51 +10:00
Peter Barker ded4eb6c95 AP_Scripting: correct URLs in markdown files 2026-04-20 19:25:51 +10:00
Peter Barker 6dd6c4e1c2 AP_Scripting: examples: copter-circle-speed.lua: parameterise groundspeed 2026-04-19 10:36:57 +10:00
Christian Clauss 3df6c1bc79 AP_Scripting: support Lua 5.2+ in luacheck test 2026-04-13 20:33:22 +01:00
Peter Barker 1d8b63e462 AP_Scripting: correct warning in mavlink_attitude.lua
Checking libraries/AP_Scripting/modules/mavlink_attitude.lua 2 warnings

    libraries/AP_Scripting/modules/mavlink_attitude.lua:37:43: used variable _max_lag_ms with unused hint
    libraries/AP_Scripting/modules/mavlink_attitude.lua:37:56: used variable _convergence_loops with unused hint
2026-04-13 15:42:42 +01:00
Peter Barker f965d4c7fa AP_Scripting: make mount-driver.lua angles-only
we can have the C++ code make the conversions, so let it
2026-04-07 10:44:42 +10:00
Peter Barker 13ab85a5af AP_Scripting: allow script-defined gimbals to specify target types
this allows a script which converts ArduPilot targets into a wire protocol to send to a gimbal to tell ArduPilot what sorts of targets the script/gimbal can understand.

For example, if the gimbal being controlled can understand a lat/lng/alt, the script can tell ArduPilot that with the new method call.
2026-04-07 10:44:42 +10:00
Bob Long a9f14a868e AP_Scripting: fill in mount in docs.lua 2026-04-07 10:44:42 +10:00
Iampete1 124ebedfca AP_Scripting: fix language check issues 2026-04-04 09:29:55 +11:00
Randy Mackay 3e40de50b1 AP_Scripting: hobbywing datalink link fix 2026-04-03 15:25:15 +09:00
Bob Long 4bae7f6adf AP_Scripting: add mount-driver example 2026-04-02 15:46:16 +09:00
Tim Tuxworth d887c36143 AP_Scripting: plane_follow.lua fix crosstrack oscillation 2026-03-29 08:40:05 +11:00
Tim Tuxworth ca69d64f4e AP_Scripting: plane_follow.lua fix sendtext error if no target vehicle 2026-03-27 22:47:24 +11:00