diff --git a/rcl/include/rcl/logging_rosout.h b/rcl/include/rcl/logging_rosout.h index 255511680b..5a1f2b40b5 100644 --- a/rcl/include/rcl/logging_rosout.h +++ b/rcl/include/rcl/logging_rosout.h @@ -26,6 +26,19 @@ extern "C" { #endif +static const rmw_qos_profile_t rcl_qos_profile_rosout_default = +{ + RMW_QOS_POLICY_HISTORY_KEEP_LAST, + 1000, + RMW_QOS_POLICY_RELIABILITY_RELIABLE, + RMW_QOS_POLICY_DURABILITY_TRANSIENT_LOCAL, + RMW_QOS_DEADLINE_DEFAULT, + {10, 0}, + RMW_QOS_POLICY_LIVELINESS_SYSTEM_DEFAULT, + RMW_QOS_LIVELINESS_LEASE_DURATION_DEFAULT, + false +}; + /// Initializes the rcl_logging_rosout features /** * Calling this will initialize the rcl_logging_rosout features. This function must be called diff --git a/rcl/include/rcl/node_options.h b/rcl/include/rcl/node_options.h index 9960fb2da7..cc2e60e8df 100644 --- a/rcl/include/rcl/node_options.h +++ b/rcl/include/rcl/node_options.h @@ -49,6 +49,9 @@ typedef struct rcl_node_options_t /// Flag to enable rosout for this node bool enable_rosout; + + /// Middleware quality of service settings for /rosout. + rmw_qos_profile_t rosout_qos; } rcl_node_options_t; /// Return the default node options in a rcl_node_options_t. diff --git a/rcl/src/rcl/logging_rosout.c b/rcl/src/rcl/logging_rosout.c index 3585cff4ba..c0924d4d48 100644 --- a/rcl/src/rcl/logging_rosout.c +++ b/rcl/src/rcl/logging_rosout.c @@ -173,11 +173,12 @@ rcl_ret_t rcl_logging_rosout_init_publisher_for_node( const rosidl_message_type_support_t * type_support = rosidl_typesupport_c__get_message_type_support_handle__rcl_interfaces__msg__Log(); rcl_publisher_options_t options = rcl_publisher_get_default_options(); - // Late joining subscriptions get the last 10 seconds of logs, up to 1000 logs. - options.qos.depth = 1000; - options.qos.durability = RMW_QOS_POLICY_DURABILITY_TRANSIENT_LOCAL; - options.qos.lifespan.sec = 10; - options.qos.lifespan.nsec = 0; + + // Late joining subscriptions get the user's setting of rosout qos options. + const rcl_node_options_t *node_options = rcl_node_get_options(node); + RCL_CHECK_FOR_NULL_WITH_MSG(node_options, "Node options was null.", return RCL_RET_ERROR); + + options.qos = node_options->rosout_qos; new_entry.publisher = rcl_get_zero_initialized_publisher(); status = rcl_publisher_init(&new_entry.publisher, node, type_support, ROSOUT_TOPIC_NAME, &options); diff --git a/rcl/src/rcl/node_options.c b/rcl/src/rcl/node_options.c index 9cd3f12e81..636f9acddc 100644 --- a/rcl/src/rcl/node_options.c +++ b/rcl/src/rcl/node_options.c @@ -28,9 +28,10 @@ rcl_node_options_t rcl_node_get_default_options() { // !!! MAKE SURE THAT CHANGES TO THESE DEFAULTS ARE REFLECTED IN THE HEADER DOC STRING - static rcl_node_options_t default_options = { + rcl_node_options_t default_options = { .use_global_arguments = true, .enable_rosout = true, + .rosout_qos = rcl_qos_profile_rosout_default, }; // Must set the allocator after because it is not a compile time constant. default_options.allocator = rcl_get_default_allocator(); @@ -56,6 +57,7 @@ rcl_node_options_copy( options_out->allocator = options->allocator; options_out->use_global_arguments = options->use_global_arguments; options_out->enable_rosout = options->enable_rosout; + options_out->rosout_qos = options->rosout_qos; if (NULL != options->arguments.impl) { rcl_ret_t ret = rcl_arguments_copy(&(options->arguments), &(options_out->arguments)); return ret;