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.
Asked by jeremya on 2022-04-06 11:06:40 UTC
Answers
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.
Asked by msmcconnell on 2022-05-13 07:45:43 UTC
Comments
It's been suggested to try two things:
Asked by jeremya on 2022-04-13 10:16:54 UTC