AP_Mount: fix scripting backend#32382
Conversation
| // 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))) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
|
Robert and I discussed this at length on a call. Hope to discuss this at DevCallEU. |
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)
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_targetto know what to do, andget_angle_targetreturns nil unless we're in angle mode. The fix is to haveget_angle_targetwork 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