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

gobot.Every() comment wrong and try to f() calls as equidistant as possible #966

Open
gen2thomas opened this issue Jun 25, 2023 · 0 comments
Assignees

Comments

@gen2thomas
Copy link
Collaborator

gen2thomas commented Jun 25, 2023

For some applications a "f()" call with nearly the same duration is important. If a "f()" takes to long, the next call will be obviously to late and the used ticker will be adjusted in the background by golang. This is wrong or misleading with the comment of the Every() method, which states: "It does not wait for the previous execution of f to finish before it fires the next f."

Most users has no RT Kernel running and most likely do not tweak the system to run the gobot application with any special process scheduler. So this will lead to sometimes the distance between call will be to long or, if the implementation of "f()" is to expensive, this will always happen.

This behavior must be taken into account e.g. for implementing digital controllers.

Two ideas could simplify the life by adding some code to the existing gobot.Every() functionality:

  • an adjustment algorithm by using the ticker.Reset() function, which increases the ticker until it keeps nearly constant
  • property to return the last real duration
@gen2thomas gen2thomas self-assigned this Jun 25, 2023
@gen2thomas gen2thomas changed the title gobot.Every() comment wrong and try to run() calls most equidistant gobot.Every() comment wrong and try to f() calls most equidistant Jun 26, 2023
@gen2thomas gen2thomas changed the title gobot.Every() comment wrong and try to f() calls most equidistant gobot.Every() comment wrong and try to f() calls as equidistant as possible Jun 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant