-
Notifications
You must be signed in to change notification settings - Fork 69
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
Connect/Disconnect notification/callback support #330
Comments
@ivanpauno @wjwwood @asorbini @MiguelCompany @alsora @SteveMacenski @mikeferguson This is to open discussion, could you share your thoughts? |
Adding this like a new rmw_event_t seems reasonable to me |
I think this is super useful - at the moment, you can't easily build something like rgbd_launch in ROS2 (where all of the various pipeline elements are lazy publishers/subscribers) - I didn't even realize this wasn't already ticketed somewhere... I had some notes about use cases (and my current lazy subscriber workaround with a timer that checks get_subscription_count once a second) here: https://www.robotandchisel.com/2020/06/16/ubr1-on-ros2/ EDIT: there was also additional information in my post on 5 things ROS2 needed in 2020: https://www.robotandchisel.com/2020/07/29/five-things-ros2/ |
I'm not familiar with the In general this looks a great feature to add. |
the main difference is, application can be notified with event on connect/disconnect. |
This would be a nice addition, probably as a new We could do the same for subscriptions, though we should probably have that as a separate issue. |
We all agreed adding new event. |
We should remove |
@Barry-Xu-2018 I don't think so, since that repository is there the tests for this feature should be added. |
Thank you for your kind reminder. |
In |
@Barry-Xu-2018 thanks for checking, i was thinking that there would be some related code or test cases in there, so just make sure that everything we may change on that table at 1st. if we do not need to update, that is also fine, i will remove |
This issue has been mentioned on ROS Discourse. There might be relevant details there: https://discourse.ros.org/t/ros-2-tsc-meeting-minutes-2023-01-19/29423/1 |
Related PRs have been submitted.
TODO
|
@Barry-Xu-2018 thanks, i will be reviewing for sure. CC: @iuhilnehc-ynos |
@Barry-Xu-2018 Can we start the CI with all dependent PRs to see all related tests complete w/o error? i will be working on review at the same time. |
Yes. After all are rebased, I will ask @iuhilnehc-ynos help to run CI. |
CI was done. The failed test cases on Windows are unrelated to my change. |
Everything up to |
@mjcarroll appreciate it for taking care of those PRs 👍 thanks a lot 🙇♂️ (ありがとう) |
the rest will be #330 (comment), can you also address these? |
Yeah, I am writing demo code and updating the document. |
Demo PR was submitted. ros2/demos#607 About the document, I didn't find a detailed description of the "event" in the document. Only a brief introduction is provided, and there are no examples given. |
I think that would be better to add an introduction like this, i left some comments on it, can you make the PR? and, probably doc for inconsistent topic, we would want to create another PR. |
Okay. I created a PR ros2/ros2_documentation#3406. |
ros2/rmw_fastrtps#683 has been merged. |
complete all related PRs, see https://github.com/ros2/rmw/issues/330#issue-1371797574#353 i will go ahead to close this issue. |
This issue has been mentioned on ROS Discourse. There might be relevant details there: https://discourse.ros.org/t/ros-2-alternative-middleware-report/33771/19 |
This implements #780 for ROS 2 distributions after Iron, where we have: * Connect/disconnect callbacks, per ros2/rmw#330 (this made it into Iron) * Updated APIs in ros-perception/image_common#272 (this is only in Rolling currently)
Hello, This is a great feature for testing in ROS 2 - you can verify all topics are matched before starting tests.
Thanks! |
unfortunately I do not think so, originally we did not consider the backport of this feature. this adds many APIs including RMW interfaces.
we can check if corresponding publishers or subscribers on the topic, which uses i think this could be used to check if Note: with that is pretty much that i know, hopefully this helps. |
This is a really cool feature but it feels quite verbose for the very common use case: "publish only if there are subscribers". For that I still prefer something as simple as: if (publisher_->get_subscription_count() > 0) {
/* heavy work for visualization
*/
publisher_->publish(msg);
} It was mentioned that the drawback with this approach is the need to constantly poll with an external timer but in many cases this block of code would already be in a timer/subscriber callback (you can see many examples in Nav2). So apart from this drawback, is there anything else matched events are better with? Thanks |
For what it is worth, that already exists, though with a caveat. The caveat is that because of intra-process publishing, just getting the subscription count isn't enough; you also need to get the intra-process subscription count. With that in mind, you can do:
|
Yes I know it exists, thanks for mentioning the caveat though. I was just asking if this method has any other known drawbacks compared to matched events + counting subscribers manually (which would be a much more verbose solution for this simple yet very common use case) |
For different use cases, you can choose different methods. |
@tonynajjar the original motivation is, we need to create the data pipeline dynamically only if it comes necessary for network and cpu efficiency as we do develop edge devices. having polling mechanism and calling API to query the network connectivity is not really cost effective cz we have to do that every single time and most likely the network connectivity has not changed yet... i think it all comes down to the use case. (we sometimes use something i want to mention about the drawback (maybe not drawback but more like feature) as comparison is, that the matched event is synchronized information, that guarantees how the mached endpoits changes. for example, publisher online -> get_sub_count called and 0 returns -> subscriber online -> subscriber offline -> get_sub_count called and 0 returns, this case it appears that nothing has happened in the network connectivity. but it actually did. the same thing could happen that publisher can see the same 1 count of subscription, but this subscription could be a different one in between @Barry-Xu-2018 please correct me if i got anything wrong above. |
I see your point about not missing any information in between API calls. Thanks everyone for the clarifications, hopefully that helps more people in the future. |
This implements ros-perception#780 for ROS 2 distributions after Iron, where we have: * Connect/disconnect callbacks, per ros2/rmw#330 (this made it into Iron) * Updated APIs in ros-perception/image_common#272 (this is only in Rolling currently)
Feature request
Feature description
rclcpp
andrclpy
, user application can register user callback that will be called when subscription connects or disconnects on the topic for publisher.ROS 1 Similar function: https://docs.ros.org/en/noetic/api/roscpp/html/classros_1_1NodeHandle.html#ae4711ef282892176ba145d02f8f45f8d
Use case
On visualization node, to suppress unnecessary CPU utilization, enable its visualization process only when RViz is connected.
Related Information / Reference
Implementation considerations
Since all tier-1 rmw implementation is DDS implementation, we can support this feature with
on_publication_matched
ofDataWriterListener Interface
. (we confirmed the code of Fast-DDS.)The text was updated successfully, but these errors were encountered: