15 #ifndef RCLCPP__CREATE_PUBLISHER_HPP_
16 #define RCLCPP__CREATE_PUBLISHER_HPP_
22 #include "rclcpp/node_interfaces/get_node_topics_interface.hpp"
23 #include "rclcpp/node_interfaces/node_topics_interface.hpp"
24 #include "rclcpp/publisher_factory.hpp"
25 #include "rclcpp/publisher_options.hpp"
26 #include "rclcpp/qos.hpp"
27 #include "rclcpp/qos_overriding_options.hpp"
28 #include "rclcpp/detail/qos_parameters.hpp"
30 #include "rmw/qos_profiles.h"
40 typename AllocatorT = std::allocator<void>,
42 typename NodeParametersT,
44 std::shared_ptr<PublisherT>
46 NodeParametersT & node_parameters,
47 NodeTopicsT & node_topics,
48 const std::string & topic_name,
55 auto node_topics_interface = rclcpp::node_interfaces::get_node_topics_interface(node_topics);
56 const rclcpp::QoS & actual_qos = options.qos_overriding_options.get_policy_kinds().size() ?
57 rclcpp::detail::declare_qos_parameters(
58 options.qos_overriding_options, node_parameters,
59 node_topics_interface->resolve_topic_name(topic_name),
64 auto pub = node_topics_interface->create_publisher(
66 rclcpp::create_publisher_factory<MessageT, AllocatorT, PublisherT>(options),
71 node_topics_interface->add_publisher(pub, options.callback_group);
73 return std::dynamic_pointer_cast<PublisherT>(pub);
89 typename AllocatorT = std::allocator<void>,
92 std::shared_ptr<PublisherT>
95 const std::string & topic_name,
102 return detail::create_publisher<MessageT, AllocatorT, PublisherT>(
103 node, node, topic_name, qos, options);
109 typename AllocatorT = std::allocator<void>,
111 std::shared_ptr<PublisherT>
113 rclcpp::node_interfaces::NodeParametersInterface::SharedPtr & node_parameters,
114 rclcpp::node_interfaces::NodeTopicsInterface::SharedPtr & node_topics,
115 const std::string & topic_name,
122 return detail::create_publisher<MessageT, AllocatorT, PublisherT>(
123 node_parameters, node_topics, topic_name, qos, options);
A publisher publishes messages of any type to a topic.
Encapsulation of Quality of Service settings.
Versions of rosidl_typesupport_cpp::get_message_type_support_handle that handle adapted types.
std::shared_ptr< PublisherT > create_publisher(NodeT &&node, const std::string &topic_name, const rclcpp::QoS &qos, const rclcpp::PublisherOptionsWithAllocator< AllocatorT > &options=(rclcpp::PublisherOptionsWithAllocator< AllocatorT >()))
Create and return a publisher of the given MessageT type.
Structure containing optional configuration for Publishers.