From 1859dd42348121289c654e6046517f7abb31b7a8 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Thu, 28 Feb 2019 21:34:54 +1100 Subject: [PATCH] AC_AutoTune: avoid climb rate conversion from float to int32_t to float --- libraries/AC_AutoTune/AC_AutoTune.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/libraries/AC_AutoTune/AC_AutoTune.cpp b/libraries/AC_AutoTune/AC_AutoTune.cpp index b2c4695eef..12df23a2e4 100644 --- a/libraries/AC_AutoTune/AC_AutoTune.cpp +++ b/libraries/AC_AutoTune/AC_AutoTune.cpp @@ -344,8 +344,6 @@ void AC_AutoTune::do_gcs_announcements() // should be called at 100hz or more void AC_AutoTune::run() { - int32_t target_climb_rate_cms; - // initialize vertical speeds and acceleration init_z_limits(); @@ -362,10 +360,10 @@ void AC_AutoTune::run() get_pilot_desired_rp_yrate_cd(target_roll_cd, target_pitch_cd, target_yaw_rate_cds); // get pilot desired climb rate - target_climb_rate_cms = get_pilot_desired_climb_rate_cms(); + const float target_climb_rate_cms = get_pilot_desired_climb_rate_cms(); bool zero_rp_input = target_roll_cd == 0 && target_pitch_cd == 0; - if (!zero_rp_input || target_yaw_rate_cds != 0 || target_climb_rate_cms != 0) { + if (!zero_rp_input || target_yaw_rate_cds != 0 || !is_zero(target_climb_rate_cms)) { if (!pilot_override) { pilot_override = true; // set gains to their original values