Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Ardupilot
GitHub Repository: Ardupilot/ardupilot
Path: blob/master/libraries/AC_PID/AC_P.cpp
9479 views
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
float AC_P::get_p(float error) const
16
{
17
return (float)error * _kp;
18
}
19
20
// Loads controller configuration from EEPROM, including gains and filter frequencies. (not used)
21
void AC_P::load_gains()
22
{
23
_kp.load();
24
}
25
26
// Saves controller configuration from EEPROM. Used by autotune to save gains before tuning.
27
void AC_P::save_gains()
28
{
29
_kp.save();
30
}
31
32