mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-25 01:05:27 +03:00
Optimized the PID loop a little bit (#5661)
* * Put PID variables into the structure * Precalculate DTerm gyro filter outside the axis loop * Removed unused variables PIDweight[3], airmodeWasActivated * If zero throttle or gyro overflow, we can just set values and exit, this saves checks and jumps in axis loop * Compute PIDSUM after the axis loop, this saves branching inside the loop because of Yaw has no D term * * Incorporated review changes from DieHertz and fujin * * Incorporated another review requests from DieHertz - PidSum renamed to Sum - pidData[3] redone to pidData[XYZ_AXIS_COUNT]
This commit is contained in:
parent
696478d04c
commit
045557561d
7 changed files with 100 additions and 80 deletions
|
@ -128,13 +128,20 @@ PG_DECLARE(pidConfig_t, pidConfig);
|
|||
union rollAndPitchTrims_u;
|
||||
void pidController(const pidProfile_t *pidProfile, const union rollAndPitchTrims_u *angleTrim, timeUs_t currentTimeUs);
|
||||
|
||||
extern float axisPID_P[3], axisPID_I[3], axisPID_D[3];
|
||||
extern float axisPIDSum[3];
|
||||
bool airmodeWasActivated;
|
||||
typedef struct pidAxisData_s {
|
||||
float P;
|
||||
float I;
|
||||
float D;
|
||||
|
||||
float Sum;
|
||||
} pidAxisData_t;
|
||||
|
||||
extern pidAxisData_t pidData[3];
|
||||
|
||||
extern uint32_t targetPidLooptime;
|
||||
|
||||
// PIDweight is a scale factor for PIDs which is derived from the throttle and TPA setting, and 100 = 100% scale means no PID reduction
|
||||
extern uint8_t PIDweight[3];
|
||||
extern float throttleBoost;
|
||||
extern pt1Filter_t throttleLpf;
|
||||
|
||||
void pidResetITerm(void);
|
||||
void pidStabilisationState(pidStabilisationState_e pidControllerState);
|
||||
|
@ -145,5 +152,3 @@ void pidInit(const pidProfile_t *pidProfile);
|
|||
void pidCopyProfile(uint8_t dstPidProfileIndex, uint8_t srcPidProfileIndex);
|
||||
bool crashRecoveryModeActive(void);
|
||||
|
||||
extern float throttleBoost;
|
||||
extern pt1Filter_t throttleLpf;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue