.. _program_listing_file_include_rclcpp_create_generic_publisher.hpp: Program Listing for File create_generic_publisher.hpp ===================================================== |exhale_lsh| :ref:`Return to documentation for file ` (``include/rclcpp/create_generic_publisher.hpp``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp // Copyright 2020, Apex.AI Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #ifndef RCLCPP__CREATE_GENERIC_PUBLISHER_HPP_ #define RCLCPP__CREATE_GENERIC_PUBLISHER_HPP_ #include #include #include #include "rclcpp/generic_publisher.hpp" #include "rclcpp/node_interfaces/node_topics_interface.hpp" #include "rclcpp/publisher_options.hpp" #include "rclcpp/qos.hpp" #include "rclcpp/typesupport_helpers.hpp" namespace rclcpp { template> std::shared_ptr create_generic_publisher( rclcpp::node_interfaces::NodeTopicsInterface::SharedPtr topics_interface, const std::string & topic_name, const std::string & topic_type, const rclcpp::QoS & qos, const rclcpp::PublisherOptionsWithAllocator & options = ( rclcpp::PublisherOptionsWithAllocator() ) ) { auto ts_lib = rclcpp::get_typesupport_library(topic_type, "rosidl_typesupport_cpp"); auto pub = std::make_shared( topics_interface->get_node_base_interface(), std::move(ts_lib), topic_name, topic_type, qos, options); topics_interface->add_publisher(pub, options.callback_group); return pub; } } // namespace rclcpp #endif // RCLCPP__CREATE_GENERIC_PUBLISHER_HPP_