From 3b2e04af0d3ce5160220130b1a53a9f047a22a9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isak=20=C3=85slund?= Date: Wed, 29 Jul 2026 19:40:30 +0200 Subject: [PATCH] fix(mavlink): report GPS_RAW_INT yaw as invalid instead of unavailable (#28095) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A yaw of 0 means the receiver does not provide yaw at all, UINT16_MAX means it does but has none for this sample. The stream left the field at 0 whenever sensor_gps.heading was NAN, so a dual antenna receiver that momentarily loses its heading reports itself as not yaw capable. Send UINT16_MAX once a heading has been seen, both for a sample without one and in the no-GPS message. Signed-off-by: Isak Åslund --- src/modules/mavlink/streams/GPS_RAW_INT.hpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/modules/mavlink/streams/GPS_RAW_INT.hpp b/src/modules/mavlink/streams/GPS_RAW_INT.hpp index 74e7948466f..cd9ea73d9ab 100644 --- a/src/modules/mavlink/streams/GPS_RAW_INT.hpp +++ b/src/modules/mavlink/streams/GPS_RAW_INT.hpp @@ -61,6 +61,7 @@ private: uORB::Subscription _sensor_gps_sub{ORB_ID(sensor_gps), 0}; SensorGpsSelector _gps_selector{}; hrt_abstime _last_send_ts {}; + bool _yaw_capable{false}; ///< a heading has been reported at least once static constexpr hrt_abstime kNoGpsSendInterval {1_s}; bool send() override @@ -106,6 +107,8 @@ private: msg.vel_acc = gps.s_variance_m_s * 1e3f; // speed uncertainty in mm if (PX4_ISFINITE(gps.heading)) { + _yaw_capable = true; + if (fabsf(gps.heading) < FLT_EPSILON) { msg.yaw = 36000; // Use 36000 for north. @@ -116,6 +119,11 @@ private: if (PX4_ISFINITE(gps.heading_accuracy)) { msg.hdg_acc = math::degrees(gps.heading_accuracy) * 1e5f; // Heading / track uncertainty in degE5 } + + } else if (_yaw_capable) { + // 0 means the receiver never provides yaw, so a receiver that does has to + // report the samples it has no heading for as invalid instead + msg.yaw = UINT16_MAX; } mavlink_msg_gps_raw_int_send_struct(_mavlink->get_channel(), &msg); @@ -130,6 +138,11 @@ private: msg.vel = UINT16_MAX; msg.cog = UINT16_MAX; msg.satellites_visible = UINT8_MAX; + + if (_yaw_capable) { + msg.yaw = UINT16_MAX; + } + mavlink_msg_gps_raw_int_send_struct(_mavlink->get_channel(), &msg); _last_send_ts = now;