diff --git a/libraries/AC_AttitudeControl/AC_PosControl.cpp b/libraries/AC_AttitudeControl/AC_PosControl.cpp index 4ae998e3e5..c5cd9a0956 100644 --- a/libraries/AC_AttitudeControl/AC_PosControl.cpp +++ b/libraries/AC_AttitudeControl/AC_PosControl.cpp @@ -589,7 +589,8 @@ void AC_PosControl::stop_vel_xy_stabilisation() // is_active_xy - returns true if the xy position controller has bee n run in the previous 5 loop times bool AC_PosControl::is_active_xy() const { - return ((AP::ins().get_last_update_usec() - _last_update_xy_us) <= _dt * 1500000.0); + const uint32_t dt_us = AP::ins().get_last_update_usec() - _last_update_xy_us; + return dt_us <= _dt * 1500000.0; } /// update_xy_controller - runs the horizontal position controller correcting position, velocity and acceleration errors. @@ -903,7 +904,8 @@ void AC_PosControl::update_pos_offset_z(float pos_offset_z) // is_active_z - returns true if the z position controller has been run in the previous 5 loop times bool AC_PosControl::is_active_z() const { - return ((AP::ins().get_last_update_usec() - _last_update_z_us) <= _dt * 1500000.0); + const uint32_t dt_us = AP::ins().get_last_update_usec() - _last_update_z_us; + return dt_us <= _dt * 1500000.0; } /// update_z_controller - runs the vertical position controller correcting position, velocity and acceleration errors.