Skip to content

Add PID controller implementation #12643

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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
Add PID controller implementation
  • Loading branch information
TahmidSwad committed Mar 28, 2025
commit dfb637b3310f71716e008ced4489e24d9bdb5dd5
6 changes: 0 additions & 6 deletions control_algorithms/pid.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,8 @@
"""


<<<<<<< HEAD
class PID:

def __init__(self, kp: float, ki: float, kd: float, setpoint: float = 0):
=======
class pid:

Check failure on line 14 in control_algorithms/pid.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (N801)

control_algorithms/pid.py:14:7: N801 Class name `pid` should use CapWords convention

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Class names should follow the CamelCase naming convention. Please update the following name accordingly: pid

def __init__(self, Kp: float, Ki: float, Kd: float, setpoint: float = 0):

Check failure on line 15 in control_algorithms/pid.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (ARG002)

control_algorithms/pid.py:15:46: ARG002 Unused method argument: `Kd`

Check failure on line 15 in control_algorithms/pid.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (N803)

control_algorithms/pid.py:15:46: N803 Argument name `Kd` should be lowercase

Check failure on line 15 in control_algorithms/pid.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (ARG002)

control_algorithms/pid.py:15:35: ARG002 Unused method argument: `Ki`

Check failure on line 15 in control_algorithms/pid.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (N803)

control_algorithms/pid.py:15:35: N803 Argument name `Ki` should be lowercase

Check failure on line 15 in control_algorithms/pid.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (ARG002)

control_algorithms/pid.py:15:24: ARG002 Unused method argument: `Kp`

Check failure on line 15 in control_algorithms/pid.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (N803)

control_algorithms/pid.py:15:24: N803 Argument name `Kp` should be lowercase

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide return type hint for the function: __init__. If the function does not return a value, please provide the type hint as: def function() -> None:

Variable and function names should follow the snake_case naming convention. Please update the following name accordingly: Kp

Variable and function names should follow the snake_case naming convention. Please update the following name accordingly: Ki

Variable and function names should follow the snake_case naming convention. Please update the following name accordingly: Kd

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide return type hint for the function: __init__. If the function does not return a value, please provide the type hint as: def function() -> None:

Variable and function names should follow the snake_case naming convention. Please update the following name accordingly: Kp

Variable and function names should follow the snake_case naming convention. Please update the following name accordingly: Ki

Variable and function names should follow the snake_case naming convention. Please update the following name accordingly: Kd

>>>>>>> 588538eaddcee6fa4733a1775487123c0ed09a43
"""
Initialize the PID controller.

Expand All @@ -27,9 +21,9 @@
:param Kd: Derivative gain
:param setpoint: Desired target value
"""
self.kp = kp

Check failure on line 24 in control_algorithms/pid.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F821)

control_algorithms/pid.py:24:19: F821 Undefined name `kp`
self.ki = ki

Check failure on line 25 in control_algorithms/pid.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F821)

control_algorithms/pid.py:25:19: F821 Undefined name `ki`
self.kd = kd

Check failure on line 26 in control_algorithms/pid.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F821)

control_algorithms/pid.py:26:19: F821 Undefined name `kd`
self.setpoint = setpoint

self.integral = 0
Expand Down