From 92910a733bf396b0fa24b4832d0cd646aa3acff7 Mon Sep 17 00:00:00 2001 From: Iampete1 Date: Mon, 24 Aug 2026 13:19:02 +0100 Subject: [PATCH] AP_Vehicle: get_osd_attitude_rad takes ahrs semaphore --- libraries/AP_Vehicle/AP_Vehicle.cpp | 5 ++++- libraries/AP_Vehicle/AP_Vehicle.h | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/libraries/AP_Vehicle/AP_Vehicle.cpp b/libraries/AP_Vehicle/AP_Vehicle.cpp index d2bfb700b6a..23ad89429bc 100644 --- a/libraries/AP_Vehicle/AP_Vehicle.cpp +++ b/libraries/AP_Vehicle/AP_Vehicle.cpp @@ -1020,9 +1020,12 @@ void AP_Vehicle::publish_osd_info() } #endif -void AP_Vehicle::get_osd_attitude_rad(float &roll, float &pitch, float &yaw) const +void AP_Vehicle::get_osd_attitude_rad(float &roll, float &pitch, float &yaw) { #if AP_AHRS_ENABLED + // Take semaphore as this can be called from a thread + WITH_SEMAPHORE(ahrs.get_semaphore()); + roll = ahrs.get_roll_rad(); pitch = ahrs.get_pitch_rad(); yaw = ahrs.get_yaw_rad(); diff --git a/libraries/AP_Vehicle/AP_Vehicle.h b/libraries/AP_Vehicle/AP_Vehicle.h index 7aa7e9fcfa1..cfc8abb041b 100644 --- a/libraries/AP_Vehicle/AP_Vehicle.h +++ b/libraries/AP_Vehicle/AP_Vehicle.h @@ -313,7 +313,7 @@ public: virtual bool get_pan_tilt_norm(float &pan_norm, float &tilt_norm) const { return false; } // Returns roll, pitch, and yaw for OSD Horizon, Plane overrides to correct for VTOL view and fixed wing PTCH_TRIM_DEG - virtual void get_osd_attitude_rad(float &roll, float &pitch, float &yaw) const; + virtual void get_osd_attitude_rad(float &roll, float &pitch, float &yaw); /* get the target earth-frame angular velocities in rad/s (Z-axis component used by some gimbals)