mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-25 17:25:20 +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
|
@ -984,9 +984,9 @@ static void loadMainState(timeUs_t currentTimeUs)
|
|||
blackboxCurrent->time = currentTimeUs;
|
||||
|
||||
for (int i = 0; i < XYZ_AXIS_COUNT; i++) {
|
||||
blackboxCurrent->axisPID_P[i] = axisPID_P[i];
|
||||
blackboxCurrent->axisPID_I[i] = axisPID_I[i];
|
||||
blackboxCurrent->axisPID_D[i] = axisPID_D[i];
|
||||
blackboxCurrent->axisPID_P[i] = pidData[i].P;
|
||||
blackboxCurrent->axisPID_I[i] = pidData[i].I;
|
||||
blackboxCurrent->axisPID_D[i] = pidData[i].D;
|
||||
blackboxCurrent->gyroADC[i] = lrintf(gyro.gyroADCf[i]);
|
||||
blackboxCurrent->accADC[i] = lrintf(acc.accADC[i]);
|
||||
#ifdef USE_MAG
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue