ROS 2 rclcpp + rcl - lyrical  lyrical
ROS 2 C++ Client Library with ROS Client Library
graph.h
Go to the documentation of this file.
1 // Copyright 2016-2017 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__GRAPH_H_
18 #define RCL__GRAPH_H_
19 
20 #ifdef __cplusplus
21 extern "C"
22 {
23 #endif
24 
25 #include <stddef.h>
26 
27 #include <rmw/names_and_types.h>
28 #include <rmw/get_topic_names_and_types.h>
29 #include <rmw/service_endpoint_info_array.h>
30 #include <rmw/topic_endpoint_info_array.h>
31 
32 #include "rcutils/time.h"
33 #include "rcutils/types.h"
34 
35 #include "rosidl_runtime_c/service_type_support_struct.h"
36 
37 #include "rcl/macros.h"
38 #include "rcl/client.h"
39 #include "rcl/node.h"
40 #include "rcl/visibility_control.h"
41 
43 typedef rmw_names_and_types_t rcl_names_and_types_t;
44 
48 typedef rmw_topic_endpoint_info_t rcl_topic_endpoint_info_t;
49 
51 typedef rmw_topic_endpoint_info_array_t rcl_topic_endpoint_info_array_t;
52 
56 typedef rmw_service_endpoint_info_t rcl_service_endpoint_info_t;
57 
58 // An array of service endpoint information.
59 typedef rmw_service_endpoint_info_array_t rcl_service_endpoint_info_array_t;
60 
62 #define rcl_get_zero_initialized_names_and_types rmw_get_zero_initialized_names_and_types
63 
65 #define rcl_get_zero_initialized_topic_endpoint_info_array \
66  rmw_get_zero_initialized_topic_endpoint_info_array
67 
69 #define rcl_topic_endpoint_info_array_fini rmw_topic_endpoint_info_array_fini
70 
72 #define rcl_get_zero_initialized_service_endpoint_info_array \
73  rmw_get_zero_initialized_service_endpoint_info_array
74 
76 #define rcl_service_endpoint_info_array_fini rmw_service_endpoint_info_array_fini
77 
79 
122 RCL_PUBLIC
123 RCL_WARN_UNUSED
124 rcl_ret_t
126  const rcl_node_t * node,
127  rcl_allocator_t * allocator,
128  bool no_demangle,
129  const char * node_name,
130  const char * node_namespace,
131  rcl_names_and_types_t * topic_names_and_types);
132 
134 
172 RCL_PUBLIC
173 RCL_WARN_UNUSED
174 rcl_ret_t
176  const rcl_node_t * node,
177  rcl_allocator_t * allocator,
178  bool no_demangle,
179  const char * node_name,
180  const char * node_namespace,
181  rcl_names_and_types_t * topic_names_and_types);
182 
184 
221 RCL_PUBLIC
222 RCL_WARN_UNUSED
223 rcl_ret_t
225  const rcl_node_t * node,
226  rcl_allocator_t * allocator,
227  const char * node_name,
228  const char * node_namespace,
229  rcl_names_and_types_t * service_names_and_types);
230 
232 
269 RCL_PUBLIC
270 RCL_WARN_UNUSED
271 rcl_ret_t
273  const rcl_node_t * node,
274  rcl_allocator_t * allocator,
275  const char * node_name,
276  const char * node_namespace,
277  rcl_names_and_types_t * service_names_and_types);
278 
280 
315 RCL_PUBLIC
316 RCL_WARN_UNUSED
317 rcl_ret_t
319  const rcl_node_t * node,
320  rcl_allocator_t * allocator,
321  bool no_demangle,
322  rcl_names_and_types_t * topic_names_and_types);
323 
325 
355 RCL_PUBLIC
356 RCL_WARN_UNUSED
357 rcl_ret_t
359  const rcl_node_t * node,
360  rcl_allocator_t * allocator,
361  rcl_names_and_types_t * service_names_and_types);
362 
364 
386 RCL_PUBLIC
387 RCL_WARN_UNUSED
388 rcl_ret_t
390  rcl_names_and_types_t * names_and_types,
391  size_t size,
392  rcl_allocator_t * allocator);
393 
395 
417 RCL_PUBLIC
418 RCL_WARN_UNUSED
419 rcl_ret_t
421 
423 
477 RCL_PUBLIC
478 RCL_WARN_UNUSED
479 rcl_ret_t
481  const rcl_node_t * node,
482  rcl_allocator_t allocator,
483  rcutils_string_array_t * node_names,
484  rcutils_string_array_t * node_namespaces);
485 
487 
510 RCL_PUBLIC
511 RCL_WARN_UNUSED
512 rcl_ret_t
514  const rcl_node_t * node,
515  rcl_allocator_t allocator,
516  rcutils_string_array_t * node_names,
517  rcutils_string_array_t * node_namespaces,
518  rcutils_string_array_t * enclaves);
519 
521 
558 RCL_PUBLIC
559 RCL_WARN_UNUSED
560 rcl_ret_t
562  const rcl_node_t * node,
563  const char * topic_name,
564  size_t * count);
565 
567 
604 RCL_PUBLIC
605 RCL_WARN_UNUSED
606 rcl_ret_t
608  const rcl_node_t * node,
609  const char * topic_name,
610  size_t * count);
611 
613 
650 RCL_PUBLIC
651 RCL_WARN_UNUSED
652 rcl_ret_t
654  const rcl_node_t * node,
655  const char * service_name,
656  size_t * count);
657 
659 
696 RCL_PUBLIC
697 RCL_WARN_UNUSED
698 rcl_ret_t
700  const rcl_node_t * node,
701  const char * service_name,
702  size_t * count);
703 
705 
748 RCL_PUBLIC
749 RCL_WARN_UNUSED
750 rcl_ret_t
752  const rcl_node_t * node,
753  rcl_allocator_t * allocator,
754  const char * topic_name,
755  const size_t count,
756  rcutils_duration_value_t timeout,
757  bool * success);
758 
760 
785 RCL_PUBLIC
786 RCL_WARN_UNUSED
787 rcl_ret_t
789  const rcl_node_t * node,
790  rcl_allocator_t * allocator,
791  const char * topic_name,
792  const size_t count,
793  rcutils_duration_value_t timeout,
794  bool * success);
795 
797 
822 RCL_PUBLIC
823 RCL_WARN_UNUSED
824 rcl_ret_t
826  const rcl_node_t * node,
827  rcl_allocator_t * allocator,
828  const char * service_name,
829  const size_t count,
830  rcutils_duration_value_t timeout,
831  bool * success);
832 
834 
859 RCL_PUBLIC
860 RCL_WARN_UNUSED
861 rcl_ret_t
863  const rcl_node_t * node,
864  rcl_allocator_t * allocator,
865  const char * service_name,
866  const size_t count,
867  rcutils_duration_value_t timeout,
868  bool * success);
869 
871 
921 RCL_PUBLIC
922 RCL_WARN_UNUSED
923 rcl_ret_t
925  const rcl_node_t * node,
926  rcutils_allocator_t * allocator,
927  const char * topic_name,
928  bool no_mangle,
929  rcl_topic_endpoint_info_array_t * publishers_info);
930 
932 
982 RCL_PUBLIC
983 RCL_WARN_UNUSED
984 rcl_ret_t
986  const rcl_node_t * node,
987  rcutils_allocator_t * allocator,
988  const char * topic_name,
989  bool no_mangle,
990  rcl_topic_endpoint_info_array_t * subscriptions_info);
991 
993 
1047 RCL_PUBLIC
1048 RCL_WARN_UNUSED
1049 rcl_ret_t
1051  const rcl_node_t * node,
1052  rcutils_allocator_t * allocator,
1053  const char * service_name,
1054  bool no_mangle,
1055  rcl_service_endpoint_info_array_t * clients_info);
1056 
1058 
1112 RCL_PUBLIC
1113 RCL_WARN_UNUSED
1114 rcl_ret_t
1116  const rcl_node_t * node,
1117  rcutils_allocator_t * allocator,
1118  const char * service_name,
1119  bool no_mangle,
1120  rcl_service_endpoint_info_array_t * servers_info);
1121 
1123 
1157 RCL_PUBLIC
1158 RCL_WARN_UNUSED
1159 rcl_ret_t
1161  const rcl_node_t * node,
1162  const rcl_client_t * client,
1163  bool * is_available);
1164 
1165 #ifdef __cplusplus
1166 }
1167 #endif
1168 
1169 #endif // RCL__GRAPH_H_
rcutils_allocator_t rcl_allocator_t
Encapsulation of an allocator.
Definition: allocator.h:31
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_get_servers_info_by_service(const rcl_node_t *node, rcutils_allocator_t *allocator, const char *service_name, bool no_mangle, rcl_service_endpoint_info_array_t *servers_info)
Return a list of all servers to a service.
Definition: graph.c:866
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_wait_for_servers(const rcl_node_t *node, rcl_allocator_t *allocator, const char *service_name, const size_t count, rcutils_duration_value_t timeout, bool *success)
Wait for there to be a specified number of servers on a given service.
Definition: graph.c:696
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_count_services(const rcl_node_t *node, const char *service_name, size_t *count)
Return the number of servers on a given service.
Definition: graph.c:484
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_get_subscriptions_info_by_topic(const rcl_node_t *node, rcutils_allocator_t *allocator, const char *topic_name, bool no_mangle, rcl_topic_endpoint_info_array_t *subscriptions_info)
Return a list of all subscriptions to a topic.
Definition: graph.c:782
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_names_and_types_fini(rcl_names_and_types_t *names_and_types)
Finalize a rcl_names_and_types_t object.
Definition: graph.c:311
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_get_node_names_with_enclaves(const rcl_node_t *node, rcl_allocator_t allocator, rcutils_string_array_t *node_names, rcutils_string_array_t *node_namespaces, rcutils_string_array_t *enclaves)
Return a list of node names and their associated namespaces and enclaves in the ROS graph.
Definition: graph.c:380
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_wait_for_clients(const rcl_node_t *node, rcl_allocator_t *allocator, const char *service_name, const size_t count, rcutils_duration_value_t timeout, bool *success)
Wait for there to be a specified number of clients on a given service.
Definition: graph.c:677
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_get_service_names_and_types(const rcl_node_t *node, rcl_allocator_t *allocator, rcl_names_and_types_t *service_names_and_types)
Return a list of service names and their types.
Definition: graph.c:272
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_get_client_names_and_types_by_node(const rcl_node_t *node, rcl_allocator_t *allocator, const char *node_name, const char *node_namespace, rcl_names_and_types_t *service_names_and_types)
Return a list of service client names and types associated with a node.
Definition: graph.c:205
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_service_server_is_available(const rcl_node_t *node, const rcl_client_t *client, bool *is_available)
Check if a service server is available for the given service client.
Definition: graph.c:883
rmw_topic_endpoint_info_t rcl_topic_endpoint_info_t
Definition: graph.h:48
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_get_publishers_info_by_topic(const rcl_node_t *node, rcutils_allocator_t *allocator, const char *topic_name, bool no_mangle, rcl_topic_endpoint_info_array_t *publishers_info)
Return a list of all publishers to a topic.
Definition: graph.c:765
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_names_and_types_init(rcl_names_and_types_t *names_and_types, size_t size, rcl_allocator_t *allocator)
Initialize a rcl_names_and_types_t object.
Definition: graph.c:297
rmw_topic_endpoint_info_array_t rcl_topic_endpoint_info_array_t
An array of topic endpoint information.
Definition: graph.h:51
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_get_service_names_and_types_by_node(const rcl_node_t *node, rcl_allocator_t *allocator, const char *node_name, const char *node_namespace, rcl_names_and_types_t *service_names_and_types)
Return a list of service names and types associated with a node.
Definition: graph.c:165
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_get_subscriber_names_and_types_by_node(const rcl_node_t *node, rcl_allocator_t *allocator, bool no_demangle, const char *node_name, const char *node_namespace, rcl_names_and_types_t *topic_names_and_types)
Return a list of topic names and types for subscriptions associated with a node.
Definition: graph.c:123
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_count_subscribers(const rcl_node_t *node, const char *topic_name, size_t *count)
Return the number of subscriptions on a given topic.
Definition: graph.c:446
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_wait_for_publishers(const rcl_node_t *node, rcl_allocator_t *allocator, const char *topic_name, const size_t count, rcutils_duration_value_t timeout, bool *success)
Wait for there to be a specified number of publishers on a given topic.
Definition: graph.c:638
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_count_clients(const rcl_node_t *node, const char *service_name, size_t *count)
Return the number of clients on a given service.
Definition: graph.c:465
rmw_names_and_types_t rcl_names_and_types_t
A structure that contains topic names and types.
Definition: graph.h:43
rmw_service_endpoint_info_t rcl_service_endpoint_info_t
Definition: graph.h:56
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_get_publisher_names_and_types_by_node(const rcl_node_t *node, rcl_allocator_t *allocator, bool no_demangle, const char *node_name, const char *node_namespace, rcl_names_and_types_t *topic_names_and_types)
Return a list of topic names and types for publishers associated with a node.
Definition: graph.c:82
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_wait_for_subscribers(const rcl_node_t *node, rcl_allocator_t *allocator, const char *topic_name, const size_t count, rcutils_duration_value_t timeout, bool *success)
Wait for there to be a specified number of subscribers on a given topic.
Definition: graph.c:657
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_get_topic_names_and_types(const rcl_node_t *node, rcl_allocator_t *allocator, bool no_demangle, rcl_names_and_types_t *topic_names_and_types)
Return a list of topic names and their types.
Definition: graph.c:245
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_get_node_names(const rcl_node_t *node, rcl_allocator_t allocator, rcutils_string_array_t *node_names, rcutils_string_array_t *node_namespaces)
Return a list of node names and their associated namespaces in the ROS graph.
Definition: graph.c:321
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_get_clients_info_by_service(const rcl_node_t *node, rcutils_allocator_t *allocator, const char *service_name, bool no_mangle, rcl_service_endpoint_info_array_t *clients_info)
Return a list of all clients to a service.
Definition: graph.c:849
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_count_publishers(const rcl_node_t *node, const char *topic_name, size_t *count)
Return the number of publishers on a given topic.
Definition: graph.c:427
Structure which encapsulates a ROS Client.
Definition: client.h:43
Structure which encapsulates a ROS Node.
Definition: node.h:45
rmw_ret_t rcl_ret_t
The type that holds an rcl return code.
Definition: types.h:24