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)