diff --git a/libraries/GCS_MAVLink/GCS_Common.cpp b/libraries/GCS_MAVLink/GCS_Common.cpp index e6c558dc28c..7cccbe63ce9 100644 --- a/libraries/GCS_MAVLink/GCS_Common.cpp +++ b/libraries/GCS_MAVLink/GCS_Common.cpp @@ -616,20 +616,20 @@ void GCS_MAVLINK::send_proximity() // report AHRS2 state void GCS_MAVLINK::send_ahrs2() { - const AP_AHRS &ahrs = AP::ahrs(); - Vector3f euler; - Location loc {}; - // we want one or both of these, use | to avoid short-circuiting: - if (uint8_t(ahrs.get_secondary_attitude(euler)) | - uint8_t(ahrs.get_secondary_position(loc))) { + const auto *estimates = AP::ahrs().get_secondary_estimates(); + if (estimates == nullptr) { + return; + } + + const Location &loc = estimates->location; + mavlink_msg_ahrs2_send(chan, - euler.x, - euler.y, - euler.z, + estimates->roll_rad, + estimates->pitch_rad, + estimates->yaw_rad, loc.alt*1.0e-2f, loc.lat, loc.lng); - } } #endif // AP_AHRS_ENABLED