Skip to content

Commit

Permalink
Copter: autotune: allow access to autotune object and call through fo…
Browse files Browse the repository at this point in the history
…r disarm and aux function
  • Loading branch information
IamPete1 committed Aug 6, 2024
1 parent 8f9b3c1 commit a6127c5
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 25 deletions.
8 changes: 2 additions & 6 deletions ArduCopter/AP_Arming.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -809,12 +809,8 @@ bool AP_Arming_Copter::disarm(const AP_Arming::Method method, bool do_disarm_che
}

#if AUTOTUNE_ENABLED == ENABLED
// save auto tuned parameters
if (copter.flightmode == &copter.mode_autotune) {
copter.mode_autotune.save_tuning_gains();
} else {
copter.mode_autotune.reset();
}
// Possibly save auto tuned parameters
copter.mode_autotune.autotune.disarmed(copter.flightmode == &copter.mode_autotune);
#endif

// we are not in the air
Expand Down
8 changes: 6 additions & 2 deletions ArduCopter/RC_Channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ void RC_Channel_Copter::init_aux_function(const AUX_FUNC ch_option, const AuxSwi
// the following functions do not need to be initialised:
case AUX_FUNC::ALTHOLD:
case AUX_FUNC::AUTO:
case AUX_FUNC::AUTOTUNE:
case AUX_FUNC::AUTOTUNE_MODE:
case AUX_FUNC::AUTOTUNE_TEST_GAINS:
case AUX_FUNC::BRAKE:
case AUX_FUNC::CIRCLE:
case AUX_FUNC::DRIFT:
Expand Down Expand Up @@ -291,9 +292,12 @@ bool RC_Channel_Copter::do_aux_function(const AUX_FUNC ch_option, const AuxSwitc
#endif

#if AUTOTUNE_ENABLED == ENABLED
case AUX_FUNC::AUTOTUNE:
case AUX_FUNC::AUTOTUNE_MODE:
do_aux_function_change_mode(Mode::Number::AUTOTUNE, ch_flag);
break;
case AUX_FUNC::AUTOTUNE_TEST_GAINS:
copter.mode_autotune.autotune.do_aux_function(ch_flag);
break;
#endif

case AUX_FUNC::LAND:
Expand Down
8 changes: 1 addition & 7 deletions ArduCopter/mode.h
Original file line number Diff line number Diff line change
Expand Up @@ -796,18 +796,12 @@ class ModeAutoTune : public Mode {
bool allows_arming(AP_Arming::Method method) const override { return false; }
bool is_autopilot() const override { return false; }

void save_tuning_gains();
void reset();
AutoTune autotune;

protected:

const char *name() const override { return "AUTOTUNE"; }
const char *name4() const override { return "ATUN"; }

private:

AutoTune autotune;

};
#endif

Expand Down
10 changes: 0 additions & 10 deletions ArduCopter/mode_autotune.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,19 +118,9 @@ void ModeAutoTune::run()
autotune.run();
}

void ModeAutoTune::save_tuning_gains()
{
autotune.save_tuning_gains();
}

void ModeAutoTune::exit()
{
autotune.stop();
}

void ModeAutoTune::reset()
{
autotune.reset();
}

#endif // AUTOTUNE_ENABLED == ENABLED

0 comments on commit a6127c5

Please sign in to comment.