Add graph method to wait for publishers#1621
Draft
jacobperron wants to merge 2 commits intorollingfrom
Draft
Conversation
Wrapping the rcl API. Signed-off-by: Jacob Perron <jacob@openrobotics.org>
c455b59 to
50ba777
Compare
Collaborator
fujitatomoya
left a comment
There was a problem hiding this comment.
overall it looks good to me.
Comment on lines
+309
to
+310
| * E.g. Do not call this after calling `rclcpp::GraphListener::get_graph_event()`. | ||
| * If this happens an exception is thrown. |
Collaborator
There was a problem hiding this comment.
Out of curiosity, I've tried to replicate this undefined behavior scenario and I didn't notice anything unexpected:
me neither.
if possible, could anyone elaborate what kind of exception we are going to get? i cannot see it precisely...
Member
Author
There was a problem hiding this comment.
Sorry, this PR is not complete. I imagine that we should guard against concurrent usage in the implementation and throw an exception (see the TODO in node_graph.cpp).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Wrapping the rcl API introduced in ros2/rcl#907
There are some issues with this change. Opening as a draft for visibility.
The issue boils down to using the node's graph guard condition in multiple wait sets concurrently.
The
rcl_wait_for_*API uses the graph guard condition in a wait set as part of it's implementation.The
rclcpp::GraphListeneralso uses the graph guard condition, running in a separate thread:rclcpp/rclcpp/src/rclcpp/graph_listener.cpp
Lines 175 to 180 in 091a8bc
This means that if a users try to use the
GraphListener, which is lazily started, and then try to call one of thercl_wait_for_*functions we get undefined behavior.Out of curiosity, I've tried to replicate this undefined behavior scenario and I didn't notice anything unexpected:
I think rather than wrapping the rcl functions, we could add similar implementations based on the
rclcpp::GraphListener. This way we avoid undefined behavior.We could additionally expose the
rclfunctions, but we should "guard" against using the same guard condition as the GraphListener (e.g. detect that they are both being used concurrently and throw an informative exception).Alternatively, we could add support to
rcl(andrmw?) for multiple graph guard conditions. Then, therclfunctions could use a different guard condition than therclcpp::GraphListener. I think this approach is more involved and is probably not worth the added complexity.