Commit Graph
1396 Commits
Author SHA1 Message Date
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
Willian Galvani e6b186e12d autotest: add test for AP_Motors6DOF
This test uses a normal, non-6dof frame, and validates that it is able to do a simple mission
2026-03-25 18:32:29 +11:00
Andy Piper f06b568151 AP_Scripting: return alt frame from safe alt fence bindings
Update get_safe_alt_min and get_safe_alt_max bindings to also return
the altitude frame as a second return value. Existing callers are not
broken as Lua silently discards extra return values.
2026-03-24 10:44:04 +11:00
Randy Mackay 23ee31d2b5 AP_Scripting: complete rename of param-lockdown applet 2026-03-20 12:46:45 +11:00
Randy Mackay c1094e4834 AP_Scripting: param-set applet renamed to param-lockdown 2026-03-20 12:46:45 +11:00
Tim Tuxworth 237b049f37 AP_Scripting: plane follow fix lowercase value in SIM_TLF_FN parameter 2026-03-20 09:34:08 +11:00
Andrew Tridgell 446ecaedb9 AP_Scripting: RTSP video relay example
shows relaying using TCP interleave between a RTSP camera and a RTSP
server such as mediamtx
2026-03-17 12:24:16 +13:00
Randy Mackay 2da686bb74 AP_Scripting: config_profiles example update for ATC rename 2026-03-04 20:00:01 +09:00
Randy Mackay f9fcf06c61 AP_Scripting: copter-deadreckon-home minor format fix 2026-02-24 14:50:55 +09:00
Randy Mackay c074cfbaf7 AP_Scripting: wall climber example update to use WP params 2026-02-24 14:50:55 +09:00
Randy Mackay 83d9c3abce AP_Scripting: copter-deadreckon update to use WP params 2026-02-24 14:50:55 +09:00
Peter Barker 04cbe9451a AP_Scripting: enclose _ and * not intended as markup in backticks
most markdown parsers will get this not-really-markup thing correct, but it can lead to inconsistencies.

Also fixes a few places where spaces had been introduced to avoid the underscores being considered markup!
2026-02-18 23:16:36 +11:00
Peter Barker f0767d24d3 AP_Scripting: remove dollar signs from bash blocks (MD014)
this will make copy/paste easier
2026-02-16 08:16:17 +11:00
Peter Barker faf3d5b2e1 AP_Scripting: fix trailing punctuation in markdown headers (MD026)
makes a lot of these headings consistent with other headings at the same level in these files!
2026-02-14 12:02:51 +11:00
Peter Barker 3849de2569 AP_Scripting: correct us of emphasis in place of headings (MD036) 2026-02-13 11:13:01 +11:00
Peter Barker 5630ed535b AP_Scripting: add type to code blocks
required by the linter, and allows renderers to do syntax highlighting
2026-02-12 19:31:55 +11:00
Peter Barker a402f8a882 AP_Scripting: correct MD001 in all markdown files (incorrect header levels) 2026-02-12 10:18:06 +11:00
Peter Barker b16a064207 AP_Scripting: fix MD041 (single # header at top of file) in all markdown 2026-02-12 10:18:06 +11:00
Iampete1 3b43db2e8d AP_Scripting: applets: plane package place: update Q_LAND_SPEED reference 2026-02-11 18:34:29 +11:00
Iampete1 ce6d78c653 AP_Scripting: Add bindings to allow updating servo telem 2026-02-10 10:21:16 +11:00
Peter BarkerandClaude Opus 4.6 f55940ad7d AP_Scripting: fix MD004 inconsistent unordered list style
Standardize on dash (-) for all unordered list markers.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-08 09:30:32 +11:00
Peter BarkerandClaude Opus 4.5 27be9675db AP_Scripting: convert bare URLs to proper markdown links
Fix MD034/no-bare-urls lint errors by converting bare URLs to proper
markdown link syntax [text](url). Link text is derived from the URL:
- GitHub repos use the repository name
- ArduPilot ecosystem URLs use descriptive names
- Vendor/product URLs use the vendor name
- Documentation sites include "documentation" suffix

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-07 15:38:01 +11:00
Peter Barker 1ed95f7fc1 AP_Scripting: fix MD025 (too few # in headings) in all markdown files 2026-02-07 07:36:26 +11:00
Peter Barker 88029b0673 AP_Scripting: replace HTML <table> with markdown tables 2026-02-04 21:51:36 +11:00
Peter BarkerandClaude Opus 4.5 7ceb7c31c7 global: fix whitespace issues in markdown files
global: fix MD007 unordered list indentation in markdown files

Normalize unordered list indentation to use 2-space multiples:
- Top-level list items start at column 0
- Nested list items use 2 additional spaces per level

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

global: fix MD009 trailing whitespace in markdown files

Remove trailing whitespace from all affected markdown files.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

global: fix MD010 hard tabs in markdown files

Replace hard tab characters with 4 spaces.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

global: fix MD012 multiple consecutive blank lines in markdown

Collapse multiple consecutive blank lines to single blank lines
across all markdown files (excluding vendored code).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

global: fix MD007 list indentation base level in markdown

Shift list indentation left by 2 spaces so top-level list items
start at column 0 instead of column 2.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Tools/scripts: fix MD022 blank lines around headings in markdown

Ensure headings are surrounded by blank lines as required by
markdownlint MD022 rule.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Tools/scripts: fix MD032 blank lines around lists in markdown

Ensure lists are surrounded by blank lines as required by
markdownlint MD032 rule.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Tools/scripts: fix MD031 blank lines around code blocks in markdown

Ensure fenced code blocks are surrounded by blank lines as required
by markdownlint MD031 rule.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Tools/scripts: fix MD047 files should end with single newline

Ensure all markdown files end with exactly one newline character
as required by markdownlint MD047 rule.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Tools/scripts: fix MD023 headings must start at beginning of line

Remove leading whitespace from heading lines as required by
markdownlint MD023 rule.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Tools/scripts: fix MD007 remaining list indentation in markdown

Fix unordered list indentation to use correct spacing as required
by markdownlint MD007 rule.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Tools/scripts: fix MD030 spaces after list markers in markdown

Reduce multiple spaces after list markers to single space as
required by markdownlint MD030 rule.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Tools/scripts: fix MD022 blank lines around setext headings

Ensure setext-style headings (underlined with === or ---) are
surrounded by blank lines as required by markdownlint MD022 rule.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Tools/scripts: fix MD018 missing space after hash in headings

Add space after hash marks in atx-style headings as required by
markdownlint MD018 rule.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Tools/scripts: fix MD019 multiple spaces after hash in headings

Reduce multiple spaces after hash marks to single space in
atx-style headings as required by markdownlint MD019 rule.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Tools/scripts: fix MD012 multiple consecutive blank lines in markdown

Remove multiple consecutive blank lines and ensure files end with
exactly one newline as required by markdownlint MD012 rule.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Tools/scripts: fix MD023 headings with leading whitespace

Remove leading whitespace from setext-style heading text lines
as required by markdownlint MD023 rule.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Tools/scripts: fix MD022 blank line after heading in markdown

Add missing blank line after heading as required by markdownlint
MD022 rule.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Tools/scripts: fix MD009 trailing non-breaking space in markdown

Remove trailing non-breaking space (U+00A0) as required by
markdownlint MD009 rule.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Tools/scripts: fix MD012 remaining multiple blank lines in markdown

Remove leading blank lines and whitespace-only lines that create
multiple consecutive blank lines.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 11:37:38 +11:00
Thomas Watson b996debd67 AP_Scripting: avoid leaking script on engine error during load
If Lua raises an error we won't ever link the new_script into the list
and won't find it to remove it and free its components later. The
components do ultimately get freed by the destruction of the heap, and
there's no way to access them after, but we'd rather it be empty and
know nothing is dangling.

This should be replaced by storing the components as Lua objects and
letting Lua's GC take care of them. That way the code could be made much
less fragile.

Also removes a chance of a leak in run_next_script.
2026-01-22 21:09:09 -06:00
Thomas Watson b0d93f0e16 AP_Scripting: simplify Lua abort handler
This should never be called so there's not much to be gained from a
panic message. If it is, the call should be identifiable by the internal
error line number.
2026-01-22 21:09:09 -06:00
Thomas Watson 79e591f947 AP_Scripting: remove Lua panic handler
Nominally cannot be called as we do not call error-raising Lua functions
outside of protected mode. In the event a panic happens somehow anyway,
Lua calls `lua_abort` which we already handle safely.
2026-01-22 21:09:09 -06:00
Thomas Watson 67860f11c0 AP_Scripting: run scripting engine in protected mode
Lua calls our registered panic function if a Lua error is raised outside
of any protected mode set up by `lua_pcall` and friends. As scripts
themselves are run in protected mode, such an error will only originate
from our engine code.

The current code handles panics, but does so incorrectly by neglecting
to free the error message buffer during a panic exit. As the underlying
heap is eventually destroyed and recreated, that static buffer pointer
is to a heap that no longer exists. If the new state raises an error it
will try to free that pointer, causing heap corruption and sadness.

Fix this issue and avoid similar ones by refactoring to run the main
part of the scripting engine in Lua protected mode. This creates exactly
one exit path from the scripting engine and avoids the need for fragile
panic handling infrastructure that duplicates what is built into Lua.
Quoth the Lua manual, "The panic function, as its name implies, is a
mechanism of last resort. Programs should avoid it."

This is unlikely to be triggerable in flight as the main engine loop
does not appear to use the Lua API in a way which can trigger errors.
But the possibility can't be fully excluded. It is, however, possible to
trigger beforehand using a perfectly wrong heap size that causes a
memory error during initialization.

Note that due to the error message buffer being freed properly now, an
error message originating from the engine will not cause a pre-arm
failure. This could be improved in the future.
2026-01-22 21:09:09 -06:00
Randy Mackay 71cf8dcb5c AP_Scripting: arming-checks update for copter RTL parms 2026-01-23 11:51:54 +11:00
Randy Mackay 71dee9460d AP_Scripting: config_profiles example uses new RTL params 2026-01-23 11:51:54 +11:00
Randy Mackay 8ede7673ba AP_Scripting: param-set example uses new RTL params 2026-01-23 11:51:54 +11:00
Thomas Watson 56005f8ca8 AP_Scripting: fix minor bug in repl applet
If `writechar` failed because the serial buffer was full, then `tx_buf`
could be nil and appending to it would fail. Fix by letting
`writestring` handle the work in this rare case.

Also bump the version to signify the fix.
2026-01-18 14:56:58 -06:00
Thomas Watson 7e777b6371 AP_Scripting: fix CRSF leaks and nullptr dereferences
There are several bogus error messages and checks that are removed.

This should probably be refactored to use ap_objects and avoid
reallocation of the underlying bits.
2026-01-07 08:56:01 -06:00
Peter Barker abf75c1831 AP_Scripting: improve definition of AP_SCRIPTING_BINDING_MOTORS_ENABLED 2026-01-06 10:37:48 +00:00