Skip to content

No longer update PID derivative if timestep is 0 - #124

Open
owen-beck wants to merge 1 commit into
mainfrom
pid-timestep-fix
Open

No longer update PID derivative if timestep is 0#124
owen-beck wants to merge 1 commit into
mainfrom
pid-timestep-fix

Conversation

@owen-beck

Copy link
Copy Markdown
Collaborator

If a PID controller is updated multiple times in under a millisecond, the timestep becomes 0 and we get a divide by zero error when computing the derivative. We encountered this error initially with someone running the arcade function in a while loop with no delay. This PR fixes that by preventing the controller from updating its derivative if the timestep is zero, since if no time has passed the derivative shouldn't have changed.

To test I ran only the PID controller update function in a while True loop. The divide by zero error occurs with the old version of the controller and not with the new version.

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

Successfully merging this pull request may close these issues.

1 participant