mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-12-01 21:52:12 +08:00
fix(mavlink): report GPS_RAW_INT yaw as invalid instead of unavailable (#28095)
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 <isak.aslund@airolit.com>
This commit is contained in:
1 parent
9e5a202f0a
commit
3b2e04af0d
1 file changed
+13
@@ -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;
|
||||
|
||||
|
||||
Reference in new issue
Block a user