Skip to content

Don't publish invalid MAVLink joystick input#23649

Merged
MaEtUgR merged 1 commit intomainfrom
mavlink-manual-control-limits
Dec 19, 2024
Merged

Don't publish invalid MAVLink joystick input#23649
MaEtUgR merged 1 commit intomainfrom
mavlink-manual-control-limits

Conversation

@MaEtUgR
Copy link
Copy Markdown
Member

@MaEtUgR MaEtUgR commented Sep 5, 2024

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

Bugfix: don't publish invalid MAVLink joystick input

Test coverage

I tested in SITL SIH for x, y, z, r that out-of-range values lead to zero deflection and valid values including -1000 and 1000 lead to the expected deflections published.

Context

image (16)

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.
@MaEtUgR MaEtUgR requested a review from sfuhrer September 5, 2024 16:47
@MaEtUgR MaEtUgR self-assigned this Sep 5, 2024
@MaEtUgR MaEtUgR changed the title mavlink_receiver: don't publish out of range joystick input Don't publish invalid MAVLink joystick input Sep 5, 2024
Copy link
Copy Markdown
Contributor

@sfuhrer sfuhrer left a comment

Choose a reason for hiding this comment

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

Certainly better than before, but as you mention it would be even better to not publish it as 0 but NAN in that case.

@github-actions github-actions bot added the stale label Oct 7, 2024
@MaEtUgR MaEtUgR merged commit 6196135 into main Dec 19, 2024
@MaEtUgR MaEtUgR deleted the mavlink-manual-control-limits branch December 19, 2024 16:59
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.

2 participants