feat: Added lazy subscribe support for GZ image bridge#851
Open
TannerGilbert wants to merge 1 commit intogazebosim:ros2from
Open
feat: Added lazy subscribe support for GZ image bridge#851TannerGilbert wants to merge 1 commit intogazebosim:ros2from
TannerGilbert wants to merge 1 commit intogazebosim:ros2from
Conversation
Signed-off-by: Tanner, Gilbert <gilbertta@edu.aau.at>
ahcorde
requested changes
Mar 13, 2026
Collaborator
ahcorde
left a comment
There was a problem hiding this comment.
Update documentation with the new parameters
| std::string topic_; | ||
|
|
||
| /// \brief ROS node | ||
| std::shared_ptr<rclcpp::Node> node_; |
Collaborator
There was a problem hiding this comment.
I think we don't need to keep this, it's only used in the constructor
|
|
||
| /// \brief Manage Gazebo subscription lifecycle based on ROS subscriber count. | ||
| /// Only active when lazy mode is enabled. | ||
| void Spin() |
Collaborator
There was a problem hiding this comment.
Can we use here CheckSubscribers, the name is quite similar to rclcpp::spin which might generate some confusion
| auto node_ = rclcpp::Node::make_shared("ros_gz_image"); | ||
| node_->declare_parameter("qos", "default"); | ||
| node_->declare_parameter("lazy", false); | ||
| node_->declare_parameter("subscription_heartbeat", 1000); |
Collaborator
There was a problem hiding this comment.
maybe 1 seconds by default is to much, 100ms?
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.
🎉 New feature
Closes #752
Summary
Adds a
lazyoption to theros_gz_imagebridge similar to what already exists for theros_gz_bridge. This can be quite important as cameras usually take a lot of resources that shouldn't be used up if there is no active subscriber.Example command:
Example output:
No ROS subscribers => bridge doesn't subscribe to camera
ROS subscriber => bridge subcribes to camera:
Test it
Create a world with a camera inside it. Then run:
If no subscriber exists
gz topic -i -t /camerashould return no subscriber. After subscribing with for exampleros2 topic hz -w 10 /camerawhen reruninggz topic -i -t /camerathere should be a subscriber visible.Note: I tested on ROS2 Humble and therefore would already have a backport for this version.
Checklist
codecheckpassed (See contributing)Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining
Signed-off-byandGenerated-bymessages.