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