ROS 2 rclcpp + rcl - humble  humble
ROS 2 C++ Client Library with ROS Client Library
service.h
Go to the documentation of this file.
1 // Copyright 2016 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 
16 
17 #ifndef RCL__SERVICE_H_
18 #define RCL__SERVICE_H_
19 
20 #ifdef __cplusplus
21 extern "C"
22 {
23 #endif
24 
25 #include "rosidl_runtime_c/service_type_support_struct.h"
26 
27 #include "rcl/event_callback.h"
28 #include "rcl/macros.h"
29 #include "rcl/node.h"
30 #include "rcl/visibility_control.h"
31 
34 
36 typedef struct rcl_service_s
37 {
41 
43 typedef struct rcl_service_options_s
44 {
46  rmw_qos_profile_t qos;
48 
51 
53 
59 RCL_PUBLIC
60 RCL_WARN_UNUSED
63 
65 
154 RCL_PUBLIC
155 RCL_WARN_UNUSED
156 rcl_ret_t
158  rcl_service_t * service,
159  const rcl_node_t * node,
160  const rosidl_service_type_support_t * type_support,
161  const char * service_name,
162  const rcl_service_options_t * options);
163 
165 
190 RCL_PUBLIC
191 RCL_WARN_UNUSED
192 rcl_ret_t
193 rcl_service_fini(rcl_service_t * service, rcl_node_t * node);
194 
196 
202 RCL_PUBLIC
203 RCL_WARN_UNUSED
206 
208 
252 RCL_PUBLIC
253 RCL_WARN_UNUSED
254 rcl_ret_t
256  const rcl_service_t * service,
257  rmw_service_info_t * request_header,
258  void * ros_request);
259 
261 
276 RCL_PUBLIC
277 RCL_WARN_UNUSED
278 rcl_ret_t
280  const rcl_service_t * service,
281  rmw_request_id_t * request_header,
282  void * ros_request);
283 
285 
330 RCL_PUBLIC
331 RCL_WARN_UNUSED
332 rcl_ret_t
334  const rcl_service_t * service,
335  rmw_request_id_t * response_header,
336  void * ros_response);
337 
339 
360 RCL_PUBLIC
361 RCL_WARN_UNUSED
362 const char *
364 
366 
387 RCL_PUBLIC
388 RCL_WARN_UNUSED
389 const rcl_service_options_t *
390 rcl_service_get_options(const rcl_service_t * service);
391 
393 
418 RCL_PUBLIC
419 RCL_WARN_UNUSED
420 rmw_service_t *
422 
424 
441 RCL_PUBLIC
442 bool
443 rcl_service_is_valid(const rcl_service_t * service);
444 
446 
466 RCL_PUBLIC
467 RCL_WARN_UNUSED
468 const rmw_qos_profile_t *
470 
472 
492 RCL_PUBLIC
493 RCL_WARN_UNUSED
494 const rmw_qos_profile_t *
496 
498 
520 RCL_PUBLIC
521 RCL_WARN_UNUSED
522 rcl_ret_t
524  const rcl_service_t * service,
525  rcl_event_callback_t callback,
526  const void * user_data);
527 
528 #ifdef __cplusplus
529 }
530 #endif
531 
532 #endif // RCL__SERVICE_H_
rcutils_allocator_t rcl_allocator_t
Encapsulation of an allocator.
Definition: allocator.h:31
RCL_PUBLIC RCL_WARN_UNUSED const rmw_qos_profile_t * rcl_service_request_subscription_get_actual_qos(const rcl_service_t *service)
Get the actual qos settings of the service's request subscription.
Definition: service.c:335
RCL_PUBLIC RCL_WARN_UNUSED rmw_service_t * rcl_service_get_rmw_handle(const rcl_service_t *service)
Return the rmw service handle.
Definition: service.c:242
RCL_PUBLIC RCL_WARN_UNUSED const char * rcl_service_get_service_name(const rcl_service_t *service)
Get the topic name for the service.
Definition: service.c:220
RCL_PUBLIC RCL_WARN_UNUSED const rmw_qos_profile_t * rcl_service_response_publisher_get_actual_qos(const rcl_service_t *service)
Get the actual qos settings of the service's response publisher.
Definition: service.c:344
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_service_init(rcl_service_t *service, const rcl_node_t *node, const rosidl_service_type_support_t *type_support, const char *service_name, const rcl_service_options_t *options)
Initialize a rcl service.
Definition: service.c:49
RCL_PUBLIC RCL_WARN_UNUSED const rcl_service_options_t * rcl_service_get_options(const rcl_service_t *service)
Return the rcl service options.
Definition: service.c:233
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_take_request_with_info(const rcl_service_t *service, rmw_service_info_t *request_header, void *ros_request)
Take a pending ROS request using a rcl service.
Definition: service.c:251
struct rcl_service_s rcl_service_t
Structure which encapsulates a ROS Service.
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_service_set_on_new_request_callback(const rcl_service_t *service, rcl_event_callback_t callback, const void *user_data)
Set the on new request callback function for the service.
Definition: service.c:353
struct rcl_service_options_s rcl_service_options_t
Options available for a rcl service.
RCL_PUBLIC bool rcl_service_is_valid(const rcl_service_t *service)
Check that the service is valid.
Definition: service.c:324
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_service_fini(rcl_service_t *service, rcl_node_t *node)
Finalize a rcl_service_t.
Definition: service.c:176
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.
Definition: service.c:209
RCL_PUBLIC RCL_WARN_UNUSED rcl_service_t rcl_get_zero_initialized_service(void)
Return a rcl_service_t struct with members set to NULL.
Definition: service.c:42
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_take_request(const rcl_service_t *service, rmw_request_id_t *request_header, void *ros_request)
Backwards compatibility function to take a pending ROS request using a rcl service.
Definition: service.c:284
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_send_response(const rcl_service_t *service, rmw_request_id_t *response_header, void *ros_response)
Send a ROS response to a client using a service.
Definition: service.c:297
Structure which encapsulates a ROS Node.
Definition: node.h:42
Options available for a rcl service.
Definition: service.h:44
rmw_qos_profile_t qos
Middleware quality of service settings for the service.
Definition: service.h:46
rcl_allocator_t allocator
Custom allocator for the service, used for incidental allocations.
Definition: service.h:49
Structure which encapsulates a ROS Service.
Definition: service.h:37
rcl_service_impl_t * impl
Pointer to the service implementation.
Definition: service.h:39
rmw_ret_t rcl_ret_t
The type that holds an rcl return code.
Definition: types.h:23