00001 #ifndef PID_H 00002 #define PID_H 00003 00004 #include <inttypes.h> 00005 #include <mav_common/comm.h> 00006 #include <mav_common/comm_packets.h> 00007 #include <mav_common/comm_types.h> 00008 00009 #include "sdk.h" 00010 #include "LL_HL_comm.h" 00011 00012 typedef struct 00013 { 00014 float kp; // Proportional Const 00015 float ki; // Integral Const 00016 float kd; // Derivative Const 00017 float kd2; // Derivative Const for angular velocity feedback 00018 float d_base; 00019 float bias; // constant term in the PID sum 00020 float sum_error; // Sums of Errors 00021 float max_sum_error; // integrative saturation to avoid increasing error from the integration 00022 float max_error; // maximum instantaneous error 00023 00024 } PID; 00025 00026 void pidReset(void); 00027 00028 float pidCalc(PID * pid, float error, float d_term, float d_base, float dt); 00029 00030 void processCtrl(void); 00031 00032 void pidParamUpdate(void); 00033 00034 #endif // PID_H 00035