rclcpp  master
C++ ROS Client Library API
create_generic_publisher.hpp
Go to the documentation of this file.
1 // Copyright 2020, Apex.AI Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef RCLCPP__CREATE_GENERIC_PUBLISHER_HPP_
16 #define RCLCPP__CREATE_GENERIC_PUBLISHER_HPP_
17 
18 #include <memory>
19 #include <string>
20 #include <utility>
21 
25 #include "rclcpp/qos.hpp"
27 
28 namespace rclcpp
29 {
30 
32 
44 template<typename AllocatorT = std::allocator<void>>
46  rclcpp::node_interfaces::NodeTopicsInterface::SharedPtr topics_interface,
47  const std::string & topic_name,
48  const std::string & topic_type,
49  const rclcpp::QoS & qos,
52  )
53 )
54 {
55  auto ts_lib = rclcpp::get_typesupport_library(topic_type, "rosidl_typesupport_cpp");
56  auto pub = std::make_shared<GenericPublisher>(
57  topics_interface->get_node_base_interface(),
58  std::move(ts_lib),
59  topic_name,
60  topic_type,
61  qos,
62  options);
63  topics_interface->add_publisher(pub, options.callback_group);
64  return pub;
65 }
66 
67 } // namespace rclcpp
68 
69 #endif // RCLCPP__CREATE_GENERIC_PUBLISHER_HPP_
generic_publisher.hpp
std::string
std::shared_ptr
rclcpp::create_generic_publisher
std::shared_ptr< GenericPublisher > 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< AllocatorT > &options=(rclcpp::PublisherOptionsWithAllocator< AllocatorT >()))
Create and return a GenericPublisher.
Definition: create_generic_publisher.hpp:45
std::move
T move(T... args)
typesupport_helpers.hpp
rclcpp
This header provides the get_node_base_interface() template function.
Definition: allocator_common.hpp:24
qos.hpp
node_topics_interface.hpp
rclcpp::QoS
Encapsulation of Quality of Service settings.
Definition: qos.hpp:110
publisher_options.hpp
rclcpp::PublisherOptionsWithAllocator
Structure containing optional configuration for Publishers.
Definition: publisher_options.hpp:65
rclcpp::get_typesupport_library
std::shared_ptr< rcpputils::SharedLibrary > get_typesupport_library(const std::string &type, const std::string &typesupport_identifier)
Load the type support library for the given type.