diff --git a/rclcpp/include/rclcpp/node.hpp b/rclcpp/include/rclcpp/node.hpp index e995060..96b1663 100644 --- a/rclcpp/include/rclcpp/node.hpp +++ b/rclcpp/include/rclcpp/node.hpp @@ -92,6 +92,17 @@ public: rclcpp::callback_group::CallbackGroup::SharedPtr create_callback_group(rclcpp::callback_group::CallbackGroupType group_type); + /// Create and return a Publisher. + /** + * \param[in] topic_name The topic for this publisher to publish on. + * \param[in] qos_history_depth The depth of the publisher message queue. + * \return Shared pointer to the created publisher. + */ + template + typename rclcpp::publisher::Publisher::SharedPtr + create_publisher( + const std::string & topic_name, size_t qos_history_depth); + /// Create and return a Publisher. /** * \param[in] topic_name The topic for this publisher to publish on. diff --git a/rclcpp/include/rclcpp/node_impl.hpp b/rclcpp/include/rclcpp/node_impl.hpp index 6e6ae76..09bbbc3 100644 --- a/rclcpp/include/rclcpp/node_impl.hpp +++ b/rclcpp/include/rclcpp/node_impl.hpp @@ -113,6 +113,16 @@ Node::create_callback_group( return group; } +template +typename rclcpp::publisher::Publisher::SharedPtr +Node::create_publisher( + const std::string & topic_name, size_t qos_history_depth) +{ + rmw_qos_profile_t qos = rmw_qos_profile_default; + qos.depth = qos_history_depth; + return this->create_publisher(topic_name, qos); +} + template typename publisher::Publisher::SharedPtr Node::create_publisher(