-
Notifications
You must be signed in to change notification settings - Fork 41
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
executor ignore canceled timers #220
executor ignore canceled timers #220
Conversation
this is similar behavior observed in rclcpp, canceled timers shouldn't be handled Signed-off-by: Ilya Guterman <amfernusus@gmail.com>
bd18fcd
to
369d5df
Compare
Could you provide some examples of how is a timer cancelled in RCLC? Is this reversible? Thanks for the contribution @amfern |
@mergify backport galactic foxy |
🟠 Waiting for conditions to match
Hey, I reacted but my real name is @Mergifyio |
Codecov Report
@@ Coverage Diff @@
## master #220 +/- ##
==========================================
- Coverage 63.58% 63.49% -0.09%
==========================================
Files 16 16
Lines 2150 2153 +3
Branches 642 643 +1
==========================================
Hits 1367 1367
- Misses 469 471 +2
- Partials 314 315 +1
Continue to review full report at Codecov.
|
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.
Thanks for your contribution, @amfern.
It is more explicit, that we handle that case - but does not affect the behavior - in my understanding.
- The timer is still handled.
- the return code
rc
is returned as in the original source code. - the only difference is, that the error
RCL_RET_TIMER_CANCELED
is not treated as an error (no debug output).
Did I miss anything?
Added regression test |
Signed-off-by: Your Name <you@example.com>
497dc9c
to
b61f8ea
Compare
Signed-off-by: Your Name <you@example.com>
046f1dc
to
b72a102
Compare
Signed-off-by: Your Name <you@example.com> Signed-off-by: Pablo Garrido <pablogs9@gmail.com>
I use microros In my company and i had the need to halt publishers and resume at later point. I run rclc_executor_spin_some() with 0 timeout, because the current OS we use internally isn't POSIX like and single threaded, so I try to block the main thread as little as possible.
|
@JanStaschulat if you are ok with tests and the fix, we can merge and backport |
@JanStaschulat @pablogs9 I appreciate the swift reply and the test. |
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.
@amfern "But when I would cancel any timer rclc_executor_spin_some(executor, 0); will exit prematurely with error RCL_RET_TIMER_CANCELED without handling publishers and subscribers. So it seems to me the cancel timer behavior is broken."
Thanks for the explanation. With your fix, the error RCL_RET_TIMER_CANCELED
will still be returned, in case the timer was cancelled. How does this solve your problem? Could you add a unit test in rclc/test
directory, that shows a minimal example of this behavior?
Should the return value in this case be changed to RCL_RET_OK
?
With this patch, the error will be ignored and the retuned value of Line 1701 in f8de341
I think the unit test @pablogs9 added pretty much covers this case. But I can add another unit test with subscriber and publisher and make sure they are getting called. How do I run the tests? Is there a guide? |
You can just add a unit test, like Pablo did, and then call |
"With this patch, the error will be ignored and the retuned value of _rclc_execute will be RCL_RET_OK." Hmm, I can't see this. The return-code is assigned to Line 1670 in f8de341
|
Signed-off-by: Ilya Guterman <amfernusus@gmail.com>
5e2b33b
to
2557d26
Compare
Signed-off-by: Ilya Guterman <amfernusus@gmail.com>
35149ee
to
b6157e9
Compare
if i run the test @pablogs9 added, the test Why it doesn't fail? @JanStaschulat Should it fail? |
My hypothesis: Line 1039 in f8de341
So Line 1401 in f8de341
Line 1375 in f8de341
Therefore, the switch/case statement of the This would explain that the unit test works without this fix. Could you insert a simple If this is the case, then I wonder, why it did not work in your application. |
yes, i can add the printf, but later today. So is it possible for the timer to become ready and canceled at the same time? And because i execute one loop each time around, i cancled the timer when it was ready but not handled yet. |
@amfern But maybe you have the case, where the timer is ready, returned in the wait set (internally the executor marks it as |
everything is single threaded in my application |
…the test Signed-off-by: Ilya Guterman <amfernusus@gmail.com>
84d24ba
to
5bd205e
Compare
I added
Also, I removed this patch and recompiled arduino_micro_ros and this issue didn't reproduce anymore, so I guess recompiling was what solved the problem and not this patch. I am ok with not merging this patch, but i leave it to your discretion. |
Thanks for your test and feedback. So I will close this pull request and merge. |
* executor ignore canceled timers this is similar behavior observed in rclcpp, canceled timers shouldn't be handled Signed-off-by: Ilya Guterman <amfernusus@gmail.com> * Add regression test Signed-off-by: Your Name <you@example.com> * Uncrustify Signed-off-by: Your Name <you@example.com> * Fix warning unused Signed-off-by: Your Name <you@example.com> Signed-off-by: Pablo Garrido <pablogs9@gmail.com> * return sucess on cancled timer Signed-off-by: Ilya Guterman <amfernusus@gmail.com> * validate cancled timer doesn't impact the execution of other handlers Signed-off-by: Ilya Guterman <amfernusus@gmail.com> * executor_spin_publisher_timer_cancelled cancel timer on beggining of the test Signed-off-by: Ilya Guterman <amfernusus@gmail.com> Co-authored-by: Pablo Garrido <pablogs9@gmail.com> (cherry picked from commit 27b4d4f)
* executor ignore canceled timers this is similar behavior observed in rclcpp, canceled timers shouldn't be handled Signed-off-by: Ilya Guterman <amfernusus@gmail.com> * Add regression test Signed-off-by: Your Name <you@example.com> * Uncrustify Signed-off-by: Your Name <you@example.com> * Fix warning unused Signed-off-by: Your Name <you@example.com> Signed-off-by: Pablo Garrido <pablogs9@gmail.com> * return sucess on cancled timer Signed-off-by: Ilya Guterman <amfernusus@gmail.com> * validate cancled timer doesn't impact the execution of other handlers Signed-off-by: Ilya Guterman <amfernusus@gmail.com> * executor_spin_publisher_timer_cancelled cancel timer on beggining of the test Signed-off-by: Ilya Guterman <amfernusus@gmail.com> Co-authored-by: Pablo Garrido <pablogs9@gmail.com> (cherry picked from commit 27b4d4f)
✅ Backports have been created
|
* executor ignore canceled timers this is similar behavior observed in rclcpp, canceled timers shouldn't be handled Signed-off-by: Ilya Guterman <amfernusus@gmail.com> * Add regression test Signed-off-by: Your Name <you@example.com> * Uncrustify Signed-off-by: Your Name <you@example.com> * Fix warning unused Signed-off-by: Your Name <you@example.com> Signed-off-by: Pablo Garrido <pablogs9@gmail.com> * return sucess on cancled timer Signed-off-by: Ilya Guterman <amfernusus@gmail.com> * validate cancled timer doesn't impact the execution of other handlers Signed-off-by: Ilya Guterman <amfernusus@gmail.com> * executor_spin_publisher_timer_cancelled cancel timer on beggining of the test Signed-off-by: Ilya Guterman <amfernusus@gmail.com> Co-authored-by: Pablo Garrido <pablogs9@gmail.com> (cherry picked from commit 27b4d4f) Co-authored-by: Ilya guterman <amfernusus@gmail.com>
* executor ignore canceled timers this is similar behavior observed in rclcpp, canceled timers shouldn't be handled Signed-off-by: Ilya Guterman <amfernusus@gmail.com> * Add regression test Signed-off-by: Your Name <you@example.com> * Uncrustify Signed-off-by: Your Name <you@example.com> * Fix warning unused Signed-off-by: Your Name <you@example.com> Signed-off-by: Pablo Garrido <pablogs9@gmail.com> * return sucess on cancled timer Signed-off-by: Ilya Guterman <amfernusus@gmail.com> * validate cancled timer doesn't impact the execution of other handlers Signed-off-by: Ilya Guterman <amfernusus@gmail.com> * executor_spin_publisher_timer_cancelled cancel timer on beggining of the test Signed-off-by: Ilya Guterman <amfernusus@gmail.com> Co-authored-by: Pablo Garrido <pablogs9@gmail.com> (cherry picked from commit 27b4d4f) Co-authored-by: Ilya guterman <amfernusus@gmail.com>
Thanks @JanStaschulat |
This is similar behavior observed in rclcpp, canceled timers shouldn't be handled
https://github.com/ros2/rclcpp/blob/e03e98220d7c4a79bfc934d43d762e017b493e9c/rclcpp/include/rclcpp/timer.hpp#L213