AC_P.cpp 537 B

12345678910111213141516171819202122232425262728
  1. /// @file AC_P.cpp
  2. /// @brief Generic P algorithm
  3. #include <AP_Math/AP_Math.h>
  4. #include "AC_P.h"
  5. const AP_Param::GroupInfo AC_P::var_info[] = {
  6. // @Param: P
  7. // @DisplayName: PI Proportional Gain
  8. // @Description: P Gain which produces an output value that is proportional to the current error value
  9. AP_GROUPINFO("P", 0, AC_P, _kp, 0),
  10. AP_GROUPEND
  11. };
  12. float AC_P::get_p(float error) const
  13. {
  14. return (float)error * _kp;
  15. }
  16. void AC_P::load_gains()
  17. {
  18. _kp.load();
  19. }
  20. void AC_P::save_gains()
  21. {
  22. _kp.save();
  23. }