Don't publish invalid MAVLink joystick input#23649
Merged
Conversation
Note that the MAVLink definition explicitly writes "A value of INT16_MAX indicates that this axis is invalid." which before this change was happily executed.
sfuhrer
approved these changes
Sep 6, 2024
Contributor
sfuhrer
left a comment
There was a problem hiding this comment.
Certainly better than before, but as you mention it would be even better to not publish it as 0 but NAN in that case.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Solved Problem
When I was asked if a joystick with only 3 axes would work with PX4 I figured I'd check what the ground station should send and if it's handled correctly. Mavlink says "A value of INT16_MAX indicates that this axis is invalid." but if that's done then PX4 publishes a 3276.7% stick deflection 😱
Solution
Do not accept any out of range input. For now publish 0 when out of range.
Alternatives
I still have to go through and make sure all consumers can handle NAN. I promised to do that already here: #22108 (comment)
Changelog Entry
Test coverage
I tested in SITL SIH for
x,y,z,rthat out-of-range values lead to zero deflection and valid values including -1000 and 1000 lead to the expected deflections published.Context