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

Spinner class is drifting in time #14

Open
jviereck opened this issue Dec 3, 2019 · 0 comments
Open

Spinner class is drifting in time #14

jviereck opened this issue Dec 3, 2019 · 0 comments

Comments

@jviereck
Copy link
Contributor

jviereck commented Dec 3, 2019

The current version of the spinner class 1 can have a slight time drift between ticks. That means, if you setup 1000 hz frequency and you call the spinner 1000 times, then you might need significantly more than 1 seconds.

This is problematic as it means we might not getting stable 1 kHz loop when using dynamic graph manager (which uses the spinner classs).

The current implementation looks like this

  void Spinner::spin() {
    Timer::sleep_until_sec(next_date_sec_);   // (1)
    next_date_sec_ = Timer::get_current_time_sec() + period_sec_; // (2)
  }

The drift happens because Timer::get_current_time_sec() is not necessarly directly after Timer::sleep_until_sec. Also, Timer::sleep_until_sec might take a bit longer than desired.

Proposal is to fix the current implementation and avoid the drift.

inputs? @vincentberenz @MaximilienNaveau @righetti @mwuethri @luator

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

1 participant