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

Is RealtimeClock() still needed with ROS 2? #241

Open
christophfroehlich opened this issue Dec 18, 2024 · 8 comments
Open

Is RealtimeClock() still needed with ROS 2? #241

christophfroehlich opened this issue Dec 18, 2024 · 8 comments

Comments

@christophfroehlich
Copy link
Contributor

christophfroehlich commented Dec 18, 2024

We don't use it anywhere.

Reading the discussion from #23, are those now realtime safe?

  • std::chrono::steady_clock::now()
  • rclcpp::Clock().now()
  • rclcpp::Clock::SharedPtr rclcpp::node_interfaces::NodeClockInterface::get_clock()-> now()
@christophfroehlich
Copy link
Contributor Author

@christophfroehlich
Copy link
Contributor Author

copilot says

The function std::chrono::steady_clock::now() is generally considered to be real-time safe. The steady_clock is designed to be monotonic, meaning it won't be affected by changes in the system clock (e.g., daylight saving time adjustments or manual changes to the system time). This makes it suitable for measuring intervals in real-time systems.

However, the real-time safety of std::chrono::steady_clock::now() can depend on the specific implementation and the underlying hardware. In most standard library implementations, it is designed to be efficient and should not block or cause significant delays, making it appropriate for real-time applications.

@bmagyar
Copy link
Member

bmagyar commented Dec 19, 2024

Less code, healthier repo. Let's remove it

@saikishor
Copy link
Member

I think by default the rclcpp STEADY clock might be real-time safe. We have to check it properly. I mean calling stead clock and rclcpp::Clock to see if we get same information.

However, we cannot use steady clock everywhere in the controllers due to the ROS clock, as it is mostly needed for simulation. Instead with stead clock you only have wall time

@christophfroehlich
Copy link
Contributor Author

christophfroehlich commented Dec 19, 2024

I think by default the rclcpp STEADY clock might be real-time safe.

You mean that SystemTime is not?

We have to check it properly. I mean calling stead clock and rclcpp::Clock to see if we get same information.

But this is not the point of this issue, because the RealtimeClock is only a wrapper around a rclcpp::Clock, the user has to decide which clock_type to pass into it.

However, we cannot use steady clock everywhere in the controllers due to the ROS clock, as it is mostly needed for simulation. Instead with stead clock you only have wall time

I agree.

@saikishor
Copy link
Member

You mean that SystemTime is not?

SystemTime is not monotonic so it is better not used in the RT applications.

If no other repo is using it, we can remove it

@christophfroehlich
Copy link
Contributor Author

I've searched on github for it and haven't found any occurrences except of forks of this repo. I'll deprecate it for one release cycle

@saikishor
Copy link
Member

I've searched on github for it and haven't found any occurrences except of forks of this repo. I'll deprecate it for one release cycle

Make sense. Let's do that!

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

3 participants