Skip to content
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

[ROS2] image_proc: replace SubscriberStatusCallback (from ROS1) with a Timer #780

Closed
AndreasR30 opened this issue Oct 6, 2022 · 3 comments
Assignees
Labels

Comments

@AndreasR30
Copy link

In ROS1 the image_proc nodelets only subscribed to the input topic when there was an subscription on their output topic.

In ROS2 the components always subscribe to their input topic. For one component this is not a big problem because in the message callback it is checked with getNumSubscribers() whether there are consuming nodes/components. If there is no subscriber then no work is done.
However, when there are multiple components in the pipeline (e.g. debayer -> rectify), then there will be always a consuming node from the perspective of the debayer component and it will do expensive image processing even though nobody is interested in the output of the image pipeline.

Since there are no such callbacks for image_transport::Publisher or for rclcpp::Publisher, which is internally used, and it does not seem to get such a callback in the near future, I would suggest that the only solution is to check with a timer whether getNumSubscribers() > 0. If so, the node subscribes to its input topic. Otherwise it will unsubscribe from the input topic.

Maybe part of #467

@AndreasR30
Copy link
Author

Related:

@mikeferguson
Copy link
Member

I'm just starting to work on this for Iron (but not with a timer - using the newly exposed matched event). I've got CropDecimate working as an example so far, should have a PR in a few days for all the components. Final goal is to be able to do ros-drivers/openni2_camera#119 (and then make rgbd_launch work)

@mikeferguson mikeferguson self-assigned this May 17, 2023
mikeferguson added a commit that referenced this issue Jan 18, 2024
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)
@mikeferguson
Copy link
Member

Lazy subscribers are now in rolling!

Kotochleb pushed a commit to Kotochleb/image_pipeline that referenced this issue May 27, 2024
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants