Commit Graph
383 Commits
Author SHA1 Message Date
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
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
Clyde McQueen 0dbad6eda0 AP_Scripting: add poscontrol to Sub, provide test helper 2026-08-31 19:59:47 -03: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
Iampete1 2bb996f4b1 AP_Scripting: add OSD example 2026-07-24 11:22:29 +01: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
Randy Mackay 628db8cef0 AP_Scripting: failsafe detector example script 2026-07-03 17:23:55 -04:00
Pierre Kancir 9f5c45853e Tools: add LoggedNamedValueInt test 2026-06-27 08:07:35 +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
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
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
Iampete1 124ebedfca AP_Scripting: fix language check issues 2026-04-04 09:29:55 +11:00
Bob Long 4bae7f6adf AP_Scripting: add mount-driver example 2026-04-02 15:46:16 +09: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
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 c074cfbaf7 AP_Scripting: wall climber example update to use WP params 2026-02-24 14:50:55 +09: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 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 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 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
Randy Mackay 71dee9460d AP_Scripting: config_profiles example uses new RTL params 2026-01-23 11:51:54 +11:00
robot-to-society 3e7867ebd0 AP_Scripting: Add experimental Lua example for S.Bus-style serial output 2025-12-31 09:45:04 +09:00
Andrew Tridgell 92d6c292ca AP_Scripting: dynamic mixer example for X8 co-rotating frame 2025-12-02 11:16:21 +11:00
neo-0007 16a79f5554 AP_Scripting: add example script to test target location
Script to test location for all 7 modes of mount using the
AP_Scripting_Backend.

Signed-off-by: neo-0007 <hrishikeshgohain123@gmail.com>
2025-11-27 10:14:20 +11:00
Peter Barker 93f45acb45 AP_Scripting: rename airspeed methods on AHRS to include EAS or TAS
mixing these up has caused confusion in the past.

"estimate" could also be confused as to mean "synthetic", when it will often come from a sensor.
2025-11-17 18:46:52 -06:00
Stephen Dade d256a73ee7 AP_Scripting: Add Rockblock 9704 Lua script 2025-11-17 19:18:42 +11:00
Ryan Friedman 888456786d AP_Scripting: Add GPS switch script
* Use this script and an Aux switch to change the primary GPS for the
  EKF

Signed-off-by: Ryan Friedman <25047695+Ryanf55@users.noreply.github.com>
2025-11-04 09:48:56 +11:00
Bob Long 36b54e6e48 AP_Scripting: examples: add fake camera tracking 2025-10-24 13:54:38 +11:00
Randy Mackay 08eaef9fcb AP_Scripting: message_interval gets more messages 2025-10-19 18:11:42 +11:00
Thomas Watson da676fd438 AP_Scripting: fix gcs:set_message_interval port range
Despite the implications of the example and the
`MAVLINK_COMM_NUM_BUFFERS` limit in the description, the actual first
argument to this function is the serial port number.

Correct the argument range to allow any possible port number (no need to
limit as the list is sparse) and enhance the example to give more port
numbers.
2025-10-13 22:48:12 -05:00
Peter Barker 1fc015c5da AP_Scripting: add a script that changes vehicle between configurations
... different battery configurations, different payload configurations and different arm configurations
2025-09-30 09:42:32 +10:00
Valeriy Van af6d3b584a Plane: Fix typo 2025-09-29 16:20:10 +10:00
Iampete1 a0452ba1d4 AP_Scripting: examples: add TraxxasVelineon ESC telem script 2025-09-15 18:18:55 -05:00
Peter Barker 4e7e417dc3 AP_Scripting: add test for NAMED_VALUE_STRING 2025-08-10 08:38:08 +10:00
Peter Barker ae48665948 AP_Scripting: add example which prints checksum of @SYS/flash.bin 2025-07-23 10:50:55 +10:00
Peter Barker 1f8370b615 AP_Scripting: update scripts for get_roll->get_roll_rad rename 2025-06-05 17:28:41 +10:00
Ryan Friedman 03adf5e801 AP_Scripting: Add trisonica LI550 3D wind sensor logger
Signed-off-by: Ryan Friedman <25047695+Ryanf55@users.noreply.github.com>
2025-05-24 20:09:14 -05:00
Peter BarkerandRyan Friedman 2e414af057 AP_Scripting: correct use of pcall in examples and applets
Co-authored-by: Ryan Friedman <25047695+Ryanf55@users.noreply.github.com>
2025-05-17 08:16:52 +10:00
Andrew Tridgell 78d42fcf24 AP_Scripting: example of using DroneCAN messaging 2025-05-09 13:08:40 +10:00
Stephen Dade d0b310668c AP_Scripting: fix cast-local-type in Rockblock and MAVLinkHL 2025-04-29 17:21:00 +01:00
Iampete1 4e1457e86b AP_Scripting: temporarily ignore lua language server issues 2025-04-29 11:29:28 +10:00
Peter Barker bf8a9e5df4 AP_Scripting: add _cm to get_vector_from_origin_NEU
... and the _NE equivalent.

Moves us closer to using metres in interfaces.  Several places already *0.01 the result of these methods
2025-04-29 08:29:41 +09:00
Andrew Tridgell bd7e01dd36 AP_Scripting: added qnh_alt example
useful for BVLOS ops
2025-04-10 09:32:44 +10:00
Andy Piper fa36e5623d AP_Scripting: add CRSF menu bindings
add CRSF menu example
add scripted CRSF menu events
custom CRSFMenu helpers
play Beethoven's 5th on CRSF command
use native packed strings for CRSF menus and payloads
support CRSF submenus
2025-04-09 17:16:58 +10:00
Peter Barker 1f256707b5 AP_Scripting: adjust tooling to use MAV_SYSID 2025-04-07 10:58:41 +10:00
Andrew Tridgell f3506c6481 AP_Scripting: added gyro to set_pose 2025-04-02 07:05:04 +11:00