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

ROS2 per topic intra-process communications setup

asked 2022-04-06 11:06:40 -0500

jeremya gravatar image

updated 2022-06-22 15:41:04 -0500

If you don't use intra-process comms on the whole node by setting rclcpp::NodeOptions().use_intra_process_comms(true), you can apparently also set per publisher/subscriber by using rclcpp::PublisherOptions. For example:

  rclcpp::PublisherOptions po;
  po.use_intra_process_comm = rclcpp::IntraProcessSetting::Enable;
  pub = this->create_publisher<std_msgs::msg::Int32>("/topic", rclcpp::QoS(10).reliable(), po);

and

rclcpp::SubscriptionOptions so;
so.use_intra_process_comm = rclcpp::IntraProcessSetting::Enable;
sub =
  this->create_subscription<std_msgs::msg::Int32>(
    "topic", rclcpp::QoS(10).reliable(), std::bind(
    &MyNode::SubCallback,
    this, _1), so);

When I print the addresses similar to the intra_process_demo, they don't match.

[main_container-1] [INFO] [1649258398.387019633] [check_node]: sent message with address: 0x563D1623A310
[main_container-1] [INFO] [1649258398.387542149] [other_node]: Received message with address: 0x563D16210700

The rest of the publishing and subscribing is similar to the intra_process_demo. Any ideas? Any other data I could collect? Is there a better way to verify intra-process comms are connecting and not using the RMW implementation?

Update: I must have had some other issue because I tried again and found it to work.

edit retag flag offensive close merge delete

Comments

It's been suggested to try two things:

  1. set Log level to "DEBUG"
  2. try going back to intra-process for the whole node
jeremya gravatar image jeremya  ( 2022-04-13 10:16:54 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-05-13 07:45:43 -0500

msmcconnell gravatar image

I'm not sure what the status in galactic is, but while working with OpenRobotics on a project using Foxy, I was shown that your subscriber callbacks must use the unique_ptr instead of shared_ptr for intra-process comms to preserve the address. Try changing your callback signature to unique_ptr and see if you get the same result.

edit flag offensive delete link more

Question Tools

3 followers

Stats

Asked: 2022-04-06 11:06:40 -0500

Seen: 317 times

Last updated: Jun 22 '22