diff --git a/ArduCopter/mode_autorotate.cpp b/ArduCopter/mode_autorotate.cpp index 9b15040af3c371..8b20da63267ccf 100644 --- a/ArduCopter/mode_autorotate.cpp +++ b/ArduCopter/mode_autorotate.cpp @@ -44,9 +44,6 @@ bool ModeAutorotate::init(bool ignore_checks) _flags.touch_down_init = false; _flags.landed_init = false; - // Ensure the surface distance object is enabled. We tidy this up on the mode exit function - copter.rangefinder_state.set_enabled_by_ap(true); - // Setting default starting switches phase_switch = Autorotation_Phase::ENTRY; @@ -62,10 +59,10 @@ bool ModeAutorotate::init(bool ignore_checks) void ModeAutorotate::run() { // Current time - uint32_t now = millis(); //milliseconds + const uint32_t now = millis(); // Set dt in library - float const last_loop_time_s = AP::scheduler().get_last_loop_time_s(); + const float last_loop_time_s = AP::scheduler().get_last_loop_time_s(); g2.arot.set_dt(last_loop_time_s); // Update the height above ground measurement in the autorotation lib @@ -180,8 +177,7 @@ void ModeAutorotate::run() void ModeAutorotate::exit() { - // Ensure we return the rangefinder state back to how we found it - copter.rangefinder_state.set_enabled_by_ap(false); + g2.arot.exit(); } #endif