Skip to content

Correct mount script backend functionality - #32626

Merged
rmackay9 merged 5 commits into
ArduPilot:masterfrom
peterbarker:pr/fix-ap-mount-scripting-backend
Apr 2, 2026
Merged

Correct mount script backend functionality#32626
rmackay9 merged 5 commits into
ArduPilot:masterfrom
peterbarker:pr/fix-ap-mount-scripting-backend

Conversation

@peterbarker

Copy link
Copy Markdown
Contributor

Summary

Replaces #32382 as a fix for a regression with scripting backend functionality.

Testing (more checks increases chance of being merged)

  • Checked by a human programmer
  • Tested in SITL
  • Tested on hardware
  • Logs attached
  • Logs available on request
  • Autotest included

Description

refactoring in the mount backend caused issues with the scripting backend.

This fixes those and adds some tests which Robert crafted.

Future PRs from Robert will include the ability for a script to specify what sorts of targets it accepts.

@peterbarker peterbarker changed the title Correct script backend functionality Correct mount script backend functionality Mar 31, 2026
robertlong13 and others added 5 commits April 1, 2026 18:41
Co-authored-by: Bob Long <robertlong13@gmail.com>
If a backend gets the target mode converted to angle, get_angle_target
will return the converted angles. This fixes scripting backends that
relied on get_angle_target
Scripting backends (e.g. mount-djirs2-driver.lua) poll get_angle_target()
and get_rate_target() rather than receiving pushed targets.  Before this
fix, get_angle_target() returned false for RETRACT, NEUTRAL, and LOCATION
modes because it only checked target_type == ANGLE, even though
send_target_to_gimbal() had already written the converted angle into
mnt_target.angle_rad.

Fix by calling send_target_to_gimbal() from AP_Mount_Scripting::update()
(matching every other backend) and implementing send_target_angles() to
stamp mnt_target.target_type = ANGLE after send_target_to_gimbal() has
written the converted value into mnt_target.angle_rad.  This makes
get_angle_target() return the converted value without any changes to the
base class.

Declare NATIVE_ANGLES_AND_RATES_ONLY so that RATE targets are not
converted to angles internally; the Lua script receives them via
get_rate_target() and performs its own integration.  send_target_rates()
is a no-op because mnt_target.target_type stays RATE, which is all
get_rate_target() checks.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ipting backend fully self-contained

get_angle_target() and get_rate_target() in AP_Mount_Backend and AP_Mount
are now declared and defined only when AP_SCRIPTING_ENABLED is set,
matching the existing treatment of get_location_target().

AP_Mount_Backend::write_log() read mnt_target directly when scripting is
not compiled in, avoiding the dependency on those methods.

AP_Mount_Scripting gains its own ScriptTargetType enum and
_angle_target/_rate_target members.  send_target_angles() and
send_target_rates() now store the pushed target into those members.
get_angle_target() / get_rate_target() overrides return the stored values,
removing the previous hack of stamping mnt_target.target_type = ANGLE
inside send_target_angles().  _script_target_type is reset to NONE at the
top of each update() cycle so stale targets are never returned.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@peterbarker
peterbarker force-pushed the pr/fix-ap-mount-scripting-backend branch from 9bae8af to 01bc954 Compare April 1, 2026 07:41
@rmackay9
rmackay9 merged commit 7ae671e into ArduPilot:master Apr 2, 2026
108 checks passed
@github-project-automation github-project-automation Bot moved this to Pending in 4.7 Backports Apr 2, 2026
@peterbarker
peterbarker deleted the pr/fix-ap-mount-scripting-backend branch April 3, 2026 23:11
@Georacer Georacer moved this from Pending to 4.7.0-beta3 in 4.7 Backports Apr 10, 2026
@Georacer Georacer mentioned this pull request Apr 10, 2026
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: 4.7.0-beta3

Development

Successfully merging this pull request may close these issues.

4 participants