-
Notifications
You must be signed in to change notification settings - Fork 91
WaitForTopics: let the user inject a callaback to be executed after starting the subscribers
#356
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
WaitForTopics: let the user inject a callaback to be executed after starting the subscribers
#356
Conversation
WaitForTopics: let the user inject callables after starting subscribers
adityapande-1995
left a comment
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.
I've posted some questions worth discussing here : #348 (comment)
@adityapande-1995 @clalancette I have added a more comprehensive sample code in commit 5aa51d7 |
|
@adityapande-1995 @clalancette |
3f96cb5 to
b8004ab
Compare
|
@osrf-jenkins retest this please |
|
@adityapande-1995 @clalancette How would you test a node that is subscribed to a topic with a single |
|
@osrf-jenkins retest this please |
|
@adityapande-1995 @methylDragon Until now, I have been using my fork at work for our project, but it would give us more confidence if we could just use the official repository, or even better if this PR could end up in the released version on https://index.ros.org/packages/. |
|
@osrf-jenkins retest this please |
|
@LastStarDust my apologies, taking a look now |
launch_testing_ros/test/examples/wait_for_topic_inject_callback.py
Outdated
Show resolved
Hide resolved
WaitForTopics: let the user inject callables after starting subscribersWaitForTopics: let the user inject callables to be executed after starting the subscribers
|
@adityapande-1995 @methylDragon I fixed some linting errors and now the checks are finally passing. |
|
Hello, could we get a maintainer to look at this PR? |
WaitForTopics: let the user inject callables to be executed after starting the subscribersWaitForTopics: let the user inject callabacks to be executed after starting the subscribers
WaitForTopics: let the user inject callabacks to be executed after starting the subscribersWaitForTopics: let the user inject a callaback to be executed after starting the subscribers
|
@methylDragon is OOO, but I will ping him to look when he is back. |
Ryanf55
left a comment
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.
I tested this on a backport in humble in our own CI and it is very reliable with some minor mods.
|
@Ryanf55 Hello, I would like to resume working on this PR. Could you please take a look at the conversations you opened and resolve the ones you think are resolved? |
|
@osrf-jenkins retest this please |
Yep, all of the issues we found are still problems, and we never found a good workaround for doing this generically in Sorry, we've just spent an exorbitant amount of time on this trying to get this reliable in humble and could never figure out a way that wasn't extremely coupled to knowing exactly what was running and manual graph introspection hard-coded into our test framework. I'm optimistic that upgrading distros will make it easier, but this way of testing in python is not something we're going to pursue any further unless anyone can give us a reasonable approach that works without hard-coded timeouts/sleeps for discovery that fail on slower runners. |
|
@Ryanf55 Thank you for sharing the situation. I am sorry we could not figure out how to make this work reliably in Humble. |
Signed-off-by: Giorgio Pintaudi <[email protected]> Updates the `WaitForTopics` class to use the term 'trigger' instead of 'callback' for the function executed during the wait. This change clarifies the function's purpose, which is to trigger an action rather than simply provide a callback.
Signed-off-by: Giorgio Pintaudi <[email protected]> Passes the timeout value to the `any_publisher_connected.wait()` call. This ensures that the wait for any publisher connection respects the specified timeout, preventing indefinite blocking.
Signed-off-by: Giorgio Pintaudi <[email protected]> Allows specifying a namespace for the internal node created by `WaitForTopics`. This enables better organization and avoids potential naming conflicts when using `wait_for_topics` in complex launch setups.
Signed-off-by: Giorgio Pintaudi <[email protected]> Co-authored-by: Christophe Bedard <[email protected]> Signed-off-by: Giorgio Pintaudi <[email protected]>
Signed-off-by: Giorgio Pintaudi <[email protected]> Co-authored-by: Christophe Bedard <[email protected]> Signed-off-by: Giorgio Pintaudi <[email protected]>
…t_trigger_test.py Signed-off-by: Giorgio Pintaudi <[email protected]>
Signed-off-by: Giorgio Pintaudi <[email protected]> Adds a blank line after the disable-windows-cli-blocking pragma for improved code style and readability.
✅ Branch has been successfully rebased |
d8866da to
3c52fdd
Compare
|
@christophebedard I think the DCO check is failing after your rebase. I am not sure how to fix that. My guess is that you need to add your sign to each commit. |
|
It's OK, I can just manually set it to pass. |
|
Pulls: #356 |
christophebedard
left a comment
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.
Alright, I think this PR is in a good state and I think the approach helps reduce flakiness.
Let's see if CI passes.
|
The |
|
@LastStarDust it might be worth updating/expanding the integration testing tutorial added in ros2/ros2_documentation#4881 to show an example of |
|
I created an issue for it: ros2/ros2_documentation#5249 |
|
@christophebedard Yes, I am available to improve the documentation. I hope more people become interested in integration testing of ROS2 nodes, and as a result, we will see more advanced and flexible tooling developed. |
|
@LastStarDust do you still want this PR to be backported to Jazzy? I got an email notification, but I can't find your comment anymore |
|
@christophebedard Once all the bugs are ironed out and I am 100% sure this is working as intended, then we can port this to Jazzy. |
|
https://github.com/Mergifyio backport kilted jazzy |
✅ Backports have been created
|
…d after starting the subscribers (#356) Signed-off-by: Giorgio Pintaudi <[email protected]> (cherry picked from commit 1e33f0a)
… starting the subscribers (backport #356) (#504) * `WaitForTopics`: let the user inject a trigger function to be executed after starting the subscribers (#356) Signed-off-by: Giorgio Pintaudi <[email protected]> (cherry picked from commit 1e33f0a)
I created this pull request as a proof of concept for the new feature discussed here: #348.
The ticket description is still correct and relevant, but for clarity's sake, let me summarize and expand on it here.
Let us assume there is a node ("NODE under test" in the diagram) which:
At the moment, there is no way to programmatically test the whole node end-to-end. For that, we need a way to:
Currently, the
WaitForTopicsclass provided by this package takes care of 2 and 3, but there is no mechanism to reliably accomplish 1, due to the asynchronous nature of ROS2 publishers and subscribers.This PR is an attempt to enhance the
WaitForTopicsclass so that it can take care of 1 as well, thus closing the loop. But it might well not be the only solution or the most effective. I am open to any kind of suggestion and guidance.The main issue behind the implementation of such a feature is that in ROS2 the order of creation of publishers and subscribers does matter. They must either always be created in a specific order or be synchronized in some other way.
Below is a cartoon-style diagram illustrating what the end result should look like: