ROS2 per topic intra-process communications setup
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.
It's been suggested to try two things: