Skip to content

Commit e933a2f

Browse files
committed
create client and server service added
1 parent 240bad1 commit e933a2f

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

simple_node/include/simple_node/node.hpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,28 @@ class Node : public rclcpp::Node {
117117
return action_server;
118118
}
119119

120+
template <typename ServiceT>
121+
typename rclcpp::Client<ServiceT>::SharedPtr
122+
create_client(const std::string &service_name,
123+
const rmw_qos_profile_t &qos_profile) {
124+
return rclcpp::create_client<ServiceT>(
125+
node_base_, node_graph_, node_services_,
126+
rclcpp::extend_name_with_sub_namespace(service_name,
127+
this->get_sub_namespace()),
128+
qos_profile, this->group);
129+
}
130+
131+
template <typename ServiceT, typename CallbackT>
132+
typename rclcpp::Service<ServiceT>::SharedPtr
133+
create_service(const std::string &service_name, CallbackT &&callback,
134+
const rmw_qos_profile_t &qos_profile) {
135+
return rclcpp::create_service<ServiceT, CallbackT>(
136+
node_base_, node_services_,
137+
rclcpp::extend_name_with_sub_namespace(service_name,
138+
this->get_sub_namespace()),
139+
std::forward<CallbackT>(callback), qos_profile, this->group);
140+
}
141+
120142
private:
121143
rclcpp::CallbackGroup::SharedPtr group;
122144
rclcpp::Executor *executor;

0 commit comments

Comments
 (0)