-
Notifications
You must be signed in to change notification settings - Fork 227
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
Support zero-copy intra-process publishing #306
Support zero-copy intra-process publishing #306
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you planning to make some changes in image_transport_plugins
too ? using this new API ?
I don't see how the compressed image transports can take advantage of the image ownership as they still have to copy the data, BUT they might avoid copying the resulting compressed data by publishing it using |
I marked the method as deprecated. Also, I think that we should not add default implementations that are empty or don't make sense. I also can't make these methods abstract, so instead I just throw exceptions. @ahcorde What do you think? |
09f4756
to
9beb134
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems reasonable to me
@ahcorde Could this be backported to Jazzy? |
https://github.com/Mergifyio backport jazzy |
✅ Backports have been created
|
(cherry picked from commit fd51363)
(cherry picked from commit fd51363) Co-authored-by: Błażej Sowa <[email protected]>
ROS2 supports intra-process communication when composing multiple nodes in a single process. It additionally can avoid doing any copies of the data when published using
std::unique_ptr<MessageT>
and subscribed usingshared_ptr<const MessageT>
orstd::unique_ptr<MessageT>
(at most 1 subscriber)This PR is my attempt to add support for publishing using
std::unique_ptr
without breaking any of the existing APIs.The idea is that:
raw
can take advantage of the ownership).Publisher::publish(sensor_msgs::msg::Image::UniquePtr message)
method first publishes using the const reference to plugins that don't supportstd::unique_ptr
, then moves the ownership of the message to (at most 1) plugin that supports it.std::unique_ptr
and has subscriptions, we pass the ownership to only one such plugin (the first we find), and for the rest we still use const reference, delegating doing any extra copies to plugin implementations.Related issues/prs:
#212
#215
#216 (kinda)