Correct mount script backend functionality - #32626
Merged
rmackay9 merged 5 commits intoApr 2, 2026
Merged
Conversation
rmackay9
approved these changes
Apr 1, 2026
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
force-pushed
the
pr/fix-ap-mount-scripting-backend
branch
from
April 1, 2026 07:41
9bae8af to
01bc954
Compare
This was referenced Apr 2, 2026
9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces #32382 as a fix for a regression with scripting backend functionality.
Testing (more checks increases chance of being merged)
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.