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/node_options.hpp"
25 #include "rclcpp/publisher_factory.hpp"
26 #include "rclcpp/publisher_options.hpp"
27 #include "rclcpp/qos.hpp"
28 #include "rclcpp/qos_overriding_options.hpp"
29 #include "rclcpp/detail/qos_parameters.hpp"
31 #include "rmw/qos_profiles.h"
41 typename AllocatorT = std::allocator<void>,
43 typename NodeParametersT,
45 std::shared_ptr<PublisherT>
47 NodeParametersT & node_parameters,
48 NodeTopicsT & node_topics,
49 const std::string & topic_name,
56 auto node_topics_interface = rclcpp::node_interfaces::get_node_topics_interface(node_topics);
57 const rclcpp::QoS & actual_qos = options.qos_overriding_options.get_policy_kinds().size() ?
58 rclcpp::detail::declare_qos_parameters(
59 options.qos_overriding_options, node_parameters,
60 node_topics_interface->resolve_topic_name(topic_name),
65 auto pub = node_topics_interface->create_publisher(
67 rclcpp::create_publisher_factory<MessageT, AllocatorT, PublisherT>(options),
72 node_topics_interface->add_publisher(pub, options.callback_group);
74 return std::dynamic_pointer_cast<PublisherT>(pub);
90 typename AllocatorT = std::allocator<void>,
93 std::shared_ptr<PublisherT>
96 const std::string & topic_name,
103 return detail::create_publisher<MessageT, AllocatorT, PublisherT>(
104 node, node, topic_name, qos, options);
110 typename AllocatorT = std::allocator<void>,
112 std::shared_ptr<PublisherT>
114 rclcpp::node_interfaces::NodeParametersInterface::SharedPtr & node_parameters,
115 rclcpp::node_interfaces::NodeTopicsInterface::SharedPtr & node_topics,
116 const std::string & topic_name,
123 return detail::create_publisher<MessageT, AllocatorT, PublisherT>(
124 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.