message_filters icon indicating copy to clipboard operation
message_filters copied to clipboard

std::unique_ptr not supported

Open AndreasAZiegler opened this issue 5 years ago • 1 comments

In order to get zero-copying inter-communication, std::unique_ptr are required. Unfortunately message_filters does not yet support std::unique_ptr.

AndreasAZiegler avatar Jul 01 '19 11:07 AndreasAZiegler

Is there any update?

AndreasAZiegler avatar Apr 06 '20 08:04 AndreasAZiegler

duplicate with https://github.com/ros2/message_filters/issues/28 which is already answered by https://answers.ros.org/question/325146/how-can-i-implement-efficient-intra-process-communication-with-message-filters/

ZhenshengLee avatar Sep 06 '23 09:09 ZhenshengLee

can be closed.

ZhenshengLee avatar Sep 06 '23 09:09 ZhenshengLee

I'm also finding myself needing this. Any update?

can be closed.

I wouldn't close this issue, the answer provided only proposes a workaround, it would be nice to have a PR for this if it's a viable solution approved by the maintainers

tonynajjar avatar Sep 29 '23 10:09 tonynajjar

I agree. I will try to implement if I have time, but I'm not making any real commitment, so feel free to do the same and open a PR pointing to this issue.

roncapat avatar Sep 29 '23 11:09 roncapat

Moreover, be aware that rolling supports Type Adaptation (did a PR some time ago #95). This means that, in conjunction with intra-process comms, we would be able then to leverage the full spectrum of solutions to optimize wide ROS data exchange.

roncapat avatar Sep 29 '23 11:09 roncapat

I'm giving it a look. In my experience, I always used const MessageType::ConstSharedPtr as subscription callback type, and built MessageType::UniquePtr to be later ->publish(std::move(...))d. message_filters make use of std::shared_ptr<MessageType const> signature, which is equivalent to MessageType::ConstSharedPtr.

It made be worth a try just to add const and see what happens as a first iteration.

roncapat avatar Oct 05 '23 13:10 roncapat

To be completely honest, it seems to me that: https://github.com/ros2/rclcpp/blob/9019a8d9b7710bd405a5a31c8d74fdc9ffa686dd/rclcpp/include/rclcpp/any_subscription_callback.hpp#L935 just requires the pointed object of the shared_ptr to be const, not necessarily the pointer itself.

May I ask to you all to verify?

roncapat avatar Oct 05 '23 23:10 roncapat

@tonynajjar @AndreasAZiegler may I ask you to test #103 and see if you get any performance gain?

roncapat avatar Oct 09 '23 16:10 roncapat

Hey, I can try tomorrow. What should I be on the lookout for exactly? CPU consumption? Anything else? As far as I know the msg memory address should be the same regardless of the change in the PR right?

tonynajjar avatar Oct 09 '23 16:10 tonynajjar

@tonynajjar was the address already the same in previous test of yours?

Because otherwise I may have lost the meaning of the problem in your previous comment:

I'm also finding myself needing this. Any update?

May I ask you to clarify what was the issue/need, if different?

roncapat avatar Oct 09 '23 16:10 roncapat

@tonynajjar was the address already the same in previous test of yours?

When I made my first comment I hadn't tested anything yet, I was about to start working on a project in which I needed message_filters to support IPC and I took it for granted that it doesn't because of this ticket.

Now I did some tests on a particular setup of mine and without your changes, I'm able to get the same msg address for both the publisher and the message_filters subscriber. That's the only indication I know of that suggests that IPC is working. Currently I don't have a minimal reproducible example I can share, I'll try to find some time for that

tonynajjar avatar Oct 10 '23 09:10 tonynajjar

Ok, nice to know. Then, I do not see any other internal copy or other blocking issue preventing message_filters to be IPC-friendly :)

roncapat avatar Oct 10 '23 09:10 roncapat

@clalancette at least now we know this one has to be closed again then ;)

roncapat avatar Oct 10 '23 21:10 roncapat