Line data Source code
1 : /// @file AC_P.cpp 2 : /// @brief Single-axis P controller with EEPROM-backed gain storage. 3 : 4 : #include <AP_Math/AP_Math.h> 5 : #include "AC_P.h" 6 : 7 : const AP_Param::GroupInfo AC_P::var_info[] = { 8 : // @Param: P 9 : // @DisplayName: P Proportional Gain 10 : // @Description: P Gain which produces an output value that is proportional to the current error value 11 : AP_GROUPINFO_FLAGS_DEFAULT_POINTER("P", 0, AC_P, _kp, default_kp), 12 : AP_GROUPEND 13 : }; 14 : 15 30540 : float AC_P::get_p(float error) const 16 : { 17 30540 : return (float)error * _kp; 18 : } 19 : 20 : // Loads controller configuration from EEPROM, including gains and filter frequencies. (not used) 21 0 : void AC_P::load_gains() 22 : { 23 0 : _kp.load(); 24 0 : } 25 : 26 : // Saves controller configuration from EEPROM. Used by autotune to save gains before tuning. 27 17 : void AC_P::save_gains() 28 : { 29 17 : _kp.save(); 30 17 : }