ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

There's currently no way to emulate the on connect or on disconnect SubscriberStatusCallback (described here: https://docs.ros.org/api/roscpp/html/classros_1_1NodeHandle.html#ae4711ef282892176ba145d02f8f45f8d) in ROS 2. The underlying middlewares we support are capable of it, but we simply haven't exposed this information up to the ROS api yet. However it is on our roadmap, but not slated for inclusion into the next release:

Expose matched publisher / subscriber count (rather than only based on the topic name)

-- https://github.com/ros2/ros2/wiki/Roadmap

This could be implemented by someone else in time for the release, but it would be a moderately complex set of changes.


However, the other half of this puzzle is the ros::SingleSubscriberPublisher which allows you to publish a message to only the new subscriber and not the existing subscribers, and that's the argument of the SubscriberStatusCallback. See:

https://answers.ros.org/question/11327/argument-for-subscriberstatuscallback-in-advertise/

I currently don't know of a simple way to do that with our current system. So the question is (please edit your question rather than making another answer) do you need that feature too, or just a callback to know when something has connected?