rclcpp  master
C++ ROS Client Library API
create_client.hpp
Go to the documentation of this file.
1 // Copyright 2019 Open Source Robotics Foundation, 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_CLIENT_HPP_
16 #define RCLCPP__CREATE_CLIENT_HPP_
17 
18 #include <memory>
19 #include <string>
20 
23 #include "rmw/rmw.h"
24 
25 namespace rclcpp
26 {
27 
30 template<typename ServiceT>
36  const std::string & service_name,
37  const rmw_qos_profile_t & qos_profile,
38  rclcpp::callback_group::CallbackGroup::SharedPtr group)
39 {
41  options.qos = qos_profile;
42 
44  node_base.get(),
45  node_graph,
46  service_name,
47  options);
48 
49  auto cli_base_ptr = std::dynamic_pointer_cast<rclcpp::ClientBase>(cli);
50  node_services->add_client(cli_base_ptr, group);
51  return cli;
52 }
53 
54 } // namespace rclcpp
55 
56 #endif // RCLCPP__CREATE_CLIENT_HPP_
Definition: client.hpp:52
This header provides the get_node_base_interface() template function.
Definition: allocator_common.hpp:24
Definition: client.hpp:119
rmw_qos_profile_t qos
rcl_client_options_t rcl_client_get_default_options(void)
T dynamic_pointer_cast(T... args)
T get(T... args)
rclcpp::Client< ServiceT >::SharedPtr create_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 rmw_qos_profile_t &qos_profile, rclcpp::callback_group::CallbackGroup::SharedPtr group)
Definition: create_client.hpp:32