diff --git a/ArduPlane/ArduPlane.cpp b/ArduPlane/ArduPlane.cpp index 3ee21cfebc..61b48b4bf2 100644 --- a/ArduPlane/ArduPlane.cpp +++ b/ArduPlane/ArduPlane.cpp @@ -796,26 +796,21 @@ bool Plane::set_velocity_match(const Vector2f &velocity) #endif // AP_SCRIPTING_ENABLED -#if OSD_ENABLED // correct AHRS pitch for TRIM_PITCH_CD in non-VTOL modes, and return VTOL view in VTOL void Plane::get_osd_roll_pitch_rad(float &roll, float &pitch) const { - pitch = ahrs.pitch; - roll = ahrs.roll; #if HAL_QUADPLANE_ENABLED - if (quadplane.show_vtol_view()) { - return; - } -#endif - if (!(g2.flight_options & FlightOptions::OSD_REMOVE_TRIM_PITCH_CD)) { // correct for TRIM_PITCH_CD - pitch -= g.pitch_trim_cd * 0.01 * DEG_TO_RAD; - return; - } -#if HAL_QUADPLANE_ENABLED - pitch = quadplane.ahrs_view->pitch; - roll = quadplane.ahrs_view->roll; + if (quadplane.show_vtol_view()) { + pitch = quadplane.ahrs_view->pitch; + roll = quadplane.ahrs_view->roll; + return; + } #endif + pitch = ahrs.pitch; + roll = ahrs.roll; + if (!(g2.flight_options & FlightOptions::OSD_REMOVE_TRIM_PITCH_CD)) { // correct for TRIM_PITCH_CD + pitch -= g.pitch_trim_cd * 0.01 * DEG_TO_RAD; + } } -#endif AP_HAL_MAIN_CALLBACKS(&plane); diff --git a/ArduPlane/Plane.h b/ArduPlane/Plane.h index 5ccab39e11..b210e11443 100644 --- a/ArduPlane/Plane.h +++ b/ArduPlane/Plane.h @@ -984,9 +984,7 @@ private: // ArduPlane.cpp void disarm_if_autoland_complete(); -# if OSD_ENABLED void get_osd_roll_pitch_rad(float &roll, float &pitch) const override; -#endif float tecs_hgt_afe(void); void efi_update(void); void get_scheduler_tasks(const AP_Scheduler::Task *&tasks, diff --git a/libraries/AP_Vehicle/AP_Vehicle.cpp b/libraries/AP_Vehicle/AP_Vehicle.cpp index b0033431fa..ad25978652 100644 --- a/libraries/AP_Vehicle/AP_Vehicle.cpp +++ b/libraries/AP_Vehicle/AP_Vehicle.cpp @@ -631,6 +631,7 @@ void AP_Vehicle::publish_osd_info() nav_info.wp_number = mission->get_current_nav_index(); osd->set_nav_info(nav_info); } +#endif void AP_Vehicle::get_osd_roll_pitch_rad(float &roll, float &pitch) const { @@ -638,8 +639,6 @@ void AP_Vehicle::get_osd_roll_pitch_rad(float &roll, float &pitch) const pitch = ahrs.pitch; } -#endif - #if HAL_INS_ACCELCAL_ENABLED #ifndef HAL_CAL_ALWAYS_REBOOT diff --git a/libraries/AP_Vehicle/AP_Vehicle.h b/libraries/AP_Vehicle/AP_Vehicle.h index d32a942c0d..87e55daf22 100644 --- a/libraries/AP_Vehicle/AP_Vehicle.h +++ b/libraries/AP_Vehicle/AP_Vehicle.h @@ -292,10 +292,8 @@ public: */ virtual bool get_pan_tilt_norm(float &pan_norm, float &tilt_norm) const { return false; } -#if OSD_ENABLED // Returns roll and pitch for OSD Horizon, Plane overrides to correct for VTOL view and fixed wing TRIM_PITCH_CD virtual void get_osd_roll_pitch_rad(float &roll, float &pitch) const; -#endif /* get the target body-frame angular velocities in rad/s (Z-axis component used by some gimbals)