This is my first post (in many years), please redirect as appropriate!
Per MAVLINK definitions (e.g. MAV_CMD_DO_GIMBAL_MANAGER_PITCHYAW, among others) Gimbal_Device_ID==0 is for all gimbal device components.
In current master’s AP_Mount code, gimbal_device_id==0 is used to indicate the “primary” AP_Mount. IIUC, the _primary index indicates one of the “backends” (“instances”? “gimbals”?) but not all of them.
This looks like a bug. Can someone more experienced take a look to see if I misunderstood something?
[Related Info]
I see that Mount/Gimbals are an area of active improvement (issue list) but did not notice this one.
Attempting a delve into the source history, perhaps this implementation came originally from this PR (for vis author: @peterbarker reviewer: @rmackay9 ).
I found this from starting on this issue, where I see instructions to implement-the-same-way with the new stuff. That gives me a nice path forward: Simply do things the same way (bug or not) to unblock on solving the issue, but also ask for inspection (via this post) from more experienced devs.
If confirmed as a bug, perhaps I could contribute the fix? But it would involve a behavior change, and I’m guessing that’s a more involved review + testing workload. So I would definitely want to collaborate with someone more experienced.
Thanks for the ping. Yes we should change the behaviour so that “0” is all gimbals instead of just the primary.
When thinking about the change in behaviour we need to remember that this command is used in two ways:
users use the MP “payload” screen to control the gimbal
as part of the Auto mode command list
In both cases the default value for the gimbal id field will be zero so we should make sure that the default behaviour will be good for most users.
Most users won’t have two gimbals so regardless of what we do, most users will be unaffected. For those that do have two gimbals, interpreting “gimbal id = 0” as all gimbals means that the GCS gimbal control screen (e.g. the payload screen in MP) will cause all gimbals to move. This won’t be good for users so in addition to changing the flight code we should also modify the MP screen so that it either always sends the gimbal id as “1” or we need to add a drop-down to allow users to select the gimbal they want to control.