ROS 2 rclcpp + rcl - rolling  rolling-e7363f10
ROS 2 C++ Client Library with ROS Client Library
publisher.c
1 // Copyright 2015 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 
15 #ifdef __cplusplus
16 extern "C"
17 {
18 #endif
19 
20 #include "rcl/publisher.h"
21 
22 #include <stdbool.h>
23 #include <stddef.h>
24 
25 #include "rcl/allocator.h"
26 #include "rcl/error_handling.h"
27 #include "rcl/node.h"
28 #include "rcl/node_type_cache.h"
29 #include "rcl/time.h"
30 #include "rcl/types.h"
31 
32 #include "rcutils/error_handling.h"
33 #include "rcutils/logging_macros.h"
34 #include "rcutils/macros.h"
35 
36 #include "rmw/error_handling.h"
37 #include "rmw/qos_profiles.h"
38 #include "rmw/ret_types.h"
39 #include "rmw/rmw.h"
40 #include "rmw/time.h"
41 #include "rmw/types.h"
42 #include "tracetools/tracetools.h"
43 
44 #include "./common.h"
45 #include "./publisher_impl.h"
46 
49 {
50  // All members are initialized to 0 or NULL by C99 6.7.8/10.
51  static rcl_publisher_t null_publisher;
52  return null_publisher;
53 }
54 
57  rcl_publisher_t * publisher,
58  const rcl_node_t * node,
59  const rosidl_message_type_support_t * type_support,
60  const char * topic_name,
61  const rcl_publisher_options_t * options
62 )
63 {
64  RCUTILS_CAN_RETURN_WITH_ERROR_OF(RCL_RET_INVALID_ARGUMENT);
65  RCUTILS_CAN_RETURN_WITH_ERROR_OF(RCL_RET_ALREADY_INIT);
66  RCUTILS_CAN_RETURN_WITH_ERROR_OF(RCL_RET_NODE_INVALID);
67  RCUTILS_CAN_RETURN_WITH_ERROR_OF(RCL_RET_BAD_ALLOC);
68  RCUTILS_CAN_RETURN_WITH_ERROR_OF(RCL_RET_ERROR);
69  RCUTILS_CAN_RETURN_WITH_ERROR_OF(RCL_RET_TOPIC_NAME_INVALID);
70 
71  rcl_ret_t fail_ret = RCL_RET_ERROR;
72 
73  // Check options and allocator first, so allocator can be used with errors.
74  RCL_CHECK_ARGUMENT_FOR_NULL(options, RCL_RET_INVALID_ARGUMENT);
75  rcl_allocator_t * allocator = (rcl_allocator_t *)&options->allocator;
76  RCL_CHECK_ALLOCATOR_WITH_MSG(allocator, "invalid allocator", return RCL_RET_INVALID_ARGUMENT);
77 
78  RCL_CHECK_ARGUMENT_FOR_NULL(publisher, RCL_RET_INVALID_ARGUMENT);
79  if (publisher->impl) {
80  RCL_SET_ERROR_MSG("publisher already initialized, or memory was unintialized");
81  return RCL_RET_ALREADY_INIT;
82  }
83  if (!rcl_node_is_valid(node)) {
84  return RCL_RET_NODE_INVALID; // error already set
85  }
86  RCL_CHECK_ARGUMENT_FOR_NULL(type_support, RCL_RET_INVALID_ARGUMENT);
87  RCL_CHECK_ARGUMENT_FOR_NULL(topic_name, RCL_RET_INVALID_ARGUMENT);
88  RCUTILS_LOG_DEBUG_NAMED(
89  ROS_PACKAGE_NAME, "Initializing publisher for topic name '%s'", topic_name);
90 
91  // Expand and remap the given topic name.
92  char * remapped_topic_name = NULL;
94  node,
95  topic_name,
96  *allocator,
97  false,
98  false,
99  &remapped_topic_name);
100  if (ret != RCL_RET_OK) {
103  } else if (ret != RCL_RET_BAD_ALLOC) {
104  ret = RCL_RET_ERROR;
105  }
106  goto cleanup;
107  }
108  RCUTILS_LOG_DEBUG_NAMED(
109  ROS_PACKAGE_NAME, "Expanded and remapped topic name '%s'", remapped_topic_name);
110 
111  // Allocate space for the implementation struct.
112  publisher->impl = (rcl_publisher_impl_t *)allocator->zero_allocate(
113  1, sizeof(rcl_publisher_impl_t), allocator->state);
114  RCL_CHECK_FOR_NULL_WITH_MSG(
115  publisher->impl, "allocating memory failed", ret = RCL_RET_BAD_ALLOC; goto cleanup);
116 
117  // Fill out implementation struct.
118  // rmw handle (create rmw publisher)
119  // TODO(wjwwood): pass along the allocator to rmw when it supports it
120  publisher->impl->rmw_handle = rmw_create_publisher(
122  type_support,
123  remapped_topic_name,
124  &(options->qos),
125  &(options->rmw_publisher_options));
126  RCL_CHECK_FOR_NULL_WITH_MSG(
127  publisher->impl->rmw_handle, rmw_get_error_string().str, goto fail);
128  // get actual qos, and store it
129  rmw_ret_t rmw_ret = rmw_publisher_get_actual_qos(
130  publisher->impl->rmw_handle,
131  &publisher->impl->actual_qos);
132  if (RMW_RET_OK != rmw_ret) {
133  RCL_SET_ERROR_MSG(rmw_get_error_string().str);
134  goto fail;
135  }
136  publisher->impl->actual_qos.avoid_ros_namespace_conventions =
137  options->qos.avoid_ros_namespace_conventions;
138  // options
139  publisher->impl->options = *options;
140 
141  if (RCL_RET_OK != rcl_node_type_cache_register_type(
142  node, type_support->get_type_hash_func(type_support),
143  type_support->get_type_description_func(type_support),
144  type_support->get_type_description_sources_func(type_support)))
145  {
146  rcutils_reset_error();
147  RCL_SET_ERROR_MSG("Failed to register type for subscription");
148  goto fail;
149  }
150  publisher->impl->type_hash = *type_support->get_type_hash_func(type_support);
151 
152  RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME, "Publisher initialized");
153  // context
154  publisher->impl->context = node->context;
155  TRACETOOLS_TRACEPOINT(
157  (const void *)publisher,
158  (const void *)node,
159  (const void *)publisher->impl->rmw_handle,
160  remapped_topic_name,
161  options->qos.depth);
162 
163  goto cleanup;
164 fail:
165  if (publisher->impl) {
166  if (publisher->impl->rmw_handle) {
167  rmw_ret_t rmw_fail_ret = rmw_destroy_publisher(
168  rcl_node_get_rmw_handle(node), publisher->impl->rmw_handle);
169  if (RMW_RET_OK != rmw_fail_ret) {
170  RCUTILS_SAFE_FWRITE_TO_STDERR(rmw_get_error_string().str);
171  RCUTILS_SAFE_FWRITE_TO_STDERR("\n");
172  }
173  }
174 
175  allocator->deallocate(publisher->impl, allocator->state);
176  publisher->impl = NULL;
177  }
178 
179  ret = fail_ret;
180  // Fall through to cleanup
181 cleanup:
182  allocator->deallocate(remapped_topic_name, allocator->state);
183  return ret;
184 }
185 
186 rcl_ret_t
188 {
189  RCUTILS_CAN_RETURN_WITH_ERROR_OF(RCL_RET_PUBLISHER_INVALID);
190  RCUTILS_CAN_RETURN_WITH_ERROR_OF(RCL_RET_NODE_INVALID);
191  RCUTILS_CAN_RETURN_WITH_ERROR_OF(RCL_RET_INVALID_ARGUMENT);
192  RCUTILS_CAN_RETURN_WITH_ERROR_OF(RCL_RET_ERROR);
193 
194  rcl_ret_t result = RCL_RET_OK;
195  RCL_CHECK_ARGUMENT_FOR_NULL(publisher, RCL_RET_PUBLISHER_INVALID);
197  return RCL_RET_NODE_INVALID; // error already set
198  }
199 
200  RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME, "Finalizing publisher");
201  if (publisher->impl) {
202  rcl_allocator_t allocator = publisher->impl->options.allocator;
203  rmw_node_t * rmw_node = rcl_node_get_rmw_handle(node);
204  if (!rmw_node) {
206  }
207  rmw_ret_t ret =
208  rmw_destroy_publisher(rmw_node, publisher->impl->rmw_handle);
209  if (ret != RMW_RET_OK) {
210  RCL_SET_ERROR_MSG(rmw_get_error_string().str);
211  result = RCL_RET_ERROR;
212  }
213  if (
214  ROSIDL_TYPE_HASH_VERSION_UNSET != publisher->impl->type_hash.version &&
215  RCL_RET_OK != rcl_node_type_cache_unregister_type(node, &publisher->impl->type_hash))
216  {
217  RCUTILS_SAFE_FWRITE_TO_STDERR(rcl_get_error_string().str);
218  result = RCL_RET_ERROR;
219  }
220  allocator.deallocate(publisher->impl, allocator.state);
221  publisher->impl = NULL;
222  }
223  RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME, "Publisher finalized");
224  return result;
225 }
226 
229 {
230  // !!! MAKE SURE THAT CHANGES TO THESE DEFAULTS ARE REFLECTED IN THE HEADER DOC STRING
231  rcl_publisher_options_t default_options;
232  // Must set the allocator and qos after because they are not a compile time constant.
233  default_options.qos = rmw_qos_profile_default;
234  default_options.allocator = rcl_get_default_allocator();
235  default_options.rmw_publisher_options = rmw_get_default_publisher_options();
236 
237  // Load disable flag to LoanedMessage via environmental variable.
238  bool disable_loaned_message = false;
239  rcl_ret_t ret = rcl_get_disable_loaned_message(&disable_loaned_message);
240  if (ret == RCL_RET_OK) {
241  default_options.disable_loaned_message = disable_loaned_message;
242  } else {
243  RCUTILS_SAFE_FWRITE_TO_STDERR("Failed to get disable_loaned_message: ");
244  RCUTILS_SAFE_FWRITE_TO_STDERR(rcl_get_error_string().str);
245  rcl_reset_error();
246  default_options.disable_loaned_message = false;
247  }
248 
249  return default_options;
250 }
251 
252 rcl_ret_t
254  const rcl_publisher_t * publisher,
255  const rosidl_message_type_support_t * type_support,
256  void ** ros_message)
257 {
258  if (!rcl_publisher_is_valid(publisher)) {
259  return RCL_RET_PUBLISHER_INVALID; // error already set
260  }
261  return rcl_convert_rmw_ret_to_rcl_ret(
262  rmw_borrow_loaned_message(publisher->impl->rmw_handle, type_support, ros_message));
263 }
264 
265 rcl_ret_t
267  const rcl_publisher_t * publisher,
268  void * loaned_message)
269 {
270  if (!rcl_publisher_is_valid(publisher)) {
271  return RCL_RET_PUBLISHER_INVALID; // error already set
272  }
273  RCL_CHECK_ARGUMENT_FOR_NULL(loaned_message, RCL_RET_INVALID_ARGUMENT);
274  return rcl_convert_rmw_ret_to_rcl_ret(
275  rmw_return_loaned_message_from_publisher(publisher->impl->rmw_handle, loaned_message));
276 }
277 
278 rcl_ret_t
280  const rcl_publisher_t * publisher,
281  const void * ros_message,
282  rmw_publisher_allocation_t * allocation)
283 {
284  RCUTILS_CAN_RETURN_WITH_ERROR_OF(RCL_RET_PUBLISHER_INVALID);
285  RCUTILS_CAN_RETURN_WITH_ERROR_OF(RCL_RET_ERROR);
286 
287  if (!rcl_publisher_is_valid(publisher)) {
288  return RCL_RET_PUBLISHER_INVALID; // error already set
289  }
290  RCL_CHECK_ARGUMENT_FOR_NULL(ros_message, RCL_RET_INVALID_ARGUMENT);
291  TRACETOOLS_TRACEPOINT(rcl_publish, (const void *)publisher, (const void *)ros_message);
292  if (rmw_publish(publisher->impl->rmw_handle, ros_message, allocation) != RMW_RET_OK) {
293  RCL_SET_ERROR_MSG(rmw_get_error_string().str);
294  return RCL_RET_ERROR;
295  }
296  return RCL_RET_OK;
297 }
298 
299 rcl_ret_t
301  const rcl_publisher_t * publisher,
302  const rcl_serialized_message_t * serialized_message,
303  rmw_publisher_allocation_t * allocation)
304 {
305  if (!rcl_publisher_is_valid(publisher)) {
306  return RCL_RET_PUBLISHER_INVALID; // error already set
307  }
308  RCL_CHECK_ARGUMENT_FOR_NULL(serialized_message, RCL_RET_INVALID_ARGUMENT);
309  TRACETOOLS_TRACEPOINT(rcl_publish, (const void *)publisher, (const void *)serialized_message);
310  rmw_ret_t ret = rmw_publish_serialized_message(
311  publisher->impl->rmw_handle, serialized_message, allocation);
312  if (ret != RMW_RET_OK) {
313  RCL_SET_ERROR_MSG(rmw_get_error_string().str);
314  if (ret == RMW_RET_BAD_ALLOC) {
315  return RCL_RET_BAD_ALLOC;
316  }
317  return RCL_RET_ERROR;
318  }
319  return RCL_RET_OK;
320 }
321 
322 rcl_ret_t
324  const rcl_publisher_t * publisher,
325  void * ros_message,
326  rmw_publisher_allocation_t * allocation)
327 {
328  if (!rcl_publisher_is_valid(publisher)) {
329  return RCL_RET_PUBLISHER_INVALID; // error already set
330  }
331  RCL_CHECK_ARGUMENT_FOR_NULL(ros_message, RCL_RET_INVALID_ARGUMENT);
332  TRACETOOLS_TRACEPOINT(rcl_publish, (const void *)publisher, (const void *)ros_message);
333  rmw_ret_t ret = rmw_publish_loaned_message(publisher->impl->rmw_handle, ros_message, allocation);
334  if (ret != RMW_RET_OK) {
335  RCL_SET_ERROR_MSG(rmw_get_error_string().str);
336  return RCL_RET_ERROR;
337  }
338  return RCL_RET_OK;
339 }
340 
341 rcl_ret_t
343 {
344  if (!rcl_publisher_is_valid(publisher)) {
345  return RCL_RET_PUBLISHER_INVALID; // error already set
346  }
347  if (rmw_publisher_assert_liveliness(publisher->impl->rmw_handle) != RMW_RET_OK) {
348  RCL_SET_ERROR_MSG(rmw_get_error_string().str);
349  return RCL_RET_ERROR;
350  }
351  return RCL_RET_OK;
352 }
353 
354 rcl_ret_t
356 {
357  if (!rcl_publisher_is_valid(publisher)) {
358  return RCL_RET_PUBLISHER_INVALID; // error already set
359  }
360 
361  rmw_time_t rmw_timeout;
362  if (timeout > 0) {
363  rmw_timeout.sec = RCL_NS_TO_S(timeout);
364  rmw_timeout.nsec = timeout % 1000000000;
365  } else if (timeout < 0) {
366  rmw_time_t infinite = RMW_DURATION_INFINITE;
367  rmw_timeout = infinite;
368  } else {
369  rmw_time_t zero = RMW_DURATION_UNSPECIFIED;
370  rmw_timeout = zero;
371  }
372 
373  rmw_ret_t ret = rmw_publisher_wait_for_all_acked(publisher->impl->rmw_handle, rmw_timeout);
374  if (ret != RMW_RET_OK) {
375  if (ret == RMW_RET_TIMEOUT) {
376  return RCL_RET_TIMEOUT;
377  }
378  RCL_SET_ERROR_MSG(rmw_get_error_string().str);
379  if (ret == RMW_RET_UNSUPPORTED) {
380  return RCL_RET_UNSUPPORTED;
381  } else {
382  return RCL_RET_ERROR;
383  }
384  }
385 
386  return RCL_RET_OK;
387 }
388 
389 const char *
391 {
392  if (!rcl_publisher_is_valid_except_context(publisher)) {
393  return NULL; // error already set
394  }
395  return publisher->impl->rmw_handle->topic_name;
396 }
397 
400 {
401  if (!rcl_publisher_is_valid_except_context(publisher)) {
402  return NULL; // error already set
403  }
404  return &publisher->impl->options;
405 }
406 
407 rmw_publisher_t *
409 {
410  if (!rcl_publisher_is_valid_except_context(publisher)) {
411  return NULL; // error already set
412  }
413  return publisher->impl->rmw_handle;
414 }
415 
418 {
419  if (!rcl_publisher_is_valid_except_context(publisher)) {
420  return NULL; // error already set
421  }
422  return publisher->impl->context;
423 }
424 
425 bool
427 {
428  if (!rcl_publisher_is_valid_except_context(publisher)) {
429  return false; // error already set
430  }
431  if (!rcl_context_is_valid(publisher->impl->context)) {
432  if (!rcl_error_is_set()) {
433  // rcl_context_is_valid can return false both in the error case, and when the context
434  // hasn't been initialized. It will only set the error message in the first case.
435  RCL_SET_ERROR_MSG("publisher's context is invalid");
436  }
437  return false;
438  }
439  RCL_CHECK_FOR_NULL_WITH_MSG(
440  publisher->impl->rmw_handle, "publisher's rmw handle is invalid", return false);
441  return true;
442 }
443 
444 bool
446 {
447  RCL_CHECK_FOR_NULL_WITH_MSG(publisher, "publisher pointer is invalid", return false);
448  RCL_CHECK_FOR_NULL_WITH_MSG(
449  publisher->impl, "publisher implementation is invalid", return false);
450  RCL_CHECK_FOR_NULL_WITH_MSG(
451  publisher->impl->rmw_handle, "publisher's rmw handle is invalid", return false);
452  return true;
453 }
454 
455 rcl_ret_t
457  const rcl_publisher_t * publisher,
458  size_t * subscription_count)
459 {
460  if (!rcl_publisher_is_valid(publisher)) {
462  }
463  RCL_CHECK_ARGUMENT_FOR_NULL(subscription_count, RCL_RET_INVALID_ARGUMENT);
464 
465  rmw_ret_t ret = rmw_publisher_count_matched_subscriptions(
466  publisher->impl->rmw_handle, subscription_count);
467 
468  if (ret != RMW_RET_OK) {
469  RCL_SET_ERROR_MSG(rmw_get_error_string().str);
470  return rcl_convert_rmw_ret_to_rcl_ret(ret);
471  }
472  return RCL_RET_OK;
473 }
474 
475 const rmw_qos_profile_t *
477 {
478  if (!rcl_publisher_is_valid_except_context(publisher)) {
479  return NULL;
480  }
481  return &publisher->impl->actual_qos;
482 }
483 
484 bool
486 {
487  if (!rcl_publisher_is_valid(publisher)) {
488  return false; // error message already set
489  }
490 
491  if (publisher->impl->options.disable_loaned_message) {
492  return false;
493  }
494 
495  return publisher->impl->rmw_handle->can_loan_messages;
496 }
497 
498 #ifdef __cplusplus
499 }
500 #endif
#define rcl_get_default_allocator
Return a properly initialized rcl_allocator_t with default values.
Definition: allocator.h:37
#define RCL_CHECK_ALLOCATOR_WITH_MSG(allocator, msg, fail_statement)
Check that the given allocator is initialized, or fail with a message.
Definition: allocator.h:56
rcutils_allocator_t rcl_allocator_t
Encapsulation of an allocator.
Definition: allocator.h:31
RCL_PUBLIC RCL_WARN_UNUSED bool rcl_context_is_valid(const rcl_context_t *context)
Return true if the given context is currently valid, otherwise false.
Definition: context.c:106
RCL_PUBLIC bool rcl_node_is_valid(const rcl_node_t *node)
Return true if the node is valid, else false.
Definition: node.c:406
RCL_PUBLIC rcl_ret_t rcl_get_disable_loaned_message(bool *disable_loaned_message)
Check if loaned message is disabled, according to the environment variable.
Definition: node.c:506
RCL_PUBLIC RCL_WARN_UNUSED rmw_node_t * rcl_node_get_rmw_handle(const rcl_node_t *node)
Return the rmw node handle.
Definition: node.c:470
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_node_resolve_name(const rcl_node_t *node, const char *input_name, rcl_allocator_t allocator, bool is_service, bool only_expand, char **output_name)
Expand a given name into a fully-qualified topic name and apply remapping rules.
RCL_PUBLIC bool rcl_node_is_valid_except_context(const rcl_node_t *node)
Return true if node is valid, except for the context being valid.
Definition: node.c:396
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_publisher_init(rcl_publisher_t *publisher, const rcl_node_t *node, const rosidl_message_type_support_t *type_support, const char *topic_name, const rcl_publisher_options_t *options)
Initialize a rcl publisher.
Definition: publisher.c:56
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_publish_loaned_message(const rcl_publisher_t *publisher, void *ros_message, rmw_publisher_allocation_t *allocation)
Publish a loaned message on a topic using a publisher.
Definition: publisher.c:323
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_publisher_wait_for_all_acked(const rcl_publisher_t *publisher, rcl_duration_value_t timeout)
Wait until all published message data is acknowledged or until the specified timeout elapses.
Definition: publisher.c:355
RCL_PUBLIC bool rcl_publisher_is_valid(const rcl_publisher_t *publisher)
Return true if the publisher is valid, otherwise false.
Definition: publisher.c:426
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_publish_serialized_message(const rcl_publisher_t *publisher, const rcl_serialized_message_t *serialized_message, rmw_publisher_allocation_t *allocation)
Publish a serialized message on a topic using a publisher.
Definition: publisher.c:300
RCL_PUBLIC RCL_WARN_UNUSED rcl_context_t * rcl_publisher_get_context(const rcl_publisher_t *publisher)
Return the context associated with this publisher.
Definition: publisher.c:417
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_publish(const rcl_publisher_t *publisher, const void *ros_message, rmw_publisher_allocation_t *allocation)
Publish a ROS message on a topic using a publisher.
Definition: publisher.c:279
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_borrow_loaned_message(const rcl_publisher_t *publisher, const rosidl_message_type_support_t *type_support, void **ros_message)
Borrow a loaned message.
Definition: publisher.c:253
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_publisher_get_subscription_count(const rcl_publisher_t *publisher, size_t *subscription_count)
Get the number of subscriptions matched to a publisher.
Definition: publisher.c:456
RCL_PUBLIC RCL_WARN_UNUSED rmw_publisher_t * rcl_publisher_get_rmw_handle(const rcl_publisher_t *publisher)
Return the rmw publisher handle.
Definition: publisher.c:408
RCL_PUBLIC RCL_WARN_UNUSED const char * rcl_publisher_get_topic_name(const rcl_publisher_t *publisher)
Get the topic name for the publisher.
Definition: publisher.c:390
RCL_PUBLIC RCL_WARN_UNUSED const rmw_qos_profile_t * rcl_publisher_get_actual_qos(const rcl_publisher_t *publisher)
Get the actual qos settings of the publisher.
Definition: publisher.c:476
RCL_PUBLIC RCL_WARN_UNUSED rcl_publisher_options_t rcl_publisher_get_default_options(void)
Return the default publisher options in a rcl_publisher_options_t.
Definition: publisher.c:228
RCL_PUBLIC bool rcl_publisher_is_valid_except_context(const rcl_publisher_t *publisher)
Return true if the publisher is valid except the context, otherwise false.
Definition: publisher.c:445
RCL_PUBLIC RCL_WARN_UNUSED const rcl_publisher_options_t * rcl_publisher_get_options(const rcl_publisher_t *publisher)
Return the rcl publisher options.
Definition: publisher.c:399
RCL_PUBLIC RCL_WARN_UNUSED rcl_publisher_t rcl_get_zero_initialized_publisher(void)
Return a rcl_publisher_t struct with members set to NULL.
Definition: publisher.c:48
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_publisher_fini(rcl_publisher_t *publisher, rcl_node_t *node)
Finalize a rcl_publisher_t.
Definition: publisher.c:187
RCL_PUBLIC bool rcl_publisher_can_loan_messages(const rcl_publisher_t *publisher)
Check if publisher instance can loan messages.
Definition: publisher.c:485
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_return_loaned_message_from_publisher(const rcl_publisher_t *publisher, void *loaned_message)
Return a loaned message previously borrowed from a publisher.
Definition: publisher.c:266
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_publisher_assert_liveliness(const rcl_publisher_t *publisher)
Manually assert that this Publisher is alive (for RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_TOPIC)
Definition: publisher.c:342
Encapsulates the non-global state of an init/shutdown cycle.
Definition: context.h:117
Structure which encapsulates a ROS Node.
Definition: node.h:49
rcl_context_t * context
Context associated with this node.
Definition: node.h:51
Options available for a rcl publisher.
Definition: publisher.h:51
rmw_qos_profile_t qos
Middleware quality of service settings for the publisher.
Definition: publisher.h:53
rmw_publisher_options_t rmw_publisher_options
rmw specific publisher options, e.g. the rmw implementation specific payload.
Definition: publisher.h:58
bool disable_loaned_message
Disable flag to LoanedMessage, initialized via environmental variable.
Definition: publisher.h:60
rcl_allocator_t allocator
Custom allocator for the publisher, used for incidental allocations.
Definition: publisher.h:56
Structure which encapsulates a ROS Publisher.
Definition: publisher.h:44
rcl_publisher_impl_t * impl
Pointer to the publisher implementation.
Definition: publisher.h:46
#define RCL_NS_TO_S
Convenience macro to convert nanoseconds to seconds.
Definition: time.h:42
rcutils_duration_value_t rcl_duration_value_t
A duration of time, measured in nanoseconds.
Definition: time.h:51
#define RCL_RET_UNSUPPORTED
Unsupported return code.
Definition: types.h:38
#define RCL_RET_UNKNOWN_SUBSTITUTION
Topic name substitution is unknown.
Definition: types.h:52
#define RCL_RET_ALREADY_INIT
rcl_init() already called return code.
Definition: types.h:42
#define RCL_RET_OK
Success return code.
Definition: types.h:28
#define RCL_RET_BAD_ALLOC
Failed to allocate memory return code.
Definition: types.h:34
#define RCL_RET_INVALID_ARGUMENT
Invalid argument return code.
Definition: types.h:36
#define RCL_RET_ERROR
Unspecified error return code.
Definition: types.h:30
rmw_serialized_message_t rcl_serialized_message_t
typedef for rmw_serialized_message_t;
Definition: types.h:153
#define RCL_RET_NODE_INVALID
Invalid rcl_node_t given return code.
Definition: types.h:60
#define RCL_RET_TOPIC_NAME_INVALID
Topic name does not pass validation.
Definition: types.h:48
#define RCL_RET_TIMEOUT
Timeout occurred return code.
Definition: types.h:32
rmw_ret_t rcl_ret_t
The type that holds an rcl return code.
Definition: types.h:25
#define RCL_RET_PUBLISHER_INVALID
Invalid rcl_publisher_t given return code.
Definition: types.h:70