ROS 2 rclcpp + rcl - rolling  rolling-e7363f10
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 <stdbool.h>
26 #include <stddef.h>
27 
28 #include <rmw/names_and_types.h>
29 #include <rmw/get_topic_names_and_types.h>
30 #include <rmw/service_endpoint_info_array.h>
31 #include <rmw/topic_endpoint_info.h>
32 #include <rmw/topic_endpoint_info_array.h>
33 
34 #include "rcutils/allocator.h"
35 #include "rcutils/time.h"
36 #include "rcutils/types.h"
37 
38 #include "rosidl_runtime_c/service_type_support_struct.h"
39 
40 #include "rcl/allocator.h"
41 #include "rcl/macros.h"
42 #include "rcl/client.h"
43 #include "rcl/node.h"
44 #include "rcl/types.h"
45 #include "rcl/visibility_control.h"
46 
48 typedef rmw_names_and_types_t rcl_names_and_types_t;
49 
53 typedef rmw_topic_endpoint_info_t rcl_topic_endpoint_info_t;
54 
56 typedef rmw_topic_endpoint_info_array_t rcl_topic_endpoint_info_array_t;
57 
61 typedef rmw_service_endpoint_info_t rcl_service_endpoint_info_t;
62 
63 // An array of service endpoint information.
64 typedef rmw_service_endpoint_info_array_t rcl_service_endpoint_info_array_t;
65 
67 #define rcl_get_zero_initialized_names_and_types rmw_get_zero_initialized_names_and_types
68 
70 #define rcl_get_zero_initialized_topic_endpoint_info_array \
71  rmw_get_zero_initialized_topic_endpoint_info_array
72 
74 #define rcl_topic_endpoint_info_array_fini rmw_topic_endpoint_info_array_fini
75 
77 #define rcl_get_zero_initialized_service_endpoint_info_array \
78  rmw_get_zero_initialized_service_endpoint_info_array
79 
81 #define rcl_service_endpoint_info_array_fini rmw_service_endpoint_info_array_fini
82 
84 
127 RCL_PUBLIC
128 RCL_WARN_UNUSED
129 rcl_ret_t
131  const rcl_node_t * node,
132  rcl_allocator_t * allocator,
133  bool no_demangle,
134  const char * node_name,
135  const char * node_namespace,
136  rcl_names_and_types_t * topic_names_and_types);
137 
139 
177 RCL_PUBLIC
178 RCL_WARN_UNUSED
179 rcl_ret_t
181  const rcl_node_t * node,
182  rcl_allocator_t * allocator,
183  bool no_demangle,
184  const char * node_name,
185  const char * node_namespace,
186  rcl_names_and_types_t * topic_names_and_types);
187 
189 
226 RCL_PUBLIC
227 RCL_WARN_UNUSED
228 rcl_ret_t
230  const rcl_node_t * node,
231  rcl_allocator_t * allocator,
232  const char * node_name,
233  const char * node_namespace,
234  rcl_names_and_types_t * service_names_and_types);
235 
237 
274 RCL_PUBLIC
275 RCL_WARN_UNUSED
276 rcl_ret_t
278  const rcl_node_t * node,
279  rcl_allocator_t * allocator,
280  const char * node_name,
281  const char * node_namespace,
282  rcl_names_and_types_t * service_names_and_types);
283 
285 
320 RCL_PUBLIC
321 RCL_WARN_UNUSED
322 rcl_ret_t
324  const rcl_node_t * node,
325  rcl_allocator_t * allocator,
326  bool no_demangle,
327  rcl_names_and_types_t * topic_names_and_types);
328 
330 
360 RCL_PUBLIC
361 RCL_WARN_UNUSED
362 rcl_ret_t
364  const rcl_node_t * node,
365  rcl_allocator_t * allocator,
366  rcl_names_and_types_t * service_names_and_types);
367 
369 
391 RCL_PUBLIC
392 RCL_WARN_UNUSED
393 rcl_ret_t
395  rcl_names_and_types_t * names_and_types,
396  size_t size,
397  rcl_allocator_t * allocator);
398 
400 
422 RCL_PUBLIC
423 RCL_WARN_UNUSED
424 rcl_ret_t
426 
428 
482 RCL_PUBLIC
483 RCL_WARN_UNUSED
484 rcl_ret_t
486  const rcl_node_t * node,
487  rcl_allocator_t allocator,
488  rcutils_string_array_t * node_names,
489  rcutils_string_array_t * node_namespaces);
490 
492 
515 RCL_PUBLIC
516 RCL_WARN_UNUSED
517 rcl_ret_t
519  const rcl_node_t * node,
520  rcl_allocator_t allocator,
521  rcutils_string_array_t * node_names,
522  rcutils_string_array_t * node_namespaces,
523  rcutils_string_array_t * enclaves);
524 
526 
563 RCL_PUBLIC
564 RCL_WARN_UNUSED
565 rcl_ret_t
567  const rcl_node_t * node,
568  const char * topic_name,
569  size_t * count);
570 
572 
609 RCL_PUBLIC
610 RCL_WARN_UNUSED
611 rcl_ret_t
613  const rcl_node_t * node,
614  const char * topic_name,
615  size_t * count);
616 
618 
655 RCL_PUBLIC
656 RCL_WARN_UNUSED
657 rcl_ret_t
659  const rcl_node_t * node,
660  const char * service_name,
661  size_t * count);
662 
664 
701 RCL_PUBLIC
702 RCL_WARN_UNUSED
703 rcl_ret_t
705  const rcl_node_t * node,
706  const char * service_name,
707  size_t * count);
708 
710 
753 RCL_PUBLIC
754 RCL_WARN_UNUSED
755 rcl_ret_t
757  const rcl_node_t * node,
758  rcl_allocator_t * allocator,
759  const char * topic_name,
760  const size_t count,
761  rcutils_duration_value_t timeout,
762  bool * success);
763 
765 
790 RCL_PUBLIC
791 RCL_WARN_UNUSED
792 rcl_ret_t
794  const rcl_node_t * node,
795  rcl_allocator_t * allocator,
796  const char * topic_name,
797  const size_t count,
798  rcutils_duration_value_t timeout,
799  bool * success);
800 
802 
827 RCL_PUBLIC
828 RCL_WARN_UNUSED
829 rcl_ret_t
831  const rcl_node_t * node,
832  rcl_allocator_t * allocator,
833  const char * service_name,
834  const size_t count,
835  rcutils_duration_value_t timeout,
836  bool * success);
837 
839 
864 RCL_PUBLIC
865 RCL_WARN_UNUSED
866 rcl_ret_t
868  const rcl_node_t * node,
869  rcl_allocator_t * allocator,
870  const char * service_name,
871  const size_t count,
872  rcutils_duration_value_t timeout,
873  bool * success);
874 
876 
926 RCL_PUBLIC
927 RCL_WARN_UNUSED
928 rcl_ret_t
930  const rcl_node_t * node,
931  rcutils_allocator_t * allocator,
932  const char * topic_name,
933  bool no_mangle,
934  rcl_topic_endpoint_info_array_t * publishers_info);
935 
937 
987 RCL_PUBLIC
988 RCL_WARN_UNUSED
989 rcl_ret_t
991  const rcl_node_t * node,
992  rcutils_allocator_t * allocator,
993  const char * topic_name,
994  bool no_mangle,
995  rcl_topic_endpoint_info_array_t * subscriptions_info);
996 
998 
1052 RCL_PUBLIC
1053 RCL_WARN_UNUSED
1054 rcl_ret_t
1056  const rcl_node_t * node,
1057  rcutils_allocator_t * allocator,
1058  const char * service_name,
1059  bool no_mangle,
1060  rcl_service_endpoint_info_array_t * clients_info);
1061 
1063 
1117 RCL_PUBLIC
1118 RCL_WARN_UNUSED
1119 rcl_ret_t
1121  const rcl_node_t * node,
1122  rcutils_allocator_t * allocator,
1123  const char * service_name,
1124  bool no_mangle,
1125  rcl_service_endpoint_info_array_t * servers_info);
1126 
1128 
1162 RCL_PUBLIC
1163 RCL_WARN_UNUSED
1164 rcl_ret_t
1166  const rcl_node_t * node,
1167  const rcl_client_t * client,
1168  bool * is_available);
1169 
1170 #ifdef __cplusplus
1171 }
1172 #endif
1173 
1174 #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:872
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:702
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:490
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:788
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:317
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:386
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:683
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:278
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:211
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:889
rmw_topic_endpoint_info_t rcl_topic_endpoint_info_t
Definition: graph.h:53
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:771
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:303
rmw_topic_endpoint_info_array_t rcl_topic_endpoint_info_array_t
An array of topic endpoint information.
Definition: graph.h:56
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:171
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:129
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:452
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:644
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:471
rmw_names_and_types_t rcl_names_and_types_t
A structure that contains topic names and types.
Definition: graph.h:48
rmw_service_endpoint_info_t rcl_service_endpoint_info_t
Definition: graph.h:61
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:88
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:663
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:251
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:327
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:855
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:433
Structure which encapsulates a ROS Client.
Definition: client.h:47
Structure which encapsulates a ROS Node.
Definition: node.h:49
rmw_ret_t rcl_ret_t
The type that holds an rcl return code.
Definition: types.h:25