From 49f94d77c766689602fa0b7a046590b55808864a Mon Sep 17 00:00:00 2001 From: Karsten Knese Date: Mon, 23 Oct 2017 11:06:56 -0700 Subject: [PATCH 1/8] publish_raw function --- rcl/include/rcl/publisher.h | 5 +++++ rcl/include/rcl/types.h | 3 +++ rcl/src/rcl/publisher.c | 13 +++++++++++++ 3 files changed, 21 insertions(+) diff --git a/rcl/include/rcl/publisher.h b/rcl/include/rcl/publisher.h index 44b9c5086..083a264b3 100644 --- a/rcl/include/rcl/publisher.h +++ b/rcl/include/rcl/publisher.h @@ -252,6 +252,11 @@ RCL_WARN_UNUSED rcl_ret_t rcl_publish(const rcl_publisher_t * publisher, const void * ros_message); +RCL_PUBLIC +RCL_WARN_UNUSED +rcl_ret_t +rcl_publish_raw(const rcl_publisher_t * publisher, const rcl_message_raw_t * raw_message); + /// Get the topic name for the publisher. /** * This function returns the publisher's internal topic name string. diff --git a/rcl/include/rcl/types.h b/rcl/include/rcl/types.h index 0e6bfd729..c58f87f1a 100644 --- a/rcl/include/rcl/types.h +++ b/rcl/include/rcl/types.h @@ -97,4 +97,7 @@ typedef rmw_ret_t rcl_ret_t; /// Argument is not a valid log level rule #define RCL_RET_INVALID_LOG_LEVEL_RULE 1020 +/// typedef for rmw_message_raw_t; +typedef rmw_message_raw_t rcl_message_raw_t; + #endif // RCL__TYPES_H_ diff --git a/rcl/src/rcl/publisher.c b/rcl/src/rcl/publisher.c index 1cbabb8d7..8c5fe63f2 100644 --- a/rcl/src/rcl/publisher.c +++ b/rcl/src/rcl/publisher.c @@ -244,6 +244,19 @@ rcl_publish(const rcl_publisher_t * publisher, const void * ros_message) return RCL_RET_OK; } +rcl_ret_t +rcl_publish_raw(const rcl_publisher_t * publisher, const rcl_message_raw_t * raw_message) +{ + if (!rcl_publisher_is_valid(publisher)) { + return RCL_RET_PUBLISHER_INVALID; + } + if (rmw_publish_raw(publisher->impl->rmw_handle, raw_message) != RMW_RET_OK) { + RCL_SET_ERROR_MSG(rmw_get_error_string_safe(), rcl_get_default_allocator()); + return RCL_RET_ERROR; + } + return RCL_RET_OK; +} + const char * rcl_publisher_get_topic_name(const rcl_publisher_t * publisher) { From 85a46142ed4056931f7bb1690edd35cd9d5eea81 Mon Sep 17 00:00:00 2001 From: Karsten Knese Date: Mon, 13 Nov 2017 13:54:45 -0800 Subject: [PATCH 2/8] rcl_take_raw function --- rcl/include/rcl/subscription.h | 8 ++++++++ rcl/src/rcl/subscription.c | 35 ++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/rcl/include/rcl/subscription.h b/rcl/include/rcl/subscription.h index 507245ba2..e1c56f8fc 100644 --- a/rcl/include/rcl/subscription.h +++ b/rcl/include/rcl/subscription.h @@ -256,6 +256,14 @@ rcl_take( void * ros_message, rmw_message_info_t * message_info); +RCL_PUBLIC +RCL_WARN_UNUSED +rcl_ret_t +rcl_take_raw( + const rcl_subscription_t * subscription, + rcl_message_raw_t * raw_message, + rmw_message_info_t * message_info); + /// Get the topic name for the subscription. /** * This function returns the subscription's internal topic name string. diff --git a/rcl/src/rcl/subscription.c b/rcl/src/rcl/subscription.c index 2a8837bc6..f04aa72ae 100644 --- a/rcl/src/rcl/subscription.c +++ b/rcl/src/rcl/subscription.c @@ -272,6 +272,41 @@ rcl_take( return RCL_RET_OK; } +rcl_ret_t +rcl_take_raw( + const rcl_subscription_t * subscription, + rcl_message_raw_t * raw_message, + rmw_message_info_t * message_info) +{ + RCL_CHECK_ARGUMENT_FOR_NULL(subscription, RCL_RET_INVALID_ARGUMENT, rcl_get_default_allocator()); + const rcl_subscription_options_t * options = rcl_subscription_get_options(subscription); + if (!options) { + return RCL_RET_SUBSCRIPTION_INVALID; + } + RCL_CHECK_ARGUMENT_FOR_NULL(raw_message, RCL_RET_INVALID_ARGUMENT, options->allocator); + RCL_CHECK_FOR_NULL_WITH_MSG( + subscription->impl, "subscription is invalid", + return RCL_RET_SUBSCRIPTION_INVALID, options->allocator); + RCL_CHECK_FOR_NULL_WITH_MSG( + subscription->impl->rmw_handle, + "subscription is invalid", return RCL_RET_SUBSCRIPTION_INVALID, options->allocator); + // If message_info is NULL, use a place holder which can be discarded. + rmw_message_info_t dummy_message_info; + rmw_message_info_t * message_info_local = message_info ? message_info : &dummy_message_info; + // Call rmw_take_with_info. + bool taken = false; + rmw_ret_t ret = + rmw_take_raw_with_info(subscription->impl->rmw_handle, raw_message, &taken, message_info_local); + if (ret != RMW_RET_OK) { + RCL_SET_ERROR_MSG(rmw_get_error_string_safe(), options->allocator); + return RCL_RET_ERROR; + } + if (!taken) { + return RCL_RET_SUBSCRIPTION_TAKE_FAILED; + } + return RCL_RET_OK; +} + const char * rcl_subscription_get_topic_name(const rcl_subscription_t * subscription) { From b27aa300c3b8a0a5c2cc91fd807f8920aaedade0 Mon Sep 17 00:00:00 2001 From: Karsten Knese Date: Tue, 9 Jan 2018 19:19:39 -0800 Subject: [PATCH 3/8] comply to master --- rcl/src/rcl/publisher.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rcl/src/rcl/publisher.c b/rcl/src/rcl/publisher.c index 8c5fe63f2..f7dae8286 100644 --- a/rcl/src/rcl/publisher.c +++ b/rcl/src/rcl/publisher.c @@ -247,7 +247,7 @@ rcl_publish(const rcl_publisher_t * publisher, const void * ros_message) rcl_ret_t rcl_publish_raw(const rcl_publisher_t * publisher, const rcl_message_raw_t * raw_message) { - if (!rcl_publisher_is_valid(publisher)) { + if (!rcl_publisher_is_valid(publisher, NULL)) { return RCL_RET_PUBLISHER_INVALID; } if (rmw_publish_raw(publisher->impl->rmw_handle, raw_message) != RMW_RET_OK) { From 8b02fc93f08497bad0ba516234d155f3bf87c307 Mon Sep 17 00:00:00 2001 From: Karsten Knese Date: Tue, 29 May 2018 10:59:30 -0700 Subject: [PATCH 4/8] add documentation --- rcl/include/rcl/publisher.h | 30 +++++++++++++++++++++++++++++ rcl/include/rcl/subscription.h | 35 ++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) diff --git a/rcl/include/rcl/publisher.h b/rcl/include/rcl/publisher.h index 083a264b3..122ec6c2d 100644 --- a/rcl/include/rcl/publisher.h +++ b/rcl/include/rcl/publisher.h @@ -252,6 +252,36 @@ RCL_WARN_UNUSED rcl_ret_t rcl_publish(const rcl_publisher_t * publisher, const void * ros_message); +/// Publish a serialized message on a topic using a publisher. +/** + * It is the job of the caller to ensure that the type of the serialized raw message + * parameter and the type associate with the publisher (via the type support) + * match. + * Even though this call to publish takes an already serialized raw message, + * the publisher has to register its type as a ROS known message type. + * Passing a raw message from a different type leads to undefined behavior on the subscriber side. + * The publish call might be able to send any abitrary raw message, it is however + * not garantueed that the subscriber side successfully deserializes this byte stream. + * + * Apart from this, the `publish_raw` function has the same behavior as `rcl_publish` + * expect that no serialization step is done. + * + *
+ * Attribute | Adherence + * ------------------ | ------------- + * Allocates Memory | No + * Thread-Safe | Yes [1] + * Uses Atomics | No + * Lock-Free | Yes + * [1] for unique pairs of publishers and messages, see above for more + * + * \param[in] publisher handle to the publisher which will do the publishing + * \param[in] raw_message pointer to the already serialized message in raw form + * \return `RCL_RET_OK` if the message was published successfully, or + * \return `RCL_RET_INVALID_ARGUMENT` if any arguments are invalid, or + * \return `RCL_RET_PUBLISHER_INVALID` if the publisher is invalid, or + * \return `RCL_RET_ERROR` if an unspecified error occurs. + */ RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t diff --git a/rcl/include/rcl/subscription.h b/rcl/include/rcl/subscription.h index e1c56f8fc..1442e58a9 100644 --- a/rcl/include/rcl/subscription.h +++ b/rcl/include/rcl/subscription.h @@ -256,6 +256,41 @@ rcl_take( void * ros_message, rmw_message_info_t * message_info); +/// Take a serialized raw message from a topic using a rcl subscription. +/** + * In contrast to `rcl_take`, this function return the incoming message in + * its binary raw representation. + * It is the job of the caller to ensure that the type associate with the subscription, + * match and can optionally be deserialized into its ROS message via the correct + * type support. + * If the `raw_message` parameter contains enough preallocated memory, the incoming + * message can be taken without any additional memory allocation. + * If not, the function will dynamically allocate enough memory for the message. + * Passing a different type to rcl_take produces undefined behavior and cannot + * be checked by this function and therefore no deliberate error will occur. + * + * Apart from the contrast above, this function behaves like `rcl_take`. + * + *
+ * Attribute | Adherence + * ------------------ | ------------- + * Allocates Memory | Maybe [1] + * Thread-Safe | No + * Uses Atomics | No + * Lock-Free | Yes + * [1] only if required when filling the message, avoided for fixed sizes + * + * \param[in] subscription the handle to the subscription from which to take + * \param[inout] raw_message pointer to a (pre-allocated) raw message. + * \param[out] message_info rmw struct which contains meta-data for the message + * \return `RCL_RET_OK` if the message was published, or + * \return `RCL_RET_INVALID_ARGUMENT` if any arguments are invalid, or + * \return `RCL_RET_SUBSCRIPTION_INVALID` if the subscription is invalid, or + * \return `RCL_RET_BAD_ALLOC` if allocating memory failed, or + * \return `RCL_RET_SUBSCRIPTION_TAKE_FAILED` if take failed but no error + * occurred in the middleware, or + * \return `RCL_RET_ERROR` if an unspecified error occurs. + */ RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t From 19bf36cb36f4ad98fc4895ad2db53e73786f13ef Mon Sep 17 00:00:00 2001 From: Karsten Knese Date: Tue, 29 May 2018 11:00:00 -0700 Subject: [PATCH 5/8] use rcl_subscription_is_valid --- rcl/src/rcl/subscription.c | 39 +++++++++++++++----------------------- 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/rcl/src/rcl/subscription.c b/rcl/src/rcl/subscription.c index f04aa72ae..a750599bf 100644 --- a/rcl/src/rcl/subscription.c +++ b/rcl/src/rcl/subscription.c @@ -241,18 +241,12 @@ rcl_take( rmw_message_info_t * message_info) { RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME, "Subscription taking message") - RCL_CHECK_ARGUMENT_FOR_NULL(subscription, RCL_RET_INVALID_ARGUMENT, rcl_get_default_allocator()); - const rcl_subscription_options_t * options = rcl_subscription_get_options(subscription); - if (!options) { - return RCL_RET_SUBSCRIPTION_INVALID; + rcl_allocator_t error_allocator = rcl_get_default_allocator(); + if (!rcl_subscription_is_valid(subscription, &error_allocator)) { + return RCL_RET_SUBSCRIPTION_INVALID; // error message already set } - RCL_CHECK_ARGUMENT_FOR_NULL(ros_message, RCL_RET_INVALID_ARGUMENT, options->allocator); - RCL_CHECK_FOR_NULL_WITH_MSG( - subscription->impl, "subscription is invalid", - return RCL_RET_SUBSCRIPTION_INVALID, options->allocator); - RCL_CHECK_FOR_NULL_WITH_MSG( - subscription->impl->rmw_handle, - "subscription is invalid", return RCL_RET_SUBSCRIPTION_INVALID, options->allocator); + RCL_CHECK_ARGUMENT_FOR_NULL( + ros_message, RCL_RET_INVALID_ARGUMENT, error_allocator); // If message_info is NULL, use a place holder which can be discarded. rmw_message_info_t dummy_message_info; rmw_message_info_t * message_info_local = message_info ? message_info : &dummy_message_info; @@ -261,7 +255,7 @@ rcl_take( rmw_ret_t ret = rmw_take_with_info(subscription->impl->rmw_handle, ros_message, &taken, message_info_local); if (ret != RMW_RET_OK) { - RCL_SET_ERROR_MSG(rmw_get_error_string_safe(), options->allocator); + RCL_SET_ERROR_MSG(rmw_get_error_string_safe(), error_allocator); return RCL_RET_ERROR; } RCUTILS_LOG_DEBUG_NAMED( @@ -278,18 +272,13 @@ rcl_take_raw( rcl_message_raw_t * raw_message, rmw_message_info_t * message_info) { - RCL_CHECK_ARGUMENT_FOR_NULL(subscription, RCL_RET_INVALID_ARGUMENT, rcl_get_default_allocator()); - const rcl_subscription_options_t * options = rcl_subscription_get_options(subscription); - if (!options) { - return RCL_RET_SUBSCRIPTION_INVALID; + RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME, "Subscription taking raw message") + rcl_allocator_t error_allocator = rcl_get_default_allocator(); + if (!rcl_subscription_is_valid(subscription, &error_allocator)) { + return RCL_RET_SUBSCRIPTION_INVALID; // error message already set } - RCL_CHECK_ARGUMENT_FOR_NULL(raw_message, RCL_RET_INVALID_ARGUMENT, options->allocator); - RCL_CHECK_FOR_NULL_WITH_MSG( - subscription->impl, "subscription is invalid", - return RCL_RET_SUBSCRIPTION_INVALID, options->allocator); - RCL_CHECK_FOR_NULL_WITH_MSG( - subscription->impl->rmw_handle, - "subscription is invalid", return RCL_RET_SUBSCRIPTION_INVALID, options->allocator); + RCL_CHECK_ARGUMENT_FOR_NULL( + raw_message, RCL_RET_INVALID_ARGUMENT, error_allocator); // If message_info is NULL, use a place holder which can be discarded. rmw_message_info_t dummy_message_info; rmw_message_info_t * message_info_local = message_info ? message_info : &dummy_message_info; @@ -298,9 +287,11 @@ rcl_take_raw( rmw_ret_t ret = rmw_take_raw_with_info(subscription->impl->rmw_handle, raw_message, &taken, message_info_local); if (ret != RMW_RET_OK) { - RCL_SET_ERROR_MSG(rmw_get_error_string_safe(), options->allocator); + RCL_SET_ERROR_MSG(rmw_get_error_string_safe(), error_allocator); return RCL_RET_ERROR; } + RCUTILS_LOG_DEBUG_NAMED( + ROS_PACKAGE_NAME, "Subscription raw take succeeded: %s", taken ? "true" : "false") if (!taken) { return RCL_RET_SUBSCRIPTION_TAKE_FAILED; } From 619a3deb52310fe1249904fc813991788cc4eaba Mon Sep 17 00:00:00 2001 From: William Woodall Date: Tue, 12 Jun 2018 16:29:47 -0700 Subject: [PATCH 6/8] documentation fixups --- rcl/include/rcl/subscription.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/rcl/include/rcl/subscription.h b/rcl/include/rcl/subscription.h index 1442e58a9..4cc62bccf 100644 --- a/rcl/include/rcl/subscription.h +++ b/rcl/include/rcl/subscription.h @@ -256,12 +256,12 @@ rcl_take( void * ros_message, rmw_message_info_t * message_info); -/// Take a serialized raw message from a topic using a rcl subscription. +/// Take a serialized raw message from a topic using a rcl subscription. /** - * In contrast to `rcl_take`, this function return the incoming message in - * its binary raw representation. - * It is the job of the caller to ensure that the type associate with the subscription, - * match and can optionally be deserialized into its ROS message via the correct + * In contrast to `rcl_take`, this function stores the taken message in + * its raw binary representation. + * It is the job of the caller to ensure that the type associate with the subscription + * matches, and can optionally be deserialized into its ROS message via, the correct * type support. * If the `raw_message` parameter contains enough preallocated memory, the incoming * message can be taken without any additional memory allocation. @@ -269,7 +269,7 @@ rcl_take( * Passing a different type to rcl_take produces undefined behavior and cannot * be checked by this function and therefore no deliberate error will occur. * - * Apart from the contrast above, this function behaves like `rcl_take`. + * Apart from the differences above, this function behaves like `rcl_take`. * *
* Attribute | Adherence @@ -278,7 +278,7 @@ rcl_take( * Thread-Safe | No * Uses Atomics | No * Lock-Free | Yes - * [1] only if required when filling the message, avoided for fixed sizes + * [1] only if storage in the raw_message is insufficient * * \param[in] subscription the handle to the subscription from which to take * \param[inout] raw_message pointer to a (pre-allocated) raw message. From 23e548f41231ea7535897c21e7c9b4a07aa6933b Mon Sep 17 00:00:00 2001 From: Karsten Knese Date: Wed, 13 Jun 2018 10:44:17 +0200 Subject: [PATCH 7/8] address review comments --- rcl/src/rcl/publisher.c | 8 ++++++-- rcl/src/rcl/subscription.c | 3 +++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/rcl/src/rcl/publisher.c b/rcl/src/rcl/publisher.c index f7dae8286..daac5e059 100644 --- a/rcl/src/rcl/publisher.c +++ b/rcl/src/rcl/publisher.c @@ -250,9 +250,13 @@ rcl_publish_raw(const rcl_publisher_t * publisher, const rcl_message_raw_t * raw if (!rcl_publisher_is_valid(publisher, NULL)) { return RCL_RET_PUBLISHER_INVALID; } - if (rmw_publish_raw(publisher->impl->rmw_handle, raw_message) != RMW_RET_OK) { + rmw_ret_t ret = rmw_publish_raw(publisher->impl->rmw_handle, raw_message); + if (ret != RMW_RET_OK) { RCL_SET_ERROR_MSG(rmw_get_error_string_safe(), rcl_get_default_allocator()); - return RCL_RET_ERROR; + if (ret == RMW_RET_BAD_ALLOC) { + return RCL_RET_BAD_ALLOC; + } + return RMW_RET_ERROR; } return RCL_RET_OK; } diff --git a/rcl/src/rcl/subscription.c b/rcl/src/rcl/subscription.c index a750599bf..b90d0c120 100644 --- a/rcl/src/rcl/subscription.c +++ b/rcl/src/rcl/subscription.c @@ -288,6 +288,9 @@ rcl_take_raw( rmw_take_raw_with_info(subscription->impl->rmw_handle, raw_message, &taken, message_info_local); if (ret != RMW_RET_OK) { RCL_SET_ERROR_MSG(rmw_get_error_string_safe(), error_allocator); + if (ret == RMW_RET_BAD_ALLOC) { + return RCL_RET_BAD_ALLOC; + } return RCL_RET_ERROR; } RCUTILS_LOG_DEBUG_NAMED( From bd1f92aa1b46e3cfd408f933ef5d66deae573a40 Mon Sep 17 00:00:00 2001 From: Karsten Knese Date: Thu, 14 Jun 2018 02:06:48 +0200 Subject: [PATCH 8/8] raw->serialized --- rcl/include/rcl/publisher.h | 15 ++++++++------- rcl/include/rcl/subscription.h | 10 +++++----- rcl/include/rcl/types.h | 4 ++-- rcl/src/rcl/publisher.c | 5 +++-- rcl/src/rcl/subscription.c | 14 +++++++------- 5 files changed, 25 insertions(+), 23 deletions(-) diff --git a/rcl/include/rcl/publisher.h b/rcl/include/rcl/publisher.h index 122ec6c2d..3aadd1e36 100644 --- a/rcl/include/rcl/publisher.h +++ b/rcl/include/rcl/publisher.h @@ -254,16 +254,16 @@ rcl_publish(const rcl_publisher_t * publisher, const void * ros_message); /// Publish a serialized message on a topic using a publisher. /** - * It is the job of the caller to ensure that the type of the serialized raw message + * It is the job of the caller to ensure that the type of the serialized message * parameter and the type associate with the publisher (via the type support) * match. - * Even though this call to publish takes an already serialized raw message, + * Even though this call to publish takes an already serialized serialized message, * the publisher has to register its type as a ROS known message type. - * Passing a raw message from a different type leads to undefined behavior on the subscriber side. - * The publish call might be able to send any abitrary raw message, it is however + * Passing a serialized message from a different type leads to undefined behavior on the subscriber side. + * The publish call might be able to send any abitrary serialized message, it is however * not garantueed that the subscriber side successfully deserializes this byte stream. * - * Apart from this, the `publish_raw` function has the same behavior as `rcl_publish` + * Apart from this, the `publish_serialized` function has the same behavior as `rcl_publish` * expect that no serialization step is done. * *
@@ -276,7 +276,7 @@ rcl_publish(const rcl_publisher_t * publisher, const void * ros_message); * [1] for unique pairs of publishers and messages, see above for more * * \param[in] publisher handle to the publisher which will do the publishing - * \param[in] raw_message pointer to the already serialized message in raw form + * \param[in] serialized_message pointer to the already serialized message in raw form * \return `RCL_RET_OK` if the message was published successfully, or * \return `RCL_RET_INVALID_ARGUMENT` if any arguments are invalid, or * \return `RCL_RET_PUBLISHER_INVALID` if the publisher is invalid, or @@ -285,7 +285,8 @@ rcl_publish(const rcl_publisher_t * publisher, const void * ros_message); RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t -rcl_publish_raw(const rcl_publisher_t * publisher, const rcl_message_raw_t * raw_message); +rcl_publish_serialized_message( + const rcl_publisher_t * publisher, const rcl_serialized_message_t * serialized_message); /// Get the topic name for the publisher. /** diff --git a/rcl/include/rcl/subscription.h b/rcl/include/rcl/subscription.h index 4cc62bccf..252949ba5 100644 --- a/rcl/include/rcl/subscription.h +++ b/rcl/include/rcl/subscription.h @@ -263,7 +263,7 @@ rcl_take( * It is the job of the caller to ensure that the type associate with the subscription * matches, and can optionally be deserialized into its ROS message via, the correct * type support. - * If the `raw_message` parameter contains enough preallocated memory, the incoming + * If the `serialized_message` parameter contains enough preallocated memory, the incoming * message can be taken without any additional memory allocation. * If not, the function will dynamically allocate enough memory for the message. * Passing a different type to rcl_take produces undefined behavior and cannot @@ -278,10 +278,10 @@ rcl_take( * Thread-Safe | No * Uses Atomics | No * Lock-Free | Yes - * [1] only if storage in the raw_message is insufficient + * [1] only if storage in the serialized_message is insufficient * * \param[in] subscription the handle to the subscription from which to take - * \param[inout] raw_message pointer to a (pre-allocated) raw message. + * \param[inout] serialized_message pointer to a (pre-allocated) serialized message. * \param[out] message_info rmw struct which contains meta-data for the message * \return `RCL_RET_OK` if the message was published, or * \return `RCL_RET_INVALID_ARGUMENT` if any arguments are invalid, or @@ -294,9 +294,9 @@ rcl_take( RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t -rcl_take_raw( +rcl_take_serialized_message( const rcl_subscription_t * subscription, - rcl_message_raw_t * raw_message, + rcl_serialized_message_t * serialized_message, rmw_message_info_t * message_info); /// Get the topic name for the subscription. diff --git a/rcl/include/rcl/types.h b/rcl/include/rcl/types.h index c58f87f1a..4825bf2f3 100644 --- a/rcl/include/rcl/types.h +++ b/rcl/include/rcl/types.h @@ -97,7 +97,7 @@ typedef rmw_ret_t rcl_ret_t; /// Argument is not a valid log level rule #define RCL_RET_INVALID_LOG_LEVEL_RULE 1020 -/// typedef for rmw_message_raw_t; -typedef rmw_message_raw_t rcl_message_raw_t; +/// typedef for rmw_serialized_message_t; +typedef rmw_serialized_message_t rcl_serialized_message_t; #endif // RCL__TYPES_H_ diff --git a/rcl/src/rcl/publisher.c b/rcl/src/rcl/publisher.c index daac5e059..ef0e5cdf2 100644 --- a/rcl/src/rcl/publisher.c +++ b/rcl/src/rcl/publisher.c @@ -245,12 +245,13 @@ rcl_publish(const rcl_publisher_t * publisher, const void * ros_message) } rcl_ret_t -rcl_publish_raw(const rcl_publisher_t * publisher, const rcl_message_raw_t * raw_message) +rcl_publish_serialized_message( + const rcl_publisher_t * publisher, const rcl_serialized_message_t * serialized_message) { if (!rcl_publisher_is_valid(publisher, NULL)) { return RCL_RET_PUBLISHER_INVALID; } - rmw_ret_t ret = rmw_publish_raw(publisher->impl->rmw_handle, raw_message); + rmw_ret_t ret = rmw_publish_serialized_message(publisher->impl->rmw_handle, serialized_message); if (ret != RMW_RET_OK) { RCL_SET_ERROR_MSG(rmw_get_error_string_safe(), rcl_get_default_allocator()); if (ret == RMW_RET_BAD_ALLOC) { diff --git a/rcl/src/rcl/subscription.c b/rcl/src/rcl/subscription.c index b90d0c120..319419fd5 100644 --- a/rcl/src/rcl/subscription.c +++ b/rcl/src/rcl/subscription.c @@ -267,25 +267,25 @@ rcl_take( } rcl_ret_t -rcl_take_raw( +rcl_take_serialized_message( const rcl_subscription_t * subscription, - rcl_message_raw_t * raw_message, + rcl_serialized_message_t * serialized_message, rmw_message_info_t * message_info) { - RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME, "Subscription taking raw message") + RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME, "Subscription taking serialized message") rcl_allocator_t error_allocator = rcl_get_default_allocator(); if (!rcl_subscription_is_valid(subscription, &error_allocator)) { return RCL_RET_SUBSCRIPTION_INVALID; // error message already set } RCL_CHECK_ARGUMENT_FOR_NULL( - raw_message, RCL_RET_INVALID_ARGUMENT, error_allocator); + serialized_message, RCL_RET_INVALID_ARGUMENT, error_allocator); // If message_info is NULL, use a place holder which can be discarded. rmw_message_info_t dummy_message_info; rmw_message_info_t * message_info_local = message_info ? message_info : &dummy_message_info; // Call rmw_take_with_info. bool taken = false; - rmw_ret_t ret = - rmw_take_raw_with_info(subscription->impl->rmw_handle, raw_message, &taken, message_info_local); + rmw_ret_t ret = rmw_take_serialized_message_with_info( + subscription->impl->rmw_handle, serialized_message, &taken, message_info_local); if (ret != RMW_RET_OK) { RCL_SET_ERROR_MSG(rmw_get_error_string_safe(), error_allocator); if (ret == RMW_RET_BAD_ALLOC) { @@ -294,7 +294,7 @@ rcl_take_raw( return RCL_RET_ERROR; } RCUTILS_LOG_DEBUG_NAMED( - ROS_PACKAGE_NAME, "Subscription raw take succeeded: %s", taken ? "true" : "false") + ROS_PACKAGE_NAME, "Subscription serialized take succeeded: %s", taken ? "true" : "false") if (!taken) { return RCL_RET_SUBSCRIPTION_TAKE_FAILED; }