-
Notifications
You must be signed in to change notification settings - Fork 472
Add new RCL_RAW_STEADY_TIME changes #2910
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
base: rolling
Are you sure you want to change the base?
Conversation
Signed-off-by: Sai Kishor Kothakota <[email protected]>
5793e51
to
42d3dbc
Compare
I am confused by this commit. The code for steady and steady raw looks identical. @saikishor am I overlooking sometime ? |
Yes, they are pretty much similar. What changes is that the STEADY_CLOCK uses |
As far as I can see the rclcpp implementation uses std::chrono::steady_clock for sleeping in both cases (steady and steady raw). This seems odd. |
I agree, it is not ideal. The conditional variable |
yeah, right. i think we are going to have to keep the platform dependent code to support |
@jmachowinski how about we bring this topic to the PMC meeting before platform dependent implementation? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
overall, lgtm except sleep APIs behavior.
Yes, please let me know how you want me to proceed after the PMC meeting. Thank you for taking time to review @fujitatomoya In the meantime, I'll implement things on rclpy side |
Signed-off-by: Sai Kishor Kothakota <[email protected]>
bbe7d2e
to
3b024cc
Compare
We discussed this shortly at the PMC meeting.
Currently this patch silently falls back to the non slew free clock if using timers etc. I guess in order to support this fully, one would need to implement a custom std::chrono::clock class using the now from rclutils and providing the specializations for wait_until for the std::conditional_variable. |
@jmachowinski Thank you for the summary
If the platform doesn't support MONOTONIC_RAW, then the behavior will be similar to MONOTONIC or RCL_STEADY_TIME. There is nothing much we can do in that case.
The problem is that we cannot directly use std::conditional_variable in these situations as it internally converts the clock to system_clock and then the behaviour would be similar.
https://en.cppreference.com/w/cpp/thread/condition_variable/wait_until.html |
That's actually my biggest problem with the proposed patch. As enduser one would request a MONOTONIC_RAW clock and currently it silently falls back to MONOTONIC. The timers won't work on the requested time type, and the sleep functions won't work either as suggested by the API. Basically the only thing that might work as expected is rclcpp::Clock::now(). Looking at the implementation in rclutils, even this one has a silent fallback. Note that the timer implementation in rcl_wait is flawed in the way that a relative wait time is computed from all the clocks and given to rmw_wait as a timeout. The underlying RWM implementation will treat this timeout most likely as MONOTONIC. Meaning that if there is a clock adjustment active, rmw_wait will either take to long, or wake up to early constantly, as it is affected by the clock adjustment. On Friday there is a client working group meeting I think it would be beneficial if you could join the meeting. |
@jmachowinski thank you so much for taking care of this. and sorry for missing last PMC meeting because of my relocation from US to Japan.
totally agree with you. this is surprise for user, and hard to find out. |
@saikishor We had a lengthy discussion about this in the CWG and came to the conclusion that the rcutils PR looks useful to us, but the one for rcl and rclcpp seem flawed, or we are missing something. Would you mind sharing more details about your use case ? |
our use case is that, sensing data coming from sensing framework use only monotonic raw clock time stamp. and of course we need to handle these sensing data with ROS 2 application, that requires ROS 2 application should be able to handle the compatible hardware clock with sensing data from the system. |
@saikishor friendly ping. |
@fujitatomoya sorry I was super busy these days right before my vacation. I've checked the replies, but couldn't find time to reply properly. I'll surely get back to them ASAP. Sorry for the inconvenience 🙏🏽🙏🏽 |
The latency is coming due to the fact that
I'll respond to your earlier message soon, in the meantime this is my usecase. With the integration of more industrial grade motor control boards like ELMO on our robots, we have observed in ROS 1 with ros_control, that as the NTP clock adjustment affect the frequency at which the EtherCAT commands are send and thereby making the motors make rattling sound. For critical applications, it is very important that the clock is consistent to trigger control. I want to improve this part in ros2_control, so everyone can make use of it. I hope this gives you some context of my usecase. |
@saikishor @jmachowinski thanks for taking care of this. how about taking ros2/rcutils#507 for now? i think this is still useful for end user application to get the time with monotonic raw clock via ROS 2 API? |
If the platform doesn't support MONOTONIC_RAW, I think it is better to fallback to the MONOTONIC, because if not released packages would have to somehow add the logic based on the platform. Maybe we can add a WARN_ONCE print to mention that it is failing back to MONOTONIC.
I'm sorry I missed the meeting that day.
@fujitatomoya failing might not a good idea, then applications instead of running would simply crash on unsupported platforms, this means users will have to open PRs to add platform dependent logic in order to solve it. Instead a simple warning should work right?, this is all about performance rather than functionality. What do you think?
@fujitatomoya sure. |
@fujitatomoya what's the status of this PR ? |
because of the inconsistent behavior for user application explained in #2910 (comment), we are not inclined to take this API to the client layer yet. i think that rcutils interfaces are fine as low level implementation. |
Description
Needs ros2/rcl#1248 and ros2/rcutils#507
Fixes ros2/rcutils#488
Is this user-facing behavior change?
NO
Did you use Generative AI?
NO
@fujitatomoya FYI