aboutsummaryrefslogtreecommitdiff
path: root/apps/systemlib/pid/pid.h
diff options
context:
space:
mode:
authorDoug Weibel <deweibel@gmail.com>2012-10-07 14:46:26 -0600
committerDoug Weibel <deweibel@gmail.com>2012-10-07 14:46:26 -0600
commit2bb1d17c7e312e6f60bcd6e8f1ac6698fe623060 (patch)
treeb5084f8eeff47c6acd6eaf49aa66d38c9630fc4b /apps/systemlib/pid/pid.h
parent2fa0dec36954b0f3c99da0a443a9c51a7a0479c5 (diff)
downloadpx4-firmware-2bb1d17c7e312e6f60bcd6e8f1ac6698fe623060.tar.gz
px4-firmware-2bb1d17c7e312e6f60bcd6e8f1ac6698fe623060.tar.bz2
px4-firmware-2bb1d17c7e312e6f60bcd6e8f1ac6698fe623060.zip
Changes to the PID controller. Adds "limit" to the parameter set. Implements an output limit where the output magnitude is limited by the parameter value "limit". Also changes the integrator saturation such that the integrator is not updated (added to) if either updating it will cause the integrator values magnitude to exceed "intmax" or if the output magnitude would exceed "limit" with an updated integrator value.
Arbitrary large limit values were hard coded into multirotor_attitude_control.c. These should be changed to parametric values or something sensible. This commit will temporarily break fixedwing_control.c. A following commit will repair it along with significant changes to the inner loop control. This commit has been tested to compile with fixedwing_control.c temporarily removed. No other testing has been completed.
Diffstat (limited to 'apps/systemlib/pid/pid.h')
-rw-r--r--apps/systemlib/pid/pid.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/apps/systemlib/pid/pid.h b/apps/systemlib/pid/pid.h
index 098b2bef8..b51afef9e 100644
--- a/apps/systemlib/pid/pid.h
+++ b/apps/systemlib/pid/pid.h
@@ -49,6 +49,8 @@
#define PID_MODE_DERIVATIV_CALC 0
/* Use PID_MODE_DERIVATIV_SET if you have the derivative already (Gyros, Kalman) */
#define PID_MODE_DERIVATIV_SET 1
+// Use PID_MODE_DERIVATIV_NONE for a PI controller (vs PID)
+#define PID_MODE_DERIVATIV_NONE 9
typedef struct {
float kp;
@@ -65,8 +67,8 @@ typedef struct {
uint8_t saturated;
} PID_t;
-__EXPORT void pid_init(PID_t *pid, float kp, float ki, float kd, float intmax, uint8_t mode);
-__EXPORT int pid_set_parameters(PID_t *pid, float kp, float ki, float kd, float intmax);
+__EXPORT void pid_init(PID_t *pid, float kp, float ki, float kd, float intmax, float limit, uint8_t mode);
+__EXPORT int pid_set_parameters(PID_t *pid, float kp, float ki, float kd, float intmax, float limit);
//void pid_set(PID_t *pid, float sp);
__EXPORT float pid_calculate(PID_t *pid, float sp, float val, float val_dot, float dt);