Ask Your Question

Make ROS2 use zero-copy [closed]

asked 2018-12-10 05:02:41 -0500

uthinu gravatar image

updated 2018-12-10 05:04:03 -0500

Hello, I would want an intra-process communication without copying of messages. Does it work by default?

For now, the publisher code is:

auto message = make_unique<std_msgs::msg::String>();
message.get()->data = someString;
cout << "INPUT " << (void*)&(message.get()->data) << "\n";

which calls publish(std::unique_ptr<MessageT, MessageDeleter> & msg).

The subscriber code is:

    ...subscriberMethod(const std_msgs::msg::String::UniquePtr message) {
    cout << "OUTPUT " << (void*)&message.get()->data << "\n";
    string text = message.get()->data.c_str();

This subscriber method is directly registered with create_subscription. I get an output like

INPUT 0x7fab70000b60
OUTPUT 0x7fab64000b60

that is, there is some copying in between, even if both the publisher and the subscriber are within the same process. I tried the above with shared_ptr, but the addresses were also different.

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by allenh1
close date 2018-12-10 09:48:24.200721

1 Answer

Sort by ยป oldest newest most voted

answered 2018-12-10 05:17:36 -0500

William gravatar image

Hello, I would want an inter-process communication without copying of messages. Does it work by default?

No, not right now, see:

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2018-12-10 05:02:41 -0500

Seen: 519 times

Last updated: Dec 10 '18