PX4-Autopilot
PX4-Autopilot copied to clipboard
Don't publish invalid MAVLink joystick input
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: https://github.com/PX4/PX4-Autopilot/pull/22108#discussion_r1684065823
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.