GCS_MAVLink: create a pointer to hold the secondary estimates

... rather than using the state structure to hold values
This commit is contained in:
Peter Barker
2026-06-30 19:45:18 +10:00
committed by Peter Barker
parent ea9bb165ea
commit 09d2e8dfa5
+10 -10
View File
@@ -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