Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add mechanism to pass rmw impl specific payloads during pub/sub creation #513

Merged
merged 2 commits into from
Oct 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions rcl/include/rcl/publisher.h
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
4 changes: 2 additions & 2 deletions rcl/include/rcl/subscription.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
wjwwood marked this conversation as resolved.
Show resolved Hide resolved
/// 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`.
Expand Down
4 changes: 3 additions & 1 deletion rcl/src/rcl/publisher.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}

Expand Down
9 changes: 4 additions & 5 deletions rcl/src/rcl/subscription.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down
9 changes: 4 additions & 5 deletions rcl_action/src/rcl_action/action_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -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, \
Expand Down