Skip to content

Commit

Permalink
Some fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeller committed Jun 8, 2018
1 parent fefedbd commit db3c0d1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
11 changes: 5 additions & 6 deletions src/main/flight/pid.c
Expand Up @@ -812,12 +812,11 @@ void FAST_CODE pidController(const pidProfile_t *pidProfile, const rollAndPitchT
float itermErrorRate = 0.0f;

#if defined(USE_ITERM_RELAX)
float stickSetpoint = currentPidSetpoint;
if (itermRelax && (axis < FD_YAW || itermRelax == ITERM_RELAX_RPY )) {
const float gyroTarget = pt1FilterApply(&windupLpf[axis], stickSetpoint);
const float gyroHpf = fabsf(stickSetpoint - gyroTarget);
const float gyroTarget = pt1FilterApply(&windupLpf[axis], currentPidSetpoint);
const float gyroHpf = fabsf(currentPidSetpoint - gyroTarget);
if (itermRelaxType == ITERM_RELAX_SETPOINT) {
itermErrorRate = (1 - MIN(1, fabsf(gyroHpf) / 60.0f)) * (stickSetpoint - gyroRate);
itermErrorRate = (1 - MIN(1, fabsf(gyroHpf) / 60.0f)) * (currentPidSetpoint - gyroRate);
}
const float tolerance = gyroHpf * 1.0f;
if (axis == FD_ROLL) {
Expand All @@ -831,9 +830,9 @@ void FAST_CODE pidController(const pidProfile_t *pidProfile, const rollAndPitchT
const float gmin = gyroTarget - tolerance;

if (gyroRate >= gmin && gyroRate <= gmax) {
itermErrorRate = 0;
itermErrorRate = 0;
} else {
itermErrorRate = (gyroRate > gmax ? gmax : gmin ) - gyroRate;
itermErrorRate = (gyroRate > gmax ? gmax : gmin ) - gyroRate;
}
}

Expand Down
6 changes: 2 additions & 4 deletions src/main/flight/pid.h
Expand Up @@ -76,15 +76,13 @@ typedef struct pid8_s {
uint8_t D;
} pid8_t;

typedef enum
{
typedef enum {
ITERM_RELAX_OFF,
ITERM_RELAX_RP,
ITERM_RELAX_RPY
} itermRelax_e;

typedef enum
{
typedef enum {
ITERM_RELAX_GYRO,
ITERM_RELAX_SETPOINT
} itermRelaxType_e;
Expand Down

0 comments on commit db3c0d1

Please sign in to comment.