add mechanism to pass rmw impl specific payloads during pub/sub creation (#513)
* add optional rmw payload to rcl options for pub and sub Signed-off-by: William Woodall <william@osrfoundation.org> * move ignore_local_publications into rmw options structure for subs Signed-off-by: William Woodall <william@osrfoundation.org>
This commit is contained in:
parent
0198ffef71
commit
e673988415
5 changed files with 15 additions and 13 deletions
|
@ -43,6 +43,8 @@ typedef struct rcl_publisher_options_t
|
|||
/// Custom allocator for the publisher, used for incidental allocations.
|
||||
/** For default behavior (malloc/free), use: rcl_get_default_allocator() */
|
||||
rcl_allocator_t allocator;
|
||||
/// rmw specific publisher options, e.g. the rmw implementation specific payload.
|
||||
rmw_publisher_options_t rmw_publisher_options;
|
||||
} rcl_publisher_options_t;
|
||||
|
||||
/// Return a rcl_publisher_t struct with members set to `NULL`.
|
||||
|
|
|
@ -40,11 +40,11 @@ typedef struct rcl_subscription_options_t
|
|||
{
|
||||
/// Middleware quality of service settings for the subscription.
|
||||
rmw_qos_profile_t qos;
|
||||
/// If true, messages published from within the same node are ignored.
|
||||
bool ignore_local_publications;
|
||||
/// Custom allocator for the subscription, used for incidental allocations.
|
||||
/** For default behavior (malloc/free), see: rcl_get_default_allocator() */
|
||||
rcl_allocator_t allocator;
|
||||
/// rmw specific subscription options, e.g. the rmw implementation specific payload.
|
||||
rmw_subscription_options_t rmw_subscription_options;
|
||||
} rcl_subscription_options_t;
|
||||
|
||||
/// Return a rcl_subscription_t struct with members set to `NULL`.
|
||||
|
|
|
@ -166,7 +166,8 @@ rcl_publisher_init(
|
|||
rcl_node_get_rmw_handle(node),
|
||||
type_support,
|
||||
remapped_topic_name,
|
||||
&(options->qos));
|
||||
&(options->qos),
|
||||
&(options->rmw_publisher_options));
|
||||
RCL_CHECK_FOR_NULL_WITH_MSG(publisher->impl->rmw_handle,
|
||||
rmw_get_error_string().str, goto fail);
|
||||
// get actual qos, and store it
|
||||
|
@ -240,6 +241,7 @@ rcl_publisher_get_default_options()
|
|||
// Must set the allocator and qos after because they are not a compile time constant.
|
||||
default_options.qos = rmw_qos_profile_default;
|
||||
default_options.allocator = rcl_get_default_allocator();
|
||||
default_options.rmw_publisher_options = rmw_get_default_publisher_options();
|
||||
return default_options;
|
||||
}
|
||||
|
||||
|
|
|
@ -162,7 +162,7 @@ rcl_subscription_init(
|
|||
type_support,
|
||||
remapped_topic_name,
|
||||
&(options->qos),
|
||||
options->ignore_local_publications);
|
||||
&(options->rmw_subscription_options));
|
||||
if (!subscription->impl->rmw_handle) {
|
||||
RCL_SET_ERROR_MSG(rmw_get_error_string().str);
|
||||
goto fail;
|
||||
|
@ -230,12 +230,11 @@ rcl_subscription_options_t
|
|||
rcl_subscription_get_default_options()
|
||||
{
|
||||
// !!! MAKE SURE THAT CHANGES TO THESE DEFAULTS ARE REFLECTED IN THE HEADER DOC STRING
|
||||
static rcl_subscription_options_t default_options = {
|
||||
.ignore_local_publications = false,
|
||||
};
|
||||
// Must set the allocator and qos after because they are not a compile time constant.
|
||||
static rcl_subscription_options_t default_options;
|
||||
// Must set these after declaration because they are not a compile time constants.
|
||||
default_options.qos = rmw_qos_profile_default;
|
||||
default_options.allocator = rcl_get_default_allocator();
|
||||
default_options.rmw_subscription_options = rmw_get_default_subscription_options();
|
||||
return default_options;
|
||||
}
|
||||
|
||||
|
|
|
@ -110,11 +110,10 @@ rcl_action_get_zero_initialized_client(void)
|
|||
} \
|
||||
goto fail; \
|
||||
} \
|
||||
rcl_subscription_options_t Type ## _topic_subscription_options = { \
|
||||
.qos = options->Type ## _topic_qos, \
|
||||
.ignore_local_publications = false, \
|
||||
.allocator = allocator \
|
||||
}; \
|
||||
rcl_subscription_options_t Type ## _topic_subscription_options = \
|
||||
rcl_subscription_get_default_options(); \
|
||||
Type ## _topic_subscription_options.qos = options->Type ## _topic_qos; \
|
||||
Type ## _topic_subscription_options.allocator = allocator; \
|
||||
action_client->impl->Type ## _subscription = rcl_get_zero_initialized_subscription(); \
|
||||
ret = rcl_subscription_init( \
|
||||
&action_client->impl->Type ## _subscription, \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue