diff --git a/nav2_costmap_2d/src/costmap_2d_publisher.cpp b/nav2_costmap_2d/src/costmap_2d_publisher.cpp index 87881bc7caa..965ec68894d 100644 --- a/nav2_costmap_2d/src/costmap_2d_publisher.cpp +++ b/nav2_costmap_2d/src/costmap_2d_publisher.cpp @@ -64,18 +64,34 @@ Costmap2DPublisher::Costmap2DPublisher( auto node = parent.lock(); clock_ = node->get_clock(); logger_ = node->get_logger(); + const auto custom_qos = rclcpp::QoS(rclcpp::KeepLast(1)).transient_local().reliable(); + rclcpp::PublisherOptionsWithAllocator> pub_options; + pub_options.use_intra_process_comm = rclcpp::IntraProcessSetting::Disable; - auto custom_qos = rclcpp::QoS(rclcpp::KeepLast(1)).transient_local().reliable(); + + costmap_pub_ = + std::make_shared>( + node->get_node_base_interface().get(), + topic_name_, + custom_qos, + pub_options + ); // TODO(bpwilcox): port onNewSubscription functionality for publisher - costmap_pub_ = node->create_publisher( - topic_name, - custom_qos); - costmap_raw_pub_ = node->create_publisher( + costmap_raw_pub_ = + std::make_shared>( + node->get_node_base_interface().get(), topic_name + "_raw", - custom_qos); - costmap_update_pub_ = node->create_publisher( - topic_name + "_updates", custom_qos); + custom_qos, + pub_options + ); + costmap_update_pub_ = + std::make_shared>( + node->get_node_base_interface().get(), + topic_name + "_updates", + custom_qos, + pub_options + ); // Create a service that will use the callback function to handle requests. costmap_service_ = node->create_service(