-
Notifications
You must be signed in to change notification settings - Fork 13.6k
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
MAVLink: Generate correct RC channel count #11219
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense 👍
CI fail:
@priseborough Do we need to extend the EKF check tooling? |
@MaEtUgR Could you please rebase? Thanks! |
cb1014e
to
fcf25c9
Compare
f42ef02
to
9854166
Compare
I rebased, addressed review comments and improved readability. |
@@ -1862,6 +1861,22 @@ MavlinkReceiver::handle_message_rc_channels_override(mavlink_message_t *msg) | |||
rc.values[16] = man.chan17_raw; | |||
rc.values[17] = man.chan18_raw; | |||
|
|||
// check how many channels are valid | |||
for (int i = 17; i >= 0; i--) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still don't care for the magic number, but I don't see anything from mavlink we can use directly.
Introduction
According to the message definition https://mavlink.io/en/messages/common.html#RC_CHANNELS_OVERRIDE
channels 1-8 should be ignored when they contain the value
UINT16_MAX
and the MAVLink 2 extension channels 9-18 should be ignored if they are eitherUINT16_MAX
or zero.Problem
Currently, the channel count is always 18 which doesn't reflect this definition. Hence I'm implementing the definition.
Solution
We loop from the last to the first channel and if one of them doesn't satisfy the conditions to be ignored we set the channel count to that number. Hence if the message is full of
UINT16_MAX
's the channel count stays 0, if the message is full of zeroes the count will be 8 because of the different definition in the extension and everything in between gets checked if it's ignored.Test data
We use this implementation for half a year now on the H520.
Additional Context
mavlink/mavlink#855
#10535