15 #ifndef RCLCPP__CREATE_SERVICE_HPP_
16 #define RCLCPP__CREATE_SERVICE_HPP_
22 #include "rclcpp/node_interfaces/node_base_interface.hpp"
23 #include "rclcpp/node_interfaces/node_services_interface.hpp"
24 #include "rclcpp/visibility_control.hpp"
41 template<
typename ServiceT,
typename CallbackT>
44 std::shared_ptr<node_interfaces::NodeBaseInterface> node_base,
45 std::shared_ptr<node_interfaces::NodeServicesInterface> node_services,
46 const std::string & service_name,
47 CallbackT && callback,
49 rclcpp::CallbackGroup::SharedPtr group)
51 return create_service<ServiceT, CallbackT>(
52 node_base, node_services, service_name,
58 template<
typename ServiceT,
typename CallbackT>
61 std::shared_ptr<node_interfaces::NodeBaseInterface> node_base,
62 std::shared_ptr<node_interfaces::NodeServicesInterface> node_services,
63 const std::string & service_name,
64 CallbackT && callback,
65 const rmw_qos_profile_t & qos_profile,
66 rclcpp::CallbackGroup::SharedPtr group)
69 any_service_callback.set(std::forward<CallbackT>(callback));
72 service_options.
qos = qos_profile;
75 node_base->get_shared_rcl_node_handle(),
76 service_name, any_service_callback, service_options);
77 auto serv_base_ptr = std::dynamic_pointer_cast<ServiceBase>(serv);
78 node_services->add_service(serv_base_ptr, group);
Encapsulation of Quality of Service settings.
rmw_qos_profile_t & get_rmw_qos_profile()
Return the rmw qos profile.
Versions of rosidl_typesupport_cpp::get_message_type_support_handle that handle adapted types.
rclcpp::Service< ServiceT >::SharedPtr create_service(std::shared_ptr< node_interfaces::NodeBaseInterface > node_base, std::shared_ptr< node_interfaces::NodeServicesInterface > node_services, const std::string &service_name, CallbackT &&callback, const rclcpp::QoS &qos, rclcpp::CallbackGroup::SharedPtr group)
Create a service with a given type.
RCL_PUBLIC RCL_WARN_UNUSED rcl_service_options_t rcl_service_get_default_options(void)
Return the default service options in a rcl_service_options_t.
Options available for a rcl service.
rmw_qos_profile_t qos
Middleware quality of service settings for the service.