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