Browse Source

APM_Control: fixed saving of new rate gains

mission-4.1.18
Andrew Tridgell 11 years ago
parent
commit
3343af602e
  1. 3
      libraries/APM_Control/AP_AutoTune.cpp
  2. 3
      libraries/APM_Control/AP_AutoTune.h

3
libraries/APM_Control/AP_AutoTune.cpp

@ -106,6 +106,7 @@ void AP_AutoTune::start(void)
state_enter_ms = now; state_enter_ms = now;
last_save_ms = now; last_save_ms = now;
last_save = current;
restore = current; restore = current;
/* /*
@ -246,12 +247,14 @@ void AP_AutoTune::check_save(void)
*/ */
void AP_AutoTune::save_gains(const ATGains &v) void AP_AutoTune::save_gains(const ATGains &v)
{ {
current = last_save;
current.tau.set_and_save_ifchanged(v.tau); current.tau.set_and_save_ifchanged(v.tau);
current.P.set_and_save_ifchanged(v.P); current.P.set_and_save_ifchanged(v.P);
current.I.set_and_save_ifchanged(v.I); current.I.set_and_save_ifchanged(v.I);
current.D.set_and_save_ifchanged(v.D); current.D.set_and_save_ifchanged(v.D);
current.rmax.set_and_save_ifchanged(v.rmax); current.rmax.set_and_save_ifchanged(v.rmax);
current.imax.set_and_save_ifchanged(v.imax); current.imax.set_and_save_ifchanged(v.imax);
last_save = current;
} }
#define LOG_MSG_ATRP 211 #define LOG_MSG_ATRP 211

3
libraries/APM_Control/AP_AutoTune.h

@ -58,6 +58,9 @@ private:
// values to restore if we leave autotune mode // values to restore if we leave autotune mode
ATGains restore; ATGains restore;
// values we last saved
ATGains last_save;
// values to save on the next save event // values to save on the next save event
ATGains next_save; ATGains next_save;

Loading…
Cancel
Save