fix gimbal driver for mavlink gimbal v2 input and AUX output #22768
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.
Controlling the gimbal when the gimbal driver was configured to mavlink gimbal v2 input and AUX output was not working. PX4 would never send out the gimbal manager information when requested.
The actual issue I was chasing was that our GCS (based on QGC) would always switch to mavlink gimbal v1 when the gimbal configuration in PX4 was mavlink gimbal v2 as input and AUX (pwm) as output. This was then causing other side effects that are not relevant in this PR.
The main problem was that during initial negotiation the GCS would request the gimbal_manager_information as specified in the gimbal v2 discovery protocol: https://mavlink.io/en/services/gimbal_v2.html#discovery-of-gimbal-manager
If no response came back the GCS would assume we were using the v1 gimbal protocol, while if the message came in the GCS would use gimbal v2.
The gimbal_manager_information stream is implemented in PX4 so it would try to respond to the message_request but it would fail because the gimbal_manager_info uorb topic was never published by the gimbal driver.
Steps:
The reason why the gimbal driver would never publish this message is because of this check:
https://github.com/Auterion/PX4_firmware_private/blob/45c756efda1e3dfa9a33d74a2b0577f956c4c32a/src/modules/gimbal/input_mavlink.cpp#L582
Basically what it's saying is that if there is no change in the gimbal device compid it will never publish this message. In our case we don't have a gimbal device when using AUX output so the gimbal device compid was kept to 0 as it was initialized.
Solution
When the gimbal output is set to AUX we still need to "fake" a gimbal device (as we already do in the payload manager). To do this I think the best idea is for both the gimbal device and gimbal manager to have the same compid as the autopilot. This respects the protocol and makes AMC happy.
Changelog Entry
For release notes:
Test coverage
Manually tested with a pwm servo gimbal on an fmu-v5x