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

Incorrect warning msg when sim jumps back in time #2407

Closed
iche033 opened this issue May 14, 2024 · 1 comment · Fixed by #2435
Closed

Incorrect warning msg when sim jumps back in time #2407

iche033 opened this issue May 14, 2024 · 1 comment · Fixed by #2435
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@iche033
Copy link
Contributor

iche033 commented May 14, 2024

Environment

  • OS Version: Ubuntu 22.04
  • Source or binary build? citadel and above

In many of gz-sim's systems PostUpdate function, there is this code to print warning msg:

  if (_info.dt < std::chrono::steady_clock::duration::zero())
  {
    gzwarn << "Detected jump back in time ["
        << std::chrono::duration_cast<std::chrono::seconds>(_info.dt).count()
        << "s]. System may not work properly." << std::endl;
  }

The problem is that if _info.dt is smaller than 1 sec, std::chrono::duration_cast<std::chrono::seconds>(_info.dt).count() would produce 0, and the msg will output jump back in time [0s]

A quick fix is to change all instances of this code to std::chrono::duration<double>(_info.dt).count()

@AddisonFarley
Copy link
Contributor

I've submitted a PR for your suggested change to the 26 files I found with this function. Your solution made sense as a double is all that is needed to track any number 0>x>1.

This is my first contribution to GZ-Sim and I tried to follow the contribution guide to the best of my ability. Any feedback is more than welcome!

@github-project-automation github-project-automation bot moved this from Inbox to Done in Core development Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants