Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix gimbal driver for mavlink gimbal v2 input and AUX output #22768

Merged
merged 1 commit into from
Feb 27, 2024

Conversation

DanielePettenuzzo
Copy link
Contributor

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:

Feature/Bugfix XYZ
New parameter: XYZ_Z
Documentation: Need to clarify page ... / done, read docs.px4.io/...

Test coverage

Manually tested with a pwm servo gimbal on an fmu-v5x

thread_data.control_data.device_compid = 0;
// If the output is set to AUX we still want the input to be able to control the gimbal
// via mavlink, so we set the device_compid to 1. Basically in this configuration both
// gimbal manager and gimbal device have the same component ID as the autopilot (=1).
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the solution is good but the last line of the comment is not correct as such.

According to the protocol, the device_compid should not be "the same as the autopilot" but it should be any number from 1 to 6 to signal a non-MAVLink gimbal (which this is).

See: https://mavlink.io/en/messages/common.html#GIMBAL_MANAGER_INFORMATION

Gimbal device ID that this gimbal manager is responsible for. Component ID of gimbal device (or 1-6 for non-MAVLink gimbal).

Copy link
Contributor

Choose a reason for hiding this comment

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

And thanks for the PR @DanielePettenuzzo, appreciated!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@julianoes Thank you for the review! What you are saying makes sense. I changed the comment. When we are good to merge we can then squash the last commit.

Copy link
Contributor

@julianoes julianoes left a comment

Choose a reason for hiding this comment

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

Thanks!

The main problem was that during initial negotiation the client would
request the gimbal_manager_information from px4 but px4 would never send
it because in this configuration the device_compid was set to 0.
@bkueng bkueng merged commit 18f96c1 into main Feb 27, 2024
91 of 92 checks passed
@bkueng bkueng deleted the fix-gimbal-compid branch February 27, 2024 08:53
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.

3 participants