From 4f80efa3311e2a79e4efd5ea57d941f1323406a2 Mon Sep 17 00:00:00 2001 From: Pablo Garrido Date: Thu, 30 Apr 2020 08:41:35 +0200 Subject: [PATCH 1/5] Avoid logging on build time based on RCutils flags (#6) --- rcl/src/rcl/logging.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/rcl/src/rcl/logging.c b/rcl/src/rcl/logging.c index cce406560..5447889bb 100644 --- a/rcl/src/rcl/logging.c +++ b/rcl/src/rcl/logging.c @@ -72,9 +72,13 @@ rcl_logging_configure(const rcl_arguments_t * global_args, const rcl_allocator_t g_logging_allocator = *allocator; int default_level = global_args->impl->log_level; const char * config_file = global_args->impl->external_log_config_file; - g_rcl_logging_stdout_enabled = !global_args->impl->log_stdout_disabled; - g_rcl_logging_rosout_enabled = !global_args->impl->log_rosout_disabled; - g_rcl_logging_ext_lib_enabled = !global_args->impl->log_ext_lib_disabled; + bool global_disable = false; + #ifdef RCUTILS_NO_LOGGING + global_disable = true; + #endif + g_rcl_logging_stdout_enabled = !global_args->impl->log_stdout_disabled && !global_disable; + g_rcl_logging_rosout_enabled = !global_args->impl->log_rosout_disabled && !global_disable; + g_rcl_logging_ext_lib_enabled = !global_args->impl->log_ext_lib_disabled && !global_disable; rcl_ret_t status = RCL_RET_OK; g_rcl_logging_num_out_handlers = 0; From 079cb60a98c1a4edd52a1654494defea25c85a4c Mon Sep 17 00:00:00 2001 From: julibert Date: Thu, 4 Jun 2020 12:46:49 +0000 Subject: [PATCH 2/5] Add RCL_YAML_PARSER and RCL_LOGGING CMake options. --- rcl/CMakeLists.txt | 39 ++++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/rcl/CMakeLists.txt b/rcl/CMakeLists.txt index cbc267792..8fe9f644e 100644 --- a/rcl/CMakeLists.txt +++ b/rcl/CMakeLists.txt @@ -2,19 +2,28 @@ cmake_minimum_required(VERSION 3.5) project(rcl) +option(RCL_YAML_PARSER "Enable/disable the rcl_yaml_param_parser tool" OFF) +option(RCL_LOGGIN "Enable/disable logging" OFF) + find_package(ament_cmake_ros REQUIRED) find_package(rcl_interfaces REQUIRED) -find_package(rcl_yaml_param_parser REQUIRED) find_package(rcutils REQUIRED) find_package(rmw REQUIRED) find_package(rmw_implementation REQUIRED) find_package(rosidl_runtime_c REQUIRED) find_package(tracetools REQUIRED) +if(RCL_YAML_PARSER) + find_package(rcl_yaml_param_parser REQUIRED) +endif() + include(cmake/rcl_set_symbol_visibility_hidden.cmake) -include(cmake/get_default_rcl_logging_implementation.cmake) -get_default_rcl_logging_implementation(RCL_LOGGING_IMPL) + +if(RCL_LOGGIN) + include(cmake/get_default_rcl_logging_implementation.cmake) + get_default_rcl_logging_implementation(RCL_LOGGING_IMPL) +endif() # Default to C11 if(NOT CMAKE_C_STANDARD) @@ -69,15 +78,25 @@ target_include_directories(${PROJECT_NAME} PUBLIC # specific order: dependents before dependencies ament_target_dependencies(${PROJECT_NAME} "rcl_interfaces" - "rcl_yaml_param_parser" "rcutils" "rmw" "rmw_implementation" - ${RCL_LOGGING_IMPL} "rosidl_runtime_c" "tracetools" ) +if(RCL_YAML_PARSER) + ament_target_dependencies(${PROJECT_NAME} + "rcl_yaml_param_parser" + ) +endif() + +if(RCL_LOGGIN) + ament_target_dependencies(${PROJECT_NAME} + ${RCL_LOGGING_IMPL} + ) +endif() + # Causes the visibility macros to use dllexport rather than dllimport, # which is appropriate when building the dll but not consuming it. target_compile_definitions(${PROJECT_NAME} PRIVATE "RCL_BUILDING_DLL") @@ -102,14 +121,20 @@ ament_export_targets(${PROJECT_NAME}) ament_export_dependencies(ament_cmake) ament_export_dependencies(rcl_interfaces) -ament_export_dependencies(rcl_yaml_param_parser) ament_export_dependencies(rmw_implementation) ament_export_dependencies(rmw) ament_export_dependencies(rcutils) -ament_export_dependencies(${RCL_LOGGING_IMPL}) ament_export_dependencies(rosidl_runtime_c) ament_export_dependencies(tracetools) +if(RCL_YAML_PARSER) + ament_export_dependencies(rcl_yaml_param_parser) +endif() + +if(RCL_LOGGIN) + ament_export_dependencies(${RCL_LOGGING_IMPL}) +endif() + if(BUILD_TESTING) find_package(ament_lint_auto REQUIRED) ament_lint_auto_find_test_dependencies() From ffeb0833bc95c6900fc6a9eaaa33e7f06d599559 Mon Sep 17 00:00:00 2001 From: julibert Date: Fri, 5 Jun 2020 09:43:18 +0000 Subject: [PATCH 3/5] Replace RCL_YAML_PARSER by RCL_COMMAND_LINE_ENABLED and RCL_LOGGING by RCL_LOGGING_ENABLED. --- rcl/CMakeLists.txt | 30 ++++++++++++++++++------------ rcl/include/rcl/context.h | 4 ++++ rcl/include/rcl/node.h | 2 ++ rcl/include/rcl/node_options.h | 5 +++++ rcl/src/rcl/client.c | 4 ++++ rcl/src/rcl/context.c | 4 ++++ rcl/src/rcl/event.c | 2 ++ rcl/src/rcl/init.c | 12 ++++++++++++ rcl/src/rcl/node.c | 17 +++++++++++++++++ rcl/src/rcl/node_options.c | 10 ++++++++++ rcl/src/rcl/publisher.c | 4 ++++ rcl/src/rcl/service.c | 4 ++++ rcl/src/rcl/subscription.c | 4 ++++ 13 files changed, 90 insertions(+), 12 deletions(-) diff --git a/rcl/CMakeLists.txt b/rcl/CMakeLists.txt index 8fe9f644e..99d0de102 100644 --- a/rcl/CMakeLists.txt +++ b/rcl/CMakeLists.txt @@ -2,8 +2,8 @@ cmake_minimum_required(VERSION 3.5) project(rcl) -option(RCL_YAML_PARSER "Enable/disable the rcl_yaml_param_parser tool" OFF) -option(RCL_LOGGIN "Enable/disable logging" OFF) +option(RCL_COMMAND_LINE_ENABLED "Enable/disable the rcl_yaml_param_parser tool" OFF) +option(RCL_LOGGING_ENABLED "Enable/disable logging" OFF) find_package(ament_cmake_ros REQUIRED) @@ -14,13 +14,13 @@ find_package(rmw_implementation REQUIRED) find_package(rosidl_runtime_c REQUIRED) find_package(tracetools REQUIRED) -if(RCL_YAML_PARSER) +if(RCL_COMMAND_LINE_ENABLED) find_package(rcl_yaml_param_parser REQUIRED) endif() include(cmake/rcl_set_symbol_visibility_hidden.cmake) -if(RCL_LOGGIN) +if(RCL_LOGGING_ENABLED) include(cmake/get_default_rcl_logging_implementation.cmake) get_default_rcl_logging_implementation(RCL_LOGGING_IMPL) endif() @@ -40,7 +40,7 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") endif() set(${PROJECT_NAME}_sources - src/rcl/arguments.c + $<$:src/rcl/arguments.c> src/rcl/client.c src/rcl/common.c src/rcl/context.c @@ -54,12 +54,12 @@ set(${PROJECT_NAME}_sources src/rcl/lexer.c src/rcl/lexer_lookahead.c src/rcl/localhost.c - src/rcl/logging_rosout.c - src/rcl/logging.c + $<$:src/rcl/logging_rosout.c> + $<$:src/rcl/logging.c> src/rcl/node.c src/rcl/node_options.c src/rcl/publisher.c - src/rcl/remap.c + $<$:src/rcl/remap.c> src/rcl/rmw_implementation_identifier_check.c src/rcl/security.c src/rcl/service.c @@ -85,18 +85,24 @@ ament_target_dependencies(${PROJECT_NAME} "tracetools" ) -if(RCL_YAML_PARSER) +if(RCL_COMMAND_LINE_ENABLED) ament_target_dependencies(${PROJECT_NAME} "rcl_yaml_param_parser" ) endif() -if(RCL_LOGGIN) +if(RCL_LOGGING_ENABLED) ament_target_dependencies(${PROJECT_NAME} ${RCL_LOGGING_IMPL} ) endif() +target_compile_definitions(${PROJECT_NAME} + PRIVATE + $<$:RCL_COMMAND_LINE_ENABLED> + $<$:RCL_LOGGING_ENABLED> + ) + # Causes the visibility macros to use dllexport rather than dllimport, # which is appropriate when building the dll but not consuming it. target_compile_definitions(${PROJECT_NAME} PRIVATE "RCL_BUILDING_DLL") @@ -127,11 +133,11 @@ ament_export_dependencies(rcutils) ament_export_dependencies(rosidl_runtime_c) ament_export_dependencies(tracetools) -if(RCL_YAML_PARSER) +if(RCL_COMMAND_LINE_ENABLED) ament_export_dependencies(rcl_yaml_param_parser) endif() -if(RCL_LOGGIN) +if(RCL_LOGGING_ENABLED) ament_export_dependencies(${RCL_LOGGING_IMPL}) endif() diff --git a/rcl/include/rcl/context.h b/rcl/include/rcl/context.h index 633e3bd83..46e7896eb 100644 --- a/rcl/include/rcl/context.h +++ b/rcl/include/rcl/context.h @@ -23,7 +23,9 @@ extern "C" #include "rmw/init.h" #include "rcl/allocator.h" +#ifdef RCL_COMMAND_LINE_ENABLED #include "rcl/arguments.h" +#endif // RCL_COMMAND_LINE_ENABLED #include "rcl/init_options.h" #include "rcl/macros.h" #include "rcl/types.h" @@ -107,9 +109,11 @@ struct rcl_context_impl_t; */ typedef struct rcl_context_t { +#ifdef RCL_COMMAND_LINE_ENABLED /// Global arguments for all nodes which share this context. /** Typically generated by the parsing of argc/argv in `rcl_init()`. */ rcl_arguments_t global_arguments; +#endif // RCL_COMMAND_LINE_ENABLED /// Implementation specific pointer. struct rcl_context_impl_t * impl; diff --git a/rcl/include/rcl/node.h b/rcl/include/rcl/node.h index 2c3109450..9114d36c3 100644 --- a/rcl/include/rcl/node.h +++ b/rcl/include/rcl/node.h @@ -23,7 +23,9 @@ extern "C" #include #include "rcl/allocator.h" +#ifdef RCL_COMMAND_LINE_ENABLED #include "rcl/arguments.h" +#endif // RCL_COMMAND_LINE_ENABLED #include "rcl/context.h" #include "rcl/macros.h" #include "rcl/node_options.h" diff --git a/rcl/include/rcl/node_options.h b/rcl/include/rcl/node_options.h index 15dfeed6e..de16551e8 100644 --- a/rcl/include/rcl/node_options.h +++ b/rcl/include/rcl/node_options.h @@ -21,7 +21,10 @@ extern "C" #endif #include "rcl/allocator.h" +#ifdef RCL_COMMAND_LINE_ENABLED #include "rcl/arguments.h" +#endif // RCL_COMMAND_LINE_ENABLED +#include "rcl/macros.h" #include "rcl/domain_id.h" @@ -57,8 +60,10 @@ typedef struct rcl_node_options_t /// If false then only use arguments in this struct, otherwise use global arguments also. bool use_global_arguments; +#ifdef RCL_COMMAND_LINE_ENABLED /// Command line arguments that apply only to this node. rcl_arguments_t arguments; +#endif // RCL_COMMAND_LINE_ENABLED /// Flag to enable rosout for this node bool enable_rosout; diff --git a/rcl/src/rcl/client.c b/rcl/src/rcl/client.c index 9bf70dc4a..0c42c930f 100644 --- a/rcl/src/rcl/client.c +++ b/rcl/src/rcl/client.c @@ -24,7 +24,9 @@ extern "C" #include "rcl/error_handling.h" #include "rcl/expand_topic_name.h" +#ifdef RCL_COMMAND_LINE_ENABLED #include "rcl/remap.h" +#endif // RCL_COMMAND_LINE_ENABLED #include "rcutils/logging_macros.h" #include "rcutils/stdatomic_helper.h" #include "rmw/error_handling.h" @@ -130,6 +132,7 @@ rcl_client_init( ret = RCL_RET_ERROR; goto cleanup; } +#ifdef RCL_COMMAND_LINE_ENABLED rcl_arguments_t * global_args = NULL; if (node_options->use_global_arguments) { global_args = &(node->context->global_arguments); @@ -143,6 +146,7 @@ rcl_client_init( remapped_service_name = expanded_service_name; expanded_service_name = NULL; } +#endif // RCL_COMMAND_LINE_ENABLED // Validate the expanded service name. int validation_result; diff --git a/rcl/src/rcl/context.c b/rcl/src/rcl/context.c index 0f6df4da3..5734a4a02 100644 --- a/rcl/src/rcl/context.c +++ b/rcl/src/rcl/context.c @@ -32,7 +32,9 @@ rcl_get_zero_initialized_context(void) .instance_id_storage = {0}, }; // this is not constexpr so it cannot be in the struct initialization +#ifdef RCL_COMMAND_LINE_ENABLED context.global_arguments = rcl_get_zero_initialized_arguments(); +#endif // RCL_COMMAND_LINE_ENABLED // ensure assumption about static storage static_assert( sizeof(context.instance_id_storage) >= sizeof(atomic_uint_least64_t), @@ -103,6 +105,7 @@ __cleanup_context(rcl_context_t * context) // reset the instance id to 0 to indicate "invalid" (should already be 0, but this is defensive) rcutils_atomic_store((atomic_uint_least64_t *)(&context->instance_id_storage), 0); +#ifdef RCL_COMMAND_LINE_ENABLED // clean up global_arguments if initialized if (NULL != context->global_arguments.impl) { rcl_ret_t ret = rcl_arguments_fini(&(context->global_arguments)); @@ -115,6 +118,7 @@ __cleanup_context(rcl_context_t * context) rcl_reset_error(); } } +#endif // RCL_COMMAND_LINE_ENABLED // if impl is null, nothing else can be cleaned up if (NULL != context->impl) { diff --git a/rcl/src/rcl/event.c b/rcl/src/rcl/event.c index 81ccf7c50..3b21b179d 100644 --- a/rcl/src/rcl/event.c +++ b/rcl/src/rcl/event.c @@ -23,7 +23,9 @@ extern "C" #include "rcl/error_handling.h" #include "rcl/expand_topic_name.h" +#ifdef RCL_COMMAND_LINE_ENABLED #include "rcl/remap.h" +#endif // RCL_COMMAND_LINE_ENABLED #include "rcutils/logging_macros.h" #include "rmw/error_handling.h" #include "rmw/validate_full_topic_name.h" diff --git a/rcl/src/rcl/init.c b/rcl/src/rcl/init.c index a18f675bb..4bc5a0496 100644 --- a/rcl/src/rcl/init.c +++ b/rcl/src/rcl/init.c @@ -27,15 +27,21 @@ extern "C" #include "tracetools/tracetools.h" +#ifdef RCL_COMMAND_LINE_ENABLED #include "rcl/arguments.h" +#endif // RCL_COMMAND_LINE_ENABLED #include "rcl/domain_id.h" #include "rcl/error_handling.h" #include "rcl/localhost.h" +#ifdef RCL_LOGGING_ENABLED #include "rcl/logging.h" +#endif // RCL_LOGGING_ENABLED #include "rcl/security.h" #include "rcl/validate_enclave_name.h" +#ifdef RCL_COMMAND_LINE_ENABLED #include "./arguments_impl.h" +#endif // RCL_COMMAND_LINE_ENABLED #include "./common.h" #include "./context_impl.h" #include "./init_options_impl.h" @@ -80,8 +86,10 @@ rcl_init( return RCL_RET_ALREADY_INIT; } +#ifdef RCL_COMMAND_LINE_ENABLED // Zero initialize global arguments. context->global_arguments = rcl_get_zero_initialized_arguments(); +#endif // RCL_COMMAND_LINE_ENABLED // Setup impl for context. // use zero_allocate so the cleanup function will not try to clean up uninitialized parts later @@ -123,6 +131,7 @@ rcl_init( } } +#ifdef RCL_COMMAND_LINE_ENABLED // Parse the ROS specific arguments. ret = rcl_parse_arguments(argc, argv, allocator, &context->global_arguments); if (RCL_RET_OK != ret) { @@ -130,6 +139,7 @@ rcl_init( RCUTILS_LOG_ERROR_NAMED(ROS_PACKAGE_NAME, "Failed to parse global arguments"); goto fail; } +#endif // RCL_COMMAND_LINE_ENABLED // Set the instance id. uint64_t next_instance_id = rcutils_atomic_fetch_add_uint64_t(&__rcl_next_unique_id, 1); @@ -164,6 +174,7 @@ rcl_init( } } +#ifdef RCL_COMMAND_LINE_ENABLED if (context->global_arguments.impl->enclave) { context->impl->init_options.impl->rmw_init_options.enclave = rcutils_strdup( context->global_arguments.impl->enclave, @@ -172,6 +183,7 @@ rcl_init( context->impl->init_options.impl->rmw_init_options.enclave = rcutils_strdup( "/", context->impl->allocator); } +#endif RCL_COMMAND_LINE_ENABLED int validation_result; size_t invalid_index; ret = rcl_validate_enclave_name( diff --git a/rcl/src/rcl/node.c b/rcl/src/rcl/node.c index 4ae93ecd8..4829dbea6 100644 --- a/rcl/src/rcl/node.c +++ b/rcl/src/rcl/node.c @@ -24,14 +24,20 @@ extern "C" #include #include +#ifdef RCL_COMMAND_LINE_ENABLED #include "rcl/arguments.h" +#endif // RCL_COMMAND_LINE_ENABLED #include "rcl/error_handling.h" #include "rcl/domain_id.h" #include "rcl/localhost.h" +#ifdef RCL_LOGGING_ENABLED #include "rcl/logging.h" #include "rcl/logging_rosout.h" +#endif // RCL_LOGGING_ENABLED #include "rcl/rcl.h" +#ifdef RCL_COMMAND_LINE_ENABLED #include "rcl/remap.h" +#endif // RCL_COMMAND_LINE_ENABLED #include "rcl/security.h" #include "rcutils/filesystem.h" @@ -215,6 +221,7 @@ rcl_node_init( goto fail; } +#ifdef RCL_COMMAND_LINE_ENABLED // Remap the node name and namespace if remap rules are given rcl_arguments_t * global_args = NULL; if (node->impl->options.use_global_arguments) { @@ -241,6 +248,7 @@ rcl_node_init( should_free_local_namespace_ = true; local_namespace_ = remapped_namespace; } +#endif // RCL_COMMAND_LINE_ENABLED // compute fully qualfied name of the node. if ('/' == local_namespace_[strlen(local_namespace_) - 1]) { @@ -297,6 +305,7 @@ rcl_node_init( // error message already set goto fail; } +#ifdef RCL_LOGGING_ENABLED // 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() && node->impl->options.enable_rosout) { @@ -306,6 +315,7 @@ rcl_node_init( goto fail; } } +#endif // RCL_LOGGING_ENABLED RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME, "Node initialized"); ret = RCL_RET_OK; TRACEPOINT( @@ -317,6 +327,7 @@ rcl_node_init( goto cleanup; fail: if (node->impl) { +#ifdef RCL_LOGGING_ENABLED if (rcl_logging_rosout_enabled() && node->impl->options.enable_rosout && node->impl->logger_name) @@ -327,6 +338,7 @@ rcl_node_init( ROS_PACKAGE_NAME, "Failed to fini publisher for node: %i", ret); allocator->deallocate((char *)node->impl->logger_name, allocator->state); } +#endif // RCL_LOGGING_ENABLED if (node->impl->fq_name) { allocator->deallocate((char *)node->impl->fq_name, allocator->state); } @@ -349,6 +361,8 @@ rcl_node_init( } allocator->deallocate(node->impl->graph_guard_condition, allocator->state); } + +#ifdef RCL_COMMAND_LINE_ENABLED if (NULL != node->impl->options.arguments.impl) { ret = rcl_arguments_fini(&(node->impl->options.arguments)); if (ret != RCL_RET_OK) { @@ -358,6 +372,7 @@ rcl_node_init( ); } } +#endif // RCL_COMMAND_LINE_ENABLED allocator->deallocate(node->impl, allocator->state); } *node = rcl_get_zero_initialized_node(); @@ -408,12 +423,14 @@ rcl_node_fini(rcl_node_t * node) // assuming that allocate and deallocate are ok since they are checked in init allocator.deallocate((char *)node->impl->logger_name, allocator.state); allocator.deallocate((char *)node->impl->fq_name, allocator.state); +#ifdef RCL_COMMAND_LINE_ENABLED if (NULL != node->impl->options.arguments.impl) { rcl_ret_t ret = rcl_arguments_fini(&(node->impl->options.arguments)); if (ret != RCL_RET_OK) { return ret; } } +#endif // RCL_COMMAND_LINE_ENABLED allocator.deallocate(node->impl, allocator.state); node->impl = NULL; RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME, "Node finalized"); diff --git a/rcl/src/rcl/node_options.c b/rcl/src/rcl/node_options.c index 024a76dc6..095904d0e 100644 --- a/rcl/src/rcl/node_options.c +++ b/rcl/src/rcl/node_options.c @@ -19,10 +19,14 @@ extern "C" #include "rcl/node_options.h" +#ifdef RCL_COMMAND_LINE_ENABLED #include "rcl/arguments.h" +#endif // RCL_COMMAND_LINE_ENABLED #include "rcl/domain_id.h" #include "rcl/error_handling.h" +#ifdef RCL_LOGGING_ENABLED #include "rcl/logging_rosout.h" +#endif // RCL_LOGGING_ENABLED rcl_node_options_t rcl_node_get_default_options() @@ -35,7 +39,9 @@ rcl_node_get_default_options() }; // Must set the allocator after because it is not a compile time constant. default_options.allocator = rcl_get_default_allocator(); +#ifdef RCL_COMMAND_LINE_ENABLED default_options.arguments = rcl_get_zero_initialized_arguments(); +#endif // RCL_COMMAND_LINE_ENABLED return default_options; } @@ -54,10 +60,12 @@ 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; +#ifdef RCL_COMMAND_LINE_ENABLED if (NULL != options->arguments.impl) { rcl_ret_t ret = rcl_arguments_copy(&(options->arguments), &(options_out->arguments)); return ret; } +#endif // RCL_COMMAND_LINE_ENABLED return RCL_RET_OK; } @@ -69,6 +77,7 @@ rcl_node_options_fini( rcl_allocator_t allocator = options->allocator; RCL_CHECK_ALLOCATOR(&allocator, return RCL_RET_INVALID_ARGUMENT); +#ifdef RCL_COMMAND_LINE_ENABLED if (options->arguments.impl) { rcl_ret_t ret = rcl_arguments_fini(&options->arguments); if (RCL_RET_OK != ret) { @@ -76,6 +85,7 @@ rcl_node_options_fini( return ret; } } +#endif // RCL_COMMAND_LINE_ENABLED return RCL_RET_OK; } diff --git a/rcl/src/rcl/publisher.c b/rcl/src/rcl/publisher.c index 7666352d8..96826ddb6 100644 --- a/rcl/src/rcl/publisher.c +++ b/rcl/src/rcl/publisher.c @@ -25,7 +25,9 @@ extern "C" #include "rcl/allocator.h" #include "rcl/error_handling.h" #include "rcl/expand_topic_name.h" +#ifdef RCL_COMMAND_LINE_ENABLED #include "rcl/remap.h" +#endif // RCL_COMMAND_LINE_ENABLED #include "rcutils/logging_macros.h" #include "rmw/error_handling.h" #include "rmw/validate_full_topic_name.h" @@ -127,6 +129,7 @@ rcl_publisher_init( ret = RCL_RET_ERROR; goto cleanup; } +#ifdef RCL_COMMAND_LINE_ENABLED rcl_arguments_t * global_args = NULL; if (node_options->use_global_arguments) { global_args = &(node->context->global_arguments); @@ -140,6 +143,7 @@ rcl_publisher_init( remapped_topic_name = expanded_topic_name; expanded_topic_name = NULL; } +#endif // RCL_COMMAND_LINE_ENABLED // Validate the expanded topic name. int validation_result; diff --git a/rcl/src/rcl/service.c b/rcl/src/rcl/service.c index 6dc1c79fc..e67459f5c 100644 --- a/rcl/src/rcl/service.c +++ b/rcl/src/rcl/service.c @@ -24,7 +24,9 @@ extern "C" #include "rcl/error_handling.h" #include "rcl/expand_topic_name.h" +#ifdef RCL_COMMAND_LINE_ENABLED #include "rcl/remap.h" +#endif // RCL_COMMAND_LINE_ENABLED #include "rcutils/logging_macros.h" #include "rmw/error_handling.h" #include "rmw/rmw.h" @@ -128,6 +130,7 @@ rcl_service_init( ret = RCL_RET_ERROR; goto cleanup; } +#ifdef RCL_COMMAND_LINE_ENABLED rcl_arguments_t * global_args = NULL; if (node_options->use_global_arguments) { global_args = &(node->context->global_arguments); @@ -141,6 +144,7 @@ rcl_service_init( remapped_service_name = expanded_service_name; expanded_service_name = NULL; } +#endif // RCL_COMMAND_LINE_ENABLED // Validate the expanded service name. int validation_result; diff --git a/rcl/src/rcl/subscription.c b/rcl/src/rcl/subscription.c index 2e3b37d38..b4b622d81 100644 --- a/rcl/src/rcl/subscription.c +++ b/rcl/src/rcl/subscription.c @@ -23,7 +23,9 @@ extern "C" #include "rcl/error_handling.h" #include "rcl/expand_topic_name.h" +#ifdef RCL_COMMAND_LINE_ENABLED #include "rcl/remap.h" +#endif // RCL_COMMAND_LINE_ENABLED #include "rcutils/logging_macros.h" #include "rmw/error_handling.h" #include "rmw/validate_full_topic_name.h" @@ -123,6 +125,7 @@ rcl_subscription_init( ret = RCL_RET_ERROR; goto cleanup; } +#ifdef RCL_COMMAND_LINE_ENABLED rcl_arguments_t * global_args = NULL; if (node_options->use_global_arguments) { global_args = &(node->context->global_arguments); @@ -136,6 +139,7 @@ rcl_subscription_init( remapped_topic_name = expanded_topic_name; expanded_topic_name = NULL; } +#endif // RCL_COMMAND_LINE_ENABLED // Validate the expanded topic name. int validation_result; From 57f3ff6f5d16e0ff2bcd6444ba358e250cac935c Mon Sep 17 00:00:00 2001 From: Pablo Garrido Date: Tue, 16 Jun 2020 08:35:14 +0200 Subject: [PATCH 4/5] Disabled logging fix --- rcl/src/rcl/node.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rcl/src/rcl/node.c b/rcl/src/rcl/node.c index 4829dbea6..13085e139 100644 --- a/rcl/src/rcl/node.c +++ b/rcl/src/rcl/node.c @@ -402,6 +402,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; +#ifdef RCL_LOGGING_ENABLED if (rcl_logging_rosout_enabled() && node->impl->options.enable_rosout) { rcl_ret = rcl_logging_rosout_fini_publisher_for_node(node); if (rcl_ret != RCL_RET_OK && rcl_ret != RCL_RET_NOT_INIT) { @@ -409,6 +410,7 @@ rcl_node_fini(rcl_node_t * node) result = RCL_RET_ERROR; } } +#endif // RCL_LOGGING_ENABLED rmw_ret_t rmw_ret = rmw_destroy_node(node->impl->rmw_node_handle); if (rmw_ret != RMW_RET_OK) { RCL_SET_ERROR_MSG(rmw_get_error_string().str); From 8b600a58e58f06c14b8a17492359833ef3ab8283 Mon Sep 17 00:00:00 2001 From: Pablo Garrido Date: Wed, 1 Jul 2020 11:35:10 +0200 Subject: [PATCH 5/5] Fix remapping (#7) --- rcl/src/rcl/client.c | 3 +++ rcl/src/rcl/publisher.c | 3 +++ rcl/src/rcl/service.c | 3 +++ rcl/src/rcl/subscription.c | 3 +++ 4 files changed, 12 insertions(+) diff --git a/rcl/src/rcl/client.c b/rcl/src/rcl/client.c index 0c42c930f..20ec2be66 100644 --- a/rcl/src/rcl/client.c +++ b/rcl/src/rcl/client.c @@ -146,6 +146,9 @@ rcl_client_init( remapped_service_name = expanded_service_name; expanded_service_name = NULL; } +#else + remapped_service_name = (char *)allocator->allocate(strlen(expanded_service_name) + 1, allocator->state); + memcpy(remapped_service_name, expanded_service_name, strlen(expanded_service_name) + 1); #endif // RCL_COMMAND_LINE_ENABLED // Validate the expanded service name. diff --git a/rcl/src/rcl/publisher.c b/rcl/src/rcl/publisher.c index 96826ddb6..e0bdb9d2c 100644 --- a/rcl/src/rcl/publisher.c +++ b/rcl/src/rcl/publisher.c @@ -143,6 +143,9 @@ rcl_publisher_init( remapped_topic_name = expanded_topic_name; expanded_topic_name = NULL; } +#else + remapped_topic_name = (char *)allocator->allocate(strlen(expanded_topic_name) + 1, allocator->state); + memcpy(remapped_topic_name, expanded_topic_name, strlen(expanded_topic_name) + 1); #endif // RCL_COMMAND_LINE_ENABLED // Validate the expanded topic name. diff --git a/rcl/src/rcl/service.c b/rcl/src/rcl/service.c index e67459f5c..c05071f52 100644 --- a/rcl/src/rcl/service.c +++ b/rcl/src/rcl/service.c @@ -144,6 +144,9 @@ rcl_service_init( remapped_service_name = expanded_service_name; expanded_service_name = NULL; } +#else + remapped_service_name = (char *)allocator->allocate(strlen(expanded_service_name) + 1, allocator->state); + memcpy(remapped_service_name, expanded_service_name, strlen(expanded_service_name) + 1); #endif // RCL_COMMAND_LINE_ENABLED // Validate the expanded service name. diff --git a/rcl/src/rcl/subscription.c b/rcl/src/rcl/subscription.c index b4b622d81..1bdc73025 100644 --- a/rcl/src/rcl/subscription.c +++ b/rcl/src/rcl/subscription.c @@ -139,6 +139,9 @@ rcl_subscription_init( remapped_topic_name = expanded_topic_name; expanded_topic_name = NULL; } +#else + remapped_topic_name = (char *)allocator->allocate(strlen(expanded_topic_name) + 1, allocator->state); + memcpy(remapped_topic_name, expanded_topic_name, strlen(expanded_topic_name) + 1); #endif // RCL_COMMAND_LINE_ENABLED // Validate the expanded topic name.