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