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

adding a filter to derivative term #44

Open
CamDavidsonPilon opened this issue Oct 13, 2021 · 1 comment
Open

adding a filter to derivative term #44

CamDavidsonPilon opened this issue Oct 13, 2021 · 1 comment

Comments

@CamDavidsonPilon
Copy link

CamDavidsonPilon commented Oct 13, 2021

👋 what are your thoughts on allowing users to add a hook into the class to add a filter infront of the derivative term. I've read in a few places that adding a filter infront of the derivative term is a good idea (i.e. instead of passing the raw input_ to d_input, we pass in some filtered version).

High level:

def my_filter(input_, previous_input_):
   # compute things    
   return some_float

pid = PID(...)
pid.add_derivative_hook(my_filter)

low level:

   
   def _compute_derivative(self, input, last_input):
       return input - (last_input if (last_input is not None) else input)

   def add_derivative_hook(self, callable):
       self._compute_derivative = callable

   def __call__(...):
        ...
        # Compute error terms
        error = self.setpoint - input_
        d_input = self._compute_derivative(input, self._last_input)
       ...
@yrik
Copy link

yrik commented Jul 10, 2024

Would love this feature as well, ideally with some built in filter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants