ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Make ROS2 use zero-copy [closed]

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

uthinu gravatar image

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

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";
native.get()->publish(message);

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
1

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

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:

https://github.com/ros2/rclcpp/blob/9...

edit flag offensive delete link more

Question Tools

1 follower

Stats

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

Seen: 993 times

Last updated: Dec 10 '18