ROS 2 rclcpp + rcl - jazzy  jazzy
ROS 2 C++ Client Library with ROS Client Library
create_generic_client.hpp
1 // Copyright 2023 Sony Group Corporation.
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_CLIENT_HPP_
16 #define RCLCPP__CREATE_GENERIC_CLIENT_HPP_
17 
18 #include <memory>
19 #include <string>
20 
21 #include "rclcpp/generic_client.hpp"
22 #include "rclcpp/node_interfaces/get_node_base_interface.hpp"
23 #include "rclcpp/node_interfaces/get_node_graph_interface.hpp"
24 #include "rclcpp/node_interfaces/get_node_services_interface.hpp"
25 #include "rclcpp/node_interfaces/node_base_interface.hpp"
26 #include "rclcpp/node_interfaces/node_graph_interface.hpp"
27 #include "rclcpp/node_interfaces/node_services_interface.hpp"
28 #include "rclcpp/qos.hpp"
29 
30 namespace rclcpp
31 {
33 
46 RCLCPP_PUBLIC
47 rclcpp::GenericClient::SharedPtr
49  std::shared_ptr<node_interfaces::NodeBaseInterface> node_base,
50  std::shared_ptr<node_interfaces::NodeGraphInterface> node_graph,
51  std::shared_ptr<node_interfaces::NodeServicesInterface> node_services,
52  const std::string & service_name,
53  const std::string & service_type,
54  const rclcpp::QoS & qos = rclcpp::ServicesQoS(),
55  rclcpp::CallbackGroup::SharedPtr group = nullptr);
56 
58 
69 template<typename NodeT>
70 rclcpp::GenericClient::SharedPtr
72  NodeT node,
73  const std::string & service_name,
74  const std::string & service_type,
75  const rclcpp::QoS & qos = rclcpp::ServicesQoS(),
76  rclcpp::CallbackGroup::SharedPtr group = nullptr)
77 {
78  return create_generic_client(
79  rclcpp::node_interfaces::get_node_base_interface(node),
80  rclcpp::node_interfaces::get_node_graph_interface(node),
81  rclcpp::node_interfaces::get_node_services_interface(node),
82  service_name,
83  service_type,
84  qos,
85  group
86  );
87 }
88 } // namespace rclcpp
89 
90 #endif // RCLCPP__CREATE_GENERIC_CLIENT_HPP_
Encapsulation of Quality of Service settings.
Definition: qos.hpp:116
Versions of rosidl_typesupport_cpp::get_message_type_support_handle that handle adapted types.
RCLCPP_PUBLIC rclcpp::GenericClient::SharedPtr create_generic_client(std::shared_ptr< node_interfaces::NodeBaseInterface > node_base, std::shared_ptr< node_interfaces::NodeGraphInterface > node_graph, std::shared_ptr< node_interfaces::NodeServicesInterface > node_services, const std::string &service_name, const std::string &service_type, const rclcpp::QoS &qos=rclcpp::ServicesQoS(), rclcpp::CallbackGroup::SharedPtr group=nullptr)
Create a generic service client with a name of given type.