diff --git a/ArduCopter/Copter.h b/ArduCopter/Copter.h index e6923f013ae..89932a8fea2 100644 --- a/ArduCopter/Copter.h +++ b/ArduCopter/Copter.h @@ -918,7 +918,6 @@ private: ModeAuto mode_auto; #endif #if AUTOTUNE_ENABLED == ENABLED - AutoTune autotune; ModeAutoTune mode_autotune; #endif #if MODE_BRAKE_ENABLED == ENABLED diff --git a/ArduCopter/Parameters.cpp b/ArduCopter/Parameters.cpp index 5662def4ec8..9c355595520 100644 --- a/ArduCopter/Parameters.cpp +++ b/ArduCopter/Parameters.cpp @@ -1084,7 +1084,7 @@ ParametersG2::ParametersG2(void) ,user_parameters() #endif #if AUTOTUNE_ENABLED == ENABLED - ,autotune_ptr(&copter.autotune) + ,autotune_ptr(&copter.mode_autotune.autotune) #endif #if MODE_SYSTEMID_ENABLED == ENABLED ,mode_systemid_ptr(&copter.mode_systemid) diff --git a/ArduCopter/mode.h b/ArduCopter/mode.h index 91ff8b9f674..0b98806ae5f 100644 --- a/ArduCopter/mode.h +++ b/ArduCopter/mode.h @@ -548,6 +548,9 @@ protected: class ModeAutoTune : public Mode { + // ParametersG2 sets a pointer within our autotune object: + friend class ParametersG2; + public: // inherit constructor using Mode::Mode; @@ -569,6 +572,11 @@ protected: const char *name() const override { return "AUTOTUNE"; } const char *name4() const override { return "ATUN"; } + +private: + + AutoTune autotune; + }; #endif diff --git a/ArduCopter/mode_autotune.cpp b/ArduCopter/mode_autotune.cpp index 4f5dbcc1d3b..72497f6756c 100644 --- a/ArduCopter/mode_autotune.cpp +++ b/ArduCopter/mode_autotune.cpp @@ -125,28 +125,28 @@ bool AutoTune::position_ok() */ bool ModeAutoTune::init(bool ignore_checks) { - return copter.autotune.init(); + return autotune.init(); } void ModeAutoTune::run() { - copter.autotune.run(); + autotune.run(); } void ModeAutoTune::save_tuning_gains() { - copter.autotune.save_tuning_gains(); + autotune.save_tuning_gains(); } void ModeAutoTune::stop() { - copter.autotune.stop(); + autotune.stop(); } void ModeAutoTune::reset() { - copter.autotune.reset(); + autotune.reset(); } #endif // AUTOTUNE_ENABLED == ENABLED