rmw  master
C API providing a middleware abstraction layer which is used to implement the rest of ROS.
rmw.h
Go to the documentation of this file.
1 // Copyright 2014-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 
78 #ifndef RMW__RMW_H_
79 #define RMW__RMW_H_
80 
81 #ifdef __cplusplus
82 extern "C"
83 {
84 #endif
85 
86 #include <stdbool.h>
87 #include <stddef.h>
88 #include <stdint.h>
89 
90 #include "rcutils/types.h"
91 
92 #include "rosidl_generator_c/message_bounds_struct.h"
93 #include "rosidl_generator_c/message_type_support_struct.h"
94 #include "rosidl_generator_c/service_type_support_struct.h"
95 
96 #include "rmw/init.h"
97 #include "rmw/macros.h"
98 #include "rmw/qos_profiles.h"
100 #include "rmw/types.h"
101 #include "rmw/visibility_control.h"
102 
105 const char *
107 
109 
122 const char *
124 
125 // TODO(wjwwood): refactor this API to return a return code when updated to use an allocator
127 
169 rmw_node_t *
171  rmw_context_t * context,
172  const char * name,
173  const char * namespace_,
174  size_t domain_id,
175  const rmw_node_security_options_t * security_options,
176  bool localhost_only);
177 
179 
187 rmw_ret_t
189 
191 
211 rmw_ret_t
213 
215 
243 const rmw_guard_condition_t *
245 
247 
265 rmw_ret_t
267  const rosidl_message_type_support_t * type_support,
268  const rosidl_message_bounds_t * message_bounds,
269  rmw_publisher_allocation_t * allocation);
270 
272 
282 rmw_ret_t
284  rmw_publisher_allocation_t * allocation);
285 
291 
293 
305  const rmw_node_t * node,
306  const rosidl_message_type_support_t * type_support,
307  const char * topic_name,
308  const rmw_qos_profile_t * qos_policies,
309  const rmw_publisher_options_t * publisher_options);
310 
313 rmw_ret_t
315 
317 
336 rmw_ret_t
338  const rmw_publisher_t * publisher,
339  const rosidl_message_type_support_t * type_support,
340  void ** ros_message);
341 
343 
356 rmw_ret_t
358  const rmw_publisher_t * publisher,
359  void * loaned_message);
360 
362 
374 rmw_ret_t
376  const rmw_publisher_t * publisher,
377  const void * ros_message,
378  rmw_publisher_allocation_t * allocation);
379 
381 
400 rmw_ret_t
402  const rmw_publisher_t * publisher,
403  void * ros_message,
404  rmw_publisher_allocation_t * allocation);
405 
407 
419 rmw_ret_t
421  const rmw_publisher_t * publisher,
422  size_t * subscription_count);
423 
425 
445 rmw_ret_t
447  const rmw_publisher_t * publisher,
448  rmw_qos_profile_t * qos);
449 
451 
466 rmw_ret_t
468  const rmw_publisher_t * publisher,
469  const rmw_serialized_message_t * serialized_message,
470  rmw_publisher_allocation_t * allocation);
471 
473 
485 rmw_ret_t
487  const rosidl_message_type_support_t * type_support,
488  const rosidl_message_bounds_t * message_bounds,
489  size_t * size);
490 
492 
512 rmw_ret_t
514 
516 
530 rmw_ret_t
532  const void * ros_message,
533  const rosidl_message_type_support_t * type_support,
534  rmw_serialized_message_t * serialized_message);
535 
537 
554 rmw_ret_t
556  const rmw_serialized_message_t * serialized_message,
557  const rosidl_message_type_support_t * type_support,
558  void * ros_message);
559 
561 
579 rmw_ret_t
581  const rosidl_message_type_support_t * type_support,
582  const rosidl_message_bounds_t * message_bounds,
583  rmw_subscription_allocation_t * allocation);
584 
586 
596 rmw_ret_t
598  rmw_subscription_allocation_t * allocation);
599 
601 
613  const rmw_node_t * node,
614  const rosidl_message_type_support_t * type_support,
615  const char * topic_name,
616  const rmw_qos_profile_t * qos_policies,
617  const rmw_subscription_options_t * subscription_options);
618 
621 rmw_ret_t
623 
625 
637 rmw_ret_t
639  const rmw_subscription_t * subscription,
640  size_t * publisher_count);
641 
643 
663 rmw_ret_t
665  const rmw_subscription_t * subscription,
666  rmw_qos_profile_t * qos);
667 
669 
681 rmw_ret_t
682 rmw_take(
683  const rmw_subscription_t * subscription,
684  void * ros_message,
685  bool * taken,
686  rmw_subscription_allocation_t * allocation);
687 
689 
702 rmw_ret_t
704  const rmw_subscription_t * subscription,
705  void * ros_message,
706  bool * taken,
707  rmw_message_info_t * message_info,
708  rmw_subscription_allocation_t * allocation);
709 
711 
729 rmw_ret_t
731  const rmw_subscription_t * subscription,
732  rmw_serialized_message_t * serialized_message,
733  bool * taken,
734  rmw_subscription_allocation_t * allocation);
735 
737 
752 rmw_ret_t
754  const rmw_subscription_t * subscription,
755  rmw_serialized_message_t * serialized_message,
756  bool * taken,
757  rmw_message_info_t * message_info,
758  rmw_subscription_allocation_t * allocation);
759 
761 
776 rmw_ret_t
778  const rmw_subscription_t * subscription,
779  void ** loaned_message,
780  bool * taken,
781  rmw_subscription_allocation_t * allocation);
782 
784 
800 rmw_ret_t
802  const rmw_subscription_t * subscription,
803  void ** loaned_message,
804  bool * taken,
805  rmw_message_info_t * message_info,
806  rmw_subscription_allocation_t * allocation);
807 
809 
821 rmw_ret_t
823  const rmw_subscription_t * subscription,
824  void * loaned_message);
825 
828 rmw_client_t *
830  const rmw_node_t * node,
831  const rosidl_service_type_support_t * type_support,
832  const char * service_name,
833  const rmw_qos_profile_t * qos_policies);
834 
837 rmw_ret_t
838 rmw_destroy_client(rmw_node_t * node, rmw_client_t * client);
839 
842 rmw_ret_t
844  const rmw_client_t * client,
845  const void * ros_request,
846  int64_t * sequence_id);
847 
850 rmw_ret_t
852  const rmw_client_t * client,
853  rmw_request_id_t * request_header,
854  void * ros_response,
855  bool * taken);
856 
861  const rmw_node_t * node,
862  const rosidl_service_type_support_t * type_support,
863  const char * service_name,
864  const rmw_qos_profile_t * qos_policies);
865 
868 rmw_ret_t
869 rmw_destroy_service(rmw_node_t * node, rmw_service_t * service);
870 
873 rmw_ret_t
875  const rmw_service_t * service,
876  rmw_request_id_t * request_header,
877  void * ros_request,
878  bool * taken);
879 
882 rmw_ret_t
884  const rmw_service_t * service,
885  rmw_request_id_t * request_header,
886  void * ros_response);
887 
888 // TODO(wjwwood): refactor this API to return a return code when updated to use an allocator
890 
918 
919 
921 
929 rmw_ret_t
931 
934 rmw_ret_t
935 rmw_trigger_guard_condition(const rmw_guard_condition_t * guard_condition);
936 
938 
958 rmw_create_wait_set(rmw_context_t * context, size_t max_conditions);
959 
962 rmw_ret_t
964 
966 
1001 rmw_ret_t
1002 rmw_wait(
1003  rmw_subscriptions_t * subscriptions,
1004  rmw_guard_conditions_t * guard_conditions,
1005  rmw_services_t * services,
1006  rmw_clients_t * clients,
1007  rmw_events_t * events,
1008  rmw_wait_set_t * wait_set,
1009  const rmw_time_t * wait_timeout);
1010 
1012 
1038 RMW_PUBLIC
1040 rmw_ret_t
1042  const rmw_node_t * node,
1043  rcutils_string_array_t * node_names,
1044  rcutils_string_array_t * node_namespaces);
1045 
1046 RMW_PUBLIC
1048 rmw_ret_t
1050  const rmw_node_t * node,
1051  const char * topic_name,
1052  size_t * count);
1053 
1054 RMW_PUBLIC
1056 rmw_ret_t
1058  const rmw_node_t * node,
1059  const char * topic_name,
1060  size_t * count);
1061 
1062 RMW_PUBLIC
1064 rmw_ret_t
1065 rmw_get_gid_for_publisher(const rmw_publisher_t * publisher, rmw_gid_t * gid);
1066 
1067 RMW_PUBLIC
1069 rmw_ret_t
1070 rmw_compare_gids_equal(const rmw_gid_t * gid1, const rmw_gid_t * gid2, bool * result);
1071 
1073 
1099 RMW_PUBLIC
1101 rmw_ret_t
1103  const rmw_node_t * node,
1104  const rmw_client_t * client,
1105  bool * is_available);
1106 
1107 RMW_PUBLIC
1109 rmw_ret_t
1111 
1112 #ifdef __cplusplus
1113 }
1114 #endif
1115 
1116 #endif // RMW__RMW_H_
rmw_client_t * rmw_create_client(const rmw_node_t *node, const rosidl_service_type_support_t *type_support, const char *service_name, const rmw_qos_profile_t *qos_policies)
const rmw_guard_condition_t * rmw_node_get_graph_guard_condition(const rmw_node_t *node)
Return a guard condition which is triggered when the ROS graph changes.
rmw_ret_t rmw_set_log_severity(rmw_log_severity_t severity)
rmw_ret_t rmw_get_node_names(const rmw_node_t *node, rcutils_string_array_t *node_names, rcutils_string_array_t *node_namespaces)
Return a list of node name and namespaces discovered via a node.
rmw_node_t * rmw_create_node(rmw_context_t *context, const char *name, const char *namespace_, size_t domain_id, const rmw_node_security_options_t *security_options, bool localhost_only)
Create a node and return a handle to that node.
rmw_subscription_t * rmw_create_subscription(const rmw_node_t *node, const rosidl_message_type_support_t *type_support, const char *topic_name, const rmw_qos_profile_t *qos_policies, const rmw_subscription_options_t *subscription_options)
Create and return an rmw subscription.
rmw_publisher_t * rmw_create_publisher(const rmw_node_t *node, const rosidl_message_type_support_t *type_support, const char *topic_name, const rmw_qos_profile_t *qos_policies, const rmw_publisher_options_t *publisher_options)
Create and return an rmw publisher.
rmw_ret_t rmw_publish_loaned_message(const rmw_publisher_t *publisher, void *ros_message, rmw_publisher_allocation_t *allocation)
Publish a loaned ros_message.
rmw_publisher_options_t rmw_get_default_publisher_options(void)
Return a rmw_publisher_options_t initialized with default values.
rmw_ret_t rmw_publish(const rmw_publisher_t *publisher, const void *ros_message, rmw_publisher_allocation_t *allocation)
Publish a given ros_message.
rmw_ret_t rmw_get_gid_for_publisher(const rmw_publisher_t *publisher, rmw_gid_t *gid)
rmw_ret_t rmw_publisher_assert_liveliness(const rmw_publisher_t *publisher)
Manually assert that this Publisher is alive (for RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_TOPIC) ...
rmw_ret_t rmw_take_serialized_message(const rmw_subscription_t *subscription, rmw_serialized_message_t *serialized_message, bool *taken, rmw_subscription_allocation_t *allocation)
Take a message without deserializing it.
#define RMW_PUBLIC
Definition: visibility_control.h:48
rmw_ret_t rmw_return_loaned_message_from_subscription(const rmw_subscription_t *subscription, void *loaned_message)
Return a loaned message previously taken from a subscription.
Options that can be used to configure the creation of a subscription in rmw.
Definition: types.h:84
Definition: types.h:336
rmw_guard_condition_t * rmw_create_guard_condition(rmw_context_t *context)
Create a guard condition and return a handle to that guard condition.
Array of service handles.
Definition: types.h:184
rmw_ret_t rmw_publisher_count_matched_subscriptions(const rmw_publisher_t *publisher, size_t *subscription_count)
Retrieve the number of matched subscriptions to a publisher.
rmw_ret_t rmw_subscription_get_actual_qos(const rmw_subscription_t *subscription, rmw_qos_profile_t *qos)
Retrieve the actual qos settings of the subscription.
Array of subscriber handles.
Definition: types.h:169
#define RMW_WARN_UNUSED
Definition: macros.h:22
Definition: types.h:237
rmw_ret_t rmw_trigger_guard_condition(const rmw_guard_condition_t *guard_condition)
rmw_service_t * rmw_create_service(const rmw_node_t *node, const rosidl_service_type_support_t *type_support, const char *service_name, const rmw_qos_profile_t *qos_policies)
rmw_ret_t rmw_destroy_subscription(rmw_node_t *node, rmw_subscription_t *subscription)
rmw_ret_t rmw_publish_serialized_message(const rmw_publisher_t *publisher, const rmw_serialized_message_t *serialized_message, rmw_publisher_allocation_t *allocation)
Publish an already serialized message.
rmw_ret_t rmw_publisher_get_actual_qos(const rmw_publisher_t *publisher, rmw_qos_profile_t *qos)
Retrieve the actual qos settings of the publisher.
enum RMW_PUBLIC_TYPE rmw_log_severity_t
Type mapping of rcutils log severity types to rmw specific types.
const char * rmw_get_implementation_identifier(void)
Definition: types.h:156
Options that can be used to configure the creation of a publisher in rmw.
Definition: types.h:50
rmw_ret_t rmw_fini_subscription_allocation(rmw_subscription_allocation_t *allocation)
Destroy a publisher allocation object.
rmw_ret_t rmw_return_loaned_message_from_publisher(const rmw_publisher_t *publisher, void *loaned_message)
Return a loaned message previously borrow from a publisher.
rmw_ret_t rmw_destroy_client(rmw_node_t *node, rmw_client_t *client)
rmw_ret_t rmw_fini_publisher_allocation(rmw_publisher_allocation_t *allocation)
Destroy a publisher allocation object.
Definition: types.h:111
Initialization context structure which is used to store init specific information.
Definition: init.h:37
rmw_ret_t rmw_take_request(const rmw_service_t *service, rmw_request_id_t *request_header, void *ros_request, bool *taken)
rmw_ret_t rmw_count_subscribers(const rmw_node_t *node, const char *topic_name, size_t *count)
rmw_ret_t rmw_take_with_info(const rmw_subscription_t *subscription, void *ros_message, bool *taken, rmw_message_info_t *message_info, rmw_subscription_allocation_t *allocation)
Take an incoming message from a subscription with additional metadata.
Definition: types.h:136
rmw_ret_t rmw_wait(rmw_subscriptions_t *subscriptions, rmw_guard_conditions_t *guard_conditions, rmw_services_t *services, rmw_clients_t *clients, rmw_events_t *events, rmw_wait_set_t *wait_set, const rmw_time_t *wait_timeout)
Waits on sets of different waitable entities and returns when one is ready.
rmw_ret_t rmw_count_publishers(const rmw_node_t *node, const char *topic_name, size_t *count)
rmw_ret_t rmw_destroy_service(rmw_node_t *node, rmw_service_t *service)
Definition: types.h:330
rmw_ret_t rmw_take_response(const rmw_client_t *client, rmw_request_id_t *request_header, void *ros_response, bool *taken)
rmw_ret_t rmw_take_serialized_message_with_info(const rmw_subscription_t *subscription, rmw_serialized_message_t *serialized_message, bool *taken, rmw_message_info_t *message_info, rmw_subscription_allocation_t *allocation)
Take a message without deserializing it and with its additional message information.
rmw_ret_t rmw_serialize(const void *ros_message, const rosidl_message_type_support_t *type_support, rmw_serialized_message_t *serialized_message)
Serialize a ROS message into a rmw_serialized_message_t.
rmw_ret_t rmw_destroy_wait_set(rmw_wait_set_t *wait_set)
rmw_ret_t rmw_destroy_guard_condition(rmw_guard_condition_t *guard_condition)
Finalize a given guard condition handle, reclaim the resources, and deallocate the handle...
Definition: types.h:207
rmw_ret_t rmw_take(const rmw_subscription_t *subscription, void *ros_message, bool *taken, rmw_subscription_allocation_t *allocation)
Take an incoming message from a subscription.
rmw_ret_t rmw_node_assert_liveliness(const rmw_node_t *node)
Manually assert that this node is alive (for RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_NODE) ...
Definition: types.h:150
rmw_ret_t rmw_destroy_publisher(rmw_node_t *node, rmw_publisher_t *publisher)
rmw_ret_t rmw_borrow_loaned_message(const rmw_publisher_t *publisher, const rosidl_message_type_support_t *type_support, void **ros_message)
Borrow a loaned message.
Definition: types.h:230
rmw_ret_t rmw_destroy_node(rmw_node_t *node)
Finalize a given node handle, reclaim the resources, and deallocate the node handle.
Definition: types.h:243
rmw_ret_t rmw_deserialize(const rmw_serialized_message_t *serialized_message, const rosidl_message_type_support_t *type_support, void *ros_message)
Deserialize a ROS message.
int32_t rmw_ret_t
Definition: ret_types.h:25
const char * rmw_get_serialization_format(void)
Get the unique serialization format for this middleware.
Definition: types.h:143
Definition: types.h:129
Definition: types.h:255
rmw_ret_t rmw_take_loaned_message_with_info(const rmw_subscription_t *subscription, void **loaned_message, bool *taken, rmw_message_info_t *message_info, rmw_subscription_allocation_t *allocation)
Take a loaned message and with its additional message information.
Array of guard condition handles.
Definition: types.h:222
rmw_ret_t rmw_init_publisher_allocation(const rosidl_message_type_support_t *type_support, const rosidl_message_bounds_t *message_bounds, rmw_publisher_allocation_t *allocation)
Initialize a publisher allocation to be used with later publications.
Definition: types.h:65
rmw_ret_t rmw_send_response(const rmw_service_t *service, rmw_request_id_t *request_header, void *ros_response)
rmw_ret_t rmw_send_request(const rmw_client_t *client, const void *ros_request, int64_t *sequence_id)
Array of client handles.
Definition: types.h:199
rmw_ret_t rmw_get_serialized_message_size(const rosidl_message_type_support_t *type_support, const rosidl_message_bounds_t *message_bounds, size_t *size)
Compute the size of a serialized message.
rmw_ret_t rmw_init_subscription_allocation(const rosidl_message_type_support_t *type_support, const rosidl_message_bounds_t *message_bounds, rmw_subscription_allocation_t *allocation)
Initialize a subscription allocation to be used with later takes.
rmw_ret_t rmw_subscription_count_matched_publishers(const rmw_subscription_t *subscription, size_t *publisher_count)
Retrieve the number of matched publishers to a subscription.
rmw_ret_t rmw_service_server_is_available(const rmw_node_t *node, const rmw_client_t *client, bool *is_available)
Check if a service server is available for the given service client.
rmw_ret_t rmw_compare_gids_equal(const rmw_gid_t *gid1, const rmw_gid_t *gid2, bool *result)
rmw_wait_set_t * rmw_create_wait_set(rmw_context_t *context, size_t max_conditions)
Create a wait set to store conditions that the middleware will block on.
ROS MiddleWare quality of service profile.
Definition: types.h:299
Definition: types.h:40
rmw_ret_t rmw_take_loaned_message(const rmw_subscription_t *subscription, void **loaned_message, bool *taken, rmw_subscription_allocation_t *allocation)
Take a loaned message.