Skip to content

AP_Mount: fix scripting backend#32382

Open
robertlong13 wants to merge 1 commit intoArduPilot:masterfrom
robertlong13:pr/fix-ap-mount-scripting-backend
Open

AP_Mount: fix scripting backend#32382
robertlong13 wants to merge 1 commit intoArduPilot:masterfrom
robertlong13:pr/fix-ap-mount-scripting-backend

Conversation

@robertlong13
Copy link
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

// return angles if target type is ANGLE, or if the target type was
// converted to angles because it is not natively supported
if (mnt_target.target_type == MountTargetType::ANGLE ||
(!natively_supports(mnt_target.target_type) && natively_supports(MountTargetType::ANGLE))) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The angles are only valid when type is angle.

If you need to cache values - have AP_Mount_Scripting scribble down the angles that are thrown at it by send_target_to_gimbal.

I think I probably broke this, so if you can give me a way to reproduce I'm happy to take it on.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These angles are actually fresh and valid if the backend has to convert the target into a target angle, so the check I have here the native modes actually does guarantee these angles are fresh and valid.

Scribbling down the angles was the first approach I was taking, but then we need to add a new, slightly different getter, and we need to update any scripts out there that use this function to instead use the new one. This fix has the advantage of not needing any update like that.

To test yourself, see the PR I linked. You don't technically need ReafFlight to test it; should work fine headless.

That said, sounds like this needs more discussion than quick review. I'll bring to the next dev call.

@peterbarker
Copy link
Contributor

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

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.

2 participants