Skip to content

AP_Mount: fix scripting backend#32382

Closed
robertlong13 wants to merge 3 commits into
ArduPilot:masterfrom
robertlong13:pr/fix-ap-mount-scripting-backend
Closed

AP_Mount: fix scripting backend#32382
robertlong13 wants to merge 3 commits into
ArduPilot:masterfrom
robertlong13:pr/fix-ap-mount-scripting-backend

Conversation

@robertlong13
Copy link
Copy Markdown
Contributor

@robertlong13 robertlong13 commented Mar 6, 2026

Summary

This fixes a 4.7 regression. Scripting backend gimbals don't respond to anything but angle commands.

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

Scripting backends, like mount-djirs2-driver.lua, differ from the others in that they can't have their target angles pushed to them. They rely on hitting up get_angle_target to know what to do, and get_angle_target returns nil unless we're in angle mode. The fix is to have get_angle_target work if we are either in angle mode, or we have converted to an angle target for a gimbal; either case means there's a valid angle target that we can return.

The only other caller of this getter is logging, and I think this is an improvement there too.

Tested against my RealFlight gimbal backend #27752

Comment thread libraries/AP_Mount/AP_Mount_Backend.cpp Outdated
@peterbarker
Copy link
Copy Markdown
Contributor

Robert and I discussed this at length on a call. Hope to discuss this at DevCallEU.

@robertlong13 robertlong13 force-pushed the pr/fix-ap-mount-scripting-backend branch from 801cd83 to ceb7523 Compare March 17, 2026 06:10
@robertlong13
Copy link
Copy Markdown
Contributor Author

robertlong13 commented Mar 17, 2026

I have reworked this slightly from my previous method. Before, I was using (!natively_supports(mnt_target.target_type) && natively_supports(MountTargetType::ANGLE)) as an implicit check for whether the target has been converted to an angle, which currently works but is fragile and non-obvious. I've instead added an explicit flag for whether the target was converted to angle. Eventually, if we start converting to other target types, like rate, we'll need another flag, or a separate enum for "converted to", but I chose this because it's the simplest, most-obvious patch for a backport.

I've also made scripting backends default to NATIVE_ANGLES_AND_RATES_ONLY, because this is actually what's needed by the only existing in-tree scripting backend: mount-djirs2-driver.lua. This is also appropriate for any out-of-tree backend that worked in 4.6 (I had to manually integrate rates to angles for an angle-only scripting backend). After this gets merged, I'll add a new binding for scripting backends to set their supported modes, which will reduce the need for that boilerplate and also allow people to make scripting backends that send native location targets if they want.

I've also added an autotest.

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
@robertlong13 robertlong13 force-pushed the pr/fix-ap-mount-scripting-backend branch from ceb7523 to 37036b3 Compare March 17, 2026 06:24
@rmackay9
Copy link
Copy Markdown
Contributor

@peterbarker will review this one

@peterbarker
Copy link
Copy Markdown
Contributor

@peterbarker will review this one

I've provided an alternative to this in a branch to @robertlong13 - where we don't have to munge the library structure to satisfy scripting....

@rmackay9
Copy link
Copy Markdown
Contributor

rmackay9 commented Apr 2, 2026

We've merged PR #32626 so I think it's OK to close this one. Thanks very much for addressing this 4.7 issue!

@rmackay9 rmackay9 closed this Apr 2, 2026
@github-project-automation github-project-automation Bot moved this to Pending in 4.7 Backports Apr 2, 2026
@robertlong13 robertlong13 deleted the pr/fix-ap-mount-scripting-backend branch April 2, 2026 06:54
@rmackay9 rmackay9 removed this from 4.7 Backports May 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants