Skip to content

Commit

Permalink
Merge pull request #964 from schmidf/iir-coeff-fix
Browse files Browse the repository at this point in the history
Fix IIR coefficient python script
  • Loading branch information
jordens authored Nov 11, 2024
2 parents c822733 + 08181b7 commit aa99010
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions py/stabilizer/iir_coefficients.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,18 +141,18 @@ def lowpass_coefficients(args):
b0 = args.K * (f0_bar / (1 + f0_bar))
b1 = args.K * f0_bar / (1 + f0_bar)

return [b0, b1, 0, a1, 0]
return [b0, b1, 0, -a1, 0]


def highpass_coefficients(args):
"""Calculate high-pass IIR filter coefficients."""
f0_bar = pi * args.f0 * args.sample_period

a1 = (1 - f0_bar) / (1 + f0_bar)
b0 = args.K * (f0_bar / (1 + f0_bar))
b0 = args.K / (1 + f0_bar)
b1 = - args.K / (1 + f0_bar)

return [b0, b1, 0, a1, 0]
return [b0, b1, 0, -a1, 0]


def allpass_coefficients(args):
Expand All @@ -164,7 +164,7 @@ def allpass_coefficients(args):
b0 = args.K * (1 - f0_bar) / (1 + f0_bar)
b1 = - args.K

return [b0, b1, 0, a1, 0]
return [b0, b1, 0, -a1, 0]


def notch_coefficients(args):
Expand All @@ -179,7 +179,7 @@ def notch_coefficients(args):
b1 = - (2 * args.K * (1 - f0_bar ** 2)) / denominator
b2 = args.K * (1 + f0_bar ** 2) / denominator

return [b0, b1, b2, a1, a2]
return [b0, b1, b2, -a1, -a2]


def pid_coefficients(args):
Expand Down Expand Up @@ -216,7 +216,7 @@ def pid_coefficients(args):
b = [i/a[0] for i in b]
a = [i/a[0] for i in a]
assert a[0] == 1
return b + [-ai for ai in a[1:]]
return b + a[1:]


def _main():
Expand Down

0 comments on commit aa99010

Please sign in to comment.