2014-02-14 02:53:23 -04:00
|
|
|
/// @file AC_P.cpp
|
|
|
|
/// @brief Generic P algorithm
|
|
|
|
|
2015-08-11 03:28:41 -03:00
|
|
|
#include <AP_Math/AP_Math.h>
|
2014-02-14 02:53:23 -04:00
|
|
|
#include "AC_P.h"
|
|
|
|
|
2015-10-25 14:03:46 -03:00
|
|
|
const AP_Param::GroupInfo AC_P::var_info[] = {
|
2014-02-14 02:53:23 -04:00
|
|
|
// @Param: P
|
|
|
|
// @DisplayName: PI Proportional Gain
|
|
|
|
// @Description: P Gain which produces an output value that is proportional to the current error value
|
2023-01-03 13:22:36 -04:00
|
|
|
AP_GROUPINFO_FLAGS_DEFAULT_POINTER("P", 0, AC_P, _kp, default_kp),
|
2014-02-14 02:53:23 -04:00
|
|
|
AP_GROUPEND
|
|
|
|
};
|
|
|
|
|
|
|
|
float AC_P::get_p(float error) const
|
|
|
|
{
|
|
|
|
return (float)error * _kp;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AC_P::load_gains()
|
|
|
|
{
|
|
|
|
_kp.load();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AC_P::save_gains()
|
|
|
|
{
|
|
|
|
_kp.save();
|
|
|
|
}
|