Skip to content

Commit

Permalink
micro-ROS Humble patch
Browse files Browse the repository at this point in the history
* Avoid logging on build time based on RCutils flags (#6)

* Add RCL_YAML_PARSER and RCL_LOGGING CMake options.

* Replace RCL_YAML_PARSER by RCL_COMMAND_LINE_ENABLED and RCL_LOGGING by RCL_LOGGING_ENABLED.

* Disabled logging fix

* Fix remapping (#7)

Co-authored-by: Pablo Garrido <pablogs9@gmail.com>
Co-authored-by: julibert <julianbermudez@eprosima.com>

Updates 17092020

*Release micro-ROS Foxy (#9)

Cleaning


Update


Update


Update


Add workflow checker
Update


Update


update


Test


Test


Update


Update


Update


New approach


Update


Update


Update


Update


Update


Update


Update


Update


Update


Update


Update


Update


Update


Update


Update


Update


Update


Update


Update


Update


Update


Update


Update


Update


Update


Update


Update
  • Loading branch information
pablogs9 committed May 6, 2024
1 parent 81bf82d commit 74f7477
Show file tree
Hide file tree
Showing 13 changed files with 162 additions and 14 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/fork_checker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: micro-ROS fork Update Checker
on:
workflow_dispatch:
inputs:
name:
description: "Manual trigger"
schedule:
- cron: '0 4 * * *'

jobs:
micro_ros_fork_update_check:
runs-on: ubuntu-latest
container: ubuntu:20.04
strategy:
fail-fast: false
matrix:
branches: [foxy, galactic, master]
steps:
- name: Check
id: check
shell: bash
run: |
apt update; apt install -y git
REPO=$(echo ${{ github.repository }} | awk '{split($0,a,"/"); print a[2]}')
git clone -b ${{ matrix.branches }} https://github.com/micro-ros/$REPO
cd $REPO
git remote add ros2 https://github.com/ros2/$REPO
git fetch ros2
git fetch origin
echo "::set-output name=merge_required::true"
CMP=$(git rev-list --left-right --count ros2/${{ matrix.branches }}...origin/${{ matrix.branches }} | awk '{print $1}')
if [ $CMP = "0" ]; then echo "::set-output name=merge_required::false"; fi
- name: Alert
if: ${{ steps.check.outputs.merge_required == 'true' }}
run: exit 1
53 changes: 42 additions & 11 deletions rcl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,29 @@ cmake_minimum_required(VERSION 3.5)

project(rcl)

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)

find_package(rcl_interfaces REQUIRED)
find_package(rcl_logging_interface 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_COMMAND_LINE_ENABLED)
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_LOGGING_ENABLED)
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)
Expand All @@ -32,7 +41,7 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
endif()

set(${PROJECT_NAME}_sources
src/rcl/arguments.c
$<$<BOOL:${RCL_COMMAND_LINE_ENABLED}>:src/rcl/arguments.c>
src/rcl/client.c
src/rcl/common.c
src/rcl/context.c
Expand All @@ -46,9 +55,9 @@ 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/log_level.c
$<$<BOOL:${RCL_LOGGING_ENABLED}>:src/rcl/logging_rosout.c>
$<$<BOOL:${RCL_LOGGING_ENABLED}>:src/rcl/logging.c>
$<$<BOOL:${RCL_LOGGING_ENABLED}>:src/rcl/log_level.c>
src/rcl/network_flow_endpoints.c
src/rcl/node.c
src/rcl/node_options.c
Expand All @@ -74,15 +83,31 @@ target_include_directories(${PROJECT_NAME} PUBLIC
ament_target_dependencies(${PROJECT_NAME}
"rcl_interfaces"
"rcl_logging_interface"
"rcl_yaml_param_parser"
"rcutils"
"rmw"
"rmw_implementation"
${RCL_LOGGING_IMPL}
"rosidl_runtime_c"
"tracetools"
)

if(RCL_COMMAND_LINE_ENABLED)
ament_target_dependencies(${PROJECT_NAME}
"rcl_yaml_param_parser"
)
endif()

if(RCL_LOGGING_ENABLED)
ament_target_dependencies(${PROJECT_NAME}
${RCL_LOGGING_IMPL}
)
endif()

target_compile_definitions(${PROJECT_NAME}
PRIVATE
$<$<BOOL:${RCL_COMMAND_LINE_ENABLED}>:RCL_COMMAND_LINE_ENABLED>
$<$<BOOL:${RCL_LOGGING_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")
Expand Down Expand Up @@ -114,14 +139,20 @@ ament_export_targets(${PROJECT_NAME})
ament_export_dependencies(ament_cmake)
ament_export_dependencies(rcl_interfaces)
ament_export_dependencies(rcl_logging_interface)
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_COMMAND_LINE_ENABLED)
ament_export_dependencies(rcl_yaml_param_parser)
endif()

if(RCL_LOGGING_ENABLED)
ament_export_dependencies(${RCL_LOGGING_IMPL})
endif()

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
ament_lint_auto_find_test_dependencies()
Expand Down
4 changes: 4 additions & 0 deletions rcl/include/rcl/arguments.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@
#include "rcl/macros.h"
#include "rcl/types.h"
#include "rcl/visibility_control.h"
#ifdef RCL_COMMAND_LINE_ENABLED
#include "rcl_yaml_param_parser/types.h"
#else
typedef bool rcl_params_t;
#endif // RCL_COMMAND_LINE_ENABLED

#ifdef __cplusplus
extern "C"
Expand Down
4 changes: 4 additions & 0 deletions rcl/include/rcl/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,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"
Expand Down Expand Up @@ -112,9 +114,11 @@ typedef struct rcl_context_impl_s rcl_context_impl_t;
*/
typedef struct rcl_context_s
{
#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.
rcl_context_impl_t * impl;
Expand Down
2 changes: 2 additions & 0 deletions rcl/include/rcl/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ extern "C"
#include <stdint.h>

#include "rcl/allocator.h"
#ifdef RCL_COMMAND_LINE_ENABLED
#include "rcl/arguments.h"
#endif // RCL_COMMAND_LINE_ENABLED
#include "rcl/context.h"
#include "rcl/guard_condition.h"
#include "rcl/macros.h"
Expand Down
5 changes: 5 additions & 0 deletions rcl/include/rcl/node_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,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"

Expand All @@ -46,8 +49,10 @@ typedef struct rcl_node_options_s
/// 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;
Expand Down
4 changes: 4 additions & 0 deletions rcl/src/rcl/arguments_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@

#include "rcl/arguments.h"
#include "rcl/log_level.h"
#ifdef RCL_COMMAND_LINE_ENABLED
#include "rcl_yaml_param_parser/types.h"
#else
typedef bool rcl_params_t;
#endif // RCL_COMMAND_LINE_ENABLED
#include "./remap_impl.h"

#ifdef __cplusplus
Expand Down
4 changes: 4 additions & 0 deletions rcl/src/rcl/context.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,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),
Expand Down Expand Up @@ -112,6 +114,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) {
ret = rcl_arguments_fini(&(context->global_arguments));
Expand All @@ -124,6 +127,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) {
Expand Down
12 changes: 12 additions & 0 deletions rcl/src/rcl/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -123,13 +131,15 @@ 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) {
fail_ret = ret;
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);
Expand Down Expand Up @@ -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,
Expand All @@ -178,6 +189,7 @@ rcl_init(
fail_ret = RCL_RET_BAD_ALLOC;
goto fail;
}
#endif //RCL_COMMAND_LINE_ENABLED

int validation_result;
size_t invalid_index;
Expand Down
10 changes: 7 additions & 3 deletions rcl/src/rcl/logging.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,13 @@ rcl_logging_configure_with_output_handler(
int default_level = -1;
rcl_log_levels_t * log_levels = &global_args->impl->log_levels;
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;

Expand Down
Loading

0 comments on commit 74f7477

Please sign in to comment.