Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix IIR coefficient python script #964

Merged
merged 1 commit into from
Nov 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading