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:
William Woodall 2019-10-08 15:40:33 -07:00 committed by GitHub
parent 0198ffef71
commit e673988415
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 13 deletions

View file

@ -43,6 +43,8 @@ typedef struct rcl_publisher_options_t
/// Custom allocator for the publisher, used for incidental allocations. /// Custom allocator for the publisher, used for incidental allocations.
/** For default behavior (malloc/free), use: rcl_get_default_allocator() */ /** For default behavior (malloc/free), use: rcl_get_default_allocator() */
rcl_allocator_t 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; } rcl_publisher_options_t;
/// Return a rcl_publisher_t struct with members set to `NULL`. /// Return a rcl_publisher_t struct with members set to `NULL`.

View file

@ -40,11 +40,11 @@ typedef struct rcl_subscription_options_t
{ {
/// Middleware quality of service settings for the subscription. /// Middleware quality of service settings for the subscription.
rmw_qos_profile_t qos; 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. /// Custom allocator for the subscription, used for incidental allocations.
/** For default behavior (malloc/free), see: rcl_get_default_allocator() */ /** For default behavior (malloc/free), see: rcl_get_default_allocator() */
rcl_allocator_t 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; } rcl_subscription_options_t;
/// Return a rcl_subscription_t struct with members set to `NULL`. /// Return a rcl_subscription_t struct with members set to `NULL`.

View file

@ -166,7 +166,8 @@ rcl_publisher_init(
rcl_node_get_rmw_handle(node), rcl_node_get_rmw_handle(node),
type_support, type_support,
remapped_topic_name, remapped_topic_name,
&(options->qos)); &(options->qos),
&(options->rmw_publisher_options));
RCL_CHECK_FOR_NULL_WITH_MSG(publisher->impl->rmw_handle, RCL_CHECK_FOR_NULL_WITH_MSG(publisher->impl->rmw_handle,
rmw_get_error_string().str, goto fail); rmw_get_error_string().str, goto fail);
// get actual qos, and store it // 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. // Must set the allocator and qos after because they are not a compile time constant.
default_options.qos = rmw_qos_profile_default; default_options.qos = rmw_qos_profile_default;
default_options.allocator = rcl_get_default_allocator(); default_options.allocator = rcl_get_default_allocator();
default_options.rmw_publisher_options = rmw_get_default_publisher_options();
return default_options; return default_options;
} }

View file

@ -162,7 +162,7 @@ rcl_subscription_init(
type_support, type_support,
remapped_topic_name, remapped_topic_name,
&(options->qos), &(options->qos),
options->ignore_local_publications); &(options->rmw_subscription_options));
if (!subscription->impl->rmw_handle) { if (!subscription->impl->rmw_handle) {
RCL_SET_ERROR_MSG(rmw_get_error_string().str); RCL_SET_ERROR_MSG(rmw_get_error_string().str);
goto fail; goto fail;
@ -230,12 +230,11 @@ rcl_subscription_options_t
rcl_subscription_get_default_options() rcl_subscription_get_default_options()
{ {
// !!! MAKE SURE THAT CHANGES TO THESE DEFAULTS ARE REFLECTED IN THE HEADER DOC STRING // !!! MAKE SURE THAT CHANGES TO THESE DEFAULTS ARE REFLECTED IN THE HEADER DOC STRING
static rcl_subscription_options_t default_options = { static rcl_subscription_options_t default_options;
.ignore_local_publications = false, // Must set these after declaration because they are not a compile time constants.
};
// Must set the allocator and qos after because they are not a compile time constant.
default_options.qos = rmw_qos_profile_default; default_options.qos = rmw_qos_profile_default;
default_options.allocator = rcl_get_default_allocator(); default_options.allocator = rcl_get_default_allocator();
default_options.rmw_subscription_options = rmw_get_default_subscription_options();
return default_options; return default_options;
} }

View file

@ -110,11 +110,10 @@ rcl_action_get_zero_initialized_client(void)
} \ } \
goto fail; \ goto fail; \
} \ } \
rcl_subscription_options_t Type ## _topic_subscription_options = { \ rcl_subscription_options_t Type ## _topic_subscription_options = \
.qos = options->Type ## _topic_qos, \ rcl_subscription_get_default_options(); \
.ignore_local_publications = false, \ Type ## _topic_subscription_options.qos = options->Type ## _topic_qos; \
.allocator = allocator \ Type ## _topic_subscription_options.allocator = allocator; \
}; \
action_client->impl->Type ## _subscription = rcl_get_zero_initialized_subscription(); \ action_client->impl->Type ## _subscription = rcl_get_zero_initialized_subscription(); \
ret = rcl_subscription_init( \ ret = rcl_subscription_init( \
&action_client->impl->Type ## _subscription, \ &action_client->impl->Type ## _subscription, \