Skip to content

Commit

Permalink
Fix gov.P and gov.D mixup
Browse files Browse the repository at this point in the history
  • Loading branch information
pmattila committed Aug 13, 2024
1 parent 5011519 commit 82bdf75
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/main/flight/governor.c
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ static float govPIDControl(void)
// PID limits
gov.P = constrainf(gov.P, -GOV_P_TERM_LIMIT, GOV_P_TERM_LIMIT);
gov.I = constrainf(gov.I, 0, GOV_I_TERM_LIMIT);
gov.D = constrainf(gov.P, -GOV_D_TERM_LIMIT, GOV_D_TERM_LIMIT);
gov.D = constrainf(gov.D, -GOV_D_TERM_LIMIT, GOV_D_TERM_LIMIT);

// Governor PID sum
gov.pidSum = gov.P + gov.I + gov.D + gov.C;
Expand All @@ -865,7 +865,7 @@ static void govMode1Init(void)
{
// PID limits
gov.P = constrainf(gov.P, -GOV_P_TERM_LIMIT, GOV_P_TERM_LIMIT);
gov.D = constrainf(gov.P, -GOV_D_TERM_LIMIT, GOV_D_TERM_LIMIT);
gov.D = constrainf(gov.D, -GOV_D_TERM_LIMIT, GOV_D_TERM_LIMIT);
gov.F = constrainf(gov.F, 0, GOV_F_TERM_LIMIT);

// Use gov.I to reach the target
Expand All @@ -882,7 +882,7 @@ static float govMode1Control(void)
// PID limits
gov.P = constrainf(gov.P, -GOV_P_TERM_LIMIT, GOV_P_TERM_LIMIT);
gov.I = constrainf(gov.I, 0, GOV_I_TERM_LIMIT);
gov.D = constrainf(gov.P, -GOV_D_TERM_LIMIT, GOV_D_TERM_LIMIT);
gov.D = constrainf(gov.D, -GOV_D_TERM_LIMIT, GOV_D_TERM_LIMIT);
gov.F = constrainf(gov.F, 0, GOV_F_TERM_LIMIT);

// Governor PIDF sum
Expand Down Expand Up @@ -916,7 +916,7 @@ static void govMode2Init(void)

// PID limits
gov.P = constrainf(gov.P, -GOV_P_TERM_LIMIT, GOV_P_TERM_LIMIT);
gov.D = constrainf(gov.P, -GOV_D_TERM_LIMIT, GOV_D_TERM_LIMIT);
gov.D = constrainf(gov.D, -GOV_D_TERM_LIMIT, GOV_D_TERM_LIMIT);
gov.F = constrainf(gov.F, 0, GOV_F_TERM_LIMIT);

// Use gov.I to reach the target
Expand All @@ -936,7 +936,7 @@ static float govMode2Control(void)
// PID limits
gov.P = constrainf(gov.P, -GOV_P_TERM_LIMIT, GOV_P_TERM_LIMIT);
gov.I = constrainf(gov.I, 0, GOV_I_TERM_LIMIT);
gov.D = constrainf(gov.P, -GOV_D_TERM_LIMIT, GOV_D_TERM_LIMIT);
gov.D = constrainf(gov.D, -GOV_D_TERM_LIMIT, GOV_D_TERM_LIMIT);
gov.F = constrainf(gov.F, 0, GOV_F_TERM_LIMIT);

// Governor PIDF sum
Expand Down

0 comments on commit 82bdf75

Please sign in to comment.