ROS 2 rclcpp + rcl - kilted  kilted
ROS 2 C++ Client Library with ROS Client Library
create_generic_client.cpp
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 #include "rclcpp/create_generic_client.hpp"
16 #include "rclcpp/generic_client.hpp"
17 
18 namespace rclcpp
19 {
20 rclcpp::GenericClient::SharedPtr
22  std::shared_ptr<node_interfaces::NodeBaseInterface> node_base,
23  std::shared_ptr<node_interfaces::NodeGraphInterface> node_graph,
24  std::shared_ptr<node_interfaces::NodeServicesInterface> node_services,
25  const std::string & service_name,
26  const std::string & service_type,
27  const rclcpp::QoS & qos,
28  rclcpp::CallbackGroup::SharedPtr group)
29 {
31  options.qos = qos.get_rmw_qos_profile();
32 
33  auto cli = rclcpp::GenericClient::make_shared(
34  node_base.get(),
35  node_graph,
36  service_name,
37  service_type,
38  options);
39 
40  auto cli_base_ptr = std::dynamic_pointer_cast<rclcpp::ClientBase>(cli);
41  node_services->add_client(cli_base_ptr, group);
42  return cli;
43 }
44 } // namespace rclcpp
Encapsulation of Quality of Service settings.
Definition: qos.hpp:116
rmw_qos_profile_t & get_rmw_qos_profile()
Return the rmw qos profile.
Definition: qos.cpp:102
RCL_PUBLIC RCL_WARN_UNUSED rcl_client_options_t rcl_client_get_default_options(void)
Return the default client options in a rcl_client_options_t.
Definition: client.c:280
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.
Options available for a rcl_client_t.
Definition: client.h:50
rmw_qos_profile_t qos
Middleware quality of service settings for the client.
Definition: client.h:52