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;