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 flag to enable/disable rosout logging in each node individually. #532

Merged
merged 6 commits into from
Nov 29, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 3 additions & 0 deletions rcl/include/rcl/node_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ typedef struct rcl_node_options_t

/// Command line arguments that apply only to this node.
rcl_arguments_t arguments;

/// Flag to disable rosout for this node
bool disable_rosout;
} rcl_node_options_t;

/// Return the default node options in a rcl_node_options_t.
Expand Down
9 changes: 6 additions & 3 deletions rcl/src/rcl/node.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ rcl_node_init(
}
// The initialization for the rosout publisher requires the node to be in initialized to a point
// that it can create new topic publishers
if (rcl_logging_rosout_enabled()) {
if (rcl_logging_rosout_enabled() && !node->impl->options.disable_rosout) {
ret = rcl_logging_rosout_init_publisher_for_node(node);
if (ret != RCL_RET_OK) {
// error message already set
Expand All @@ -376,7 +376,10 @@ rcl_node_init(
goto cleanup;
fail:
if (node->impl) {
if (rcl_logging_rosout_enabled() && node->impl->logger_name) {
if (rcl_logging_rosout_enabled() &&
!node->impl->options.disable_rosout &&
node->impl->logger_name)
{
ret = rcl_logging_rosout_fini_publisher_for_node(node);
RCUTILS_LOG_ERROR_EXPRESSION_NAMED((ret != RCL_RET_OK && ret != RCL_RET_NOT_INIT),
ROS_PACKAGE_NAME, "Failed to fini publisher for node: %i", ret);
Expand Down Expand Up @@ -443,7 +446,7 @@ rcl_node_fini(rcl_node_t * node)
rcl_allocator_t allocator = node->impl->options.allocator;
rcl_ret_t result = RCL_RET_OK;
rcl_ret_t rcl_ret = RCL_RET_OK;
if (rcl_logging_rosout_enabled()) {
if (rcl_logging_rosout_enabled() && !node->impl->options.disable_rosout) {
rcl_ret = rcl_logging_rosout_fini_publisher_for_node(node);
if (rcl_ret != RCL_RET_OK && rcl_ret != RCL_RET_NOT_INIT) {
RCL_SET_ERROR_MSG("Unable to fini publisher for node.");
Expand Down
2 changes: 2 additions & 0 deletions rcl/src/rcl/node_options.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ rcl_node_get_default_options()
static rcl_node_options_t default_options = {
.domain_id = RCL_NODE_OPTIONS_DEFAULT_DOMAIN_ID,
.use_global_arguments = true,
.disable_rosout = false,
};
// Must set the allocator after because it is not a compile time constant.
default_options.allocator = rcl_get_default_allocator();
Expand All @@ -51,6 +52,7 @@ rcl_node_options_copy(
options_out->domain_id = options->domain_id;
options_out->allocator = options->allocator;
options_out->use_global_arguments = options->use_global_arguments;
options_out->disable_rosout = options->disable_rosout;
if (NULL != options->arguments.impl) {
rcl_ret_t ret = rcl_arguments_copy(&(options->arguments), &(options_out->arguments));
return ret;
Expand Down