Skip to content

Commit f5436e7

Browse files
David-LP99pablogs9Julián Bermúdez OrtegaAcuadros954ntn
committed
micro-ROS Rolling patch
* micro-ROS changes over dashing - Remove security directory (#2) - Remove test_security_directory test (#4) - Moving allocators init (#5) * Avoid logging on build time based on RCutils flags (#6) * Fix remapping (#7) * Fix disabled logging (#8) * Release micro-ROS Foxy (#9) - Add the RCL_COMMAND_LINE_ENABLED and RCL_LOGGING_ENABLED CMake options, both disabled by default - Leave the arguments, remapping and logging sources out of the build, along with rcl_yaml_param_parser and the logging implementation * Updates 17092020 - Guard the arguments check of rcl_node_options_copy() * Add the micro-ROS fork update checker workflow * Disable logger name (#11) (#13) * Avoid uint64_t operation when handling context (#16) (#18) - Replace the atomic instance id storage by a plain uint32_t counter - Clean the id rollover check to avoid the invalid value instead of failing * Update fork checker for Humble * Update fork checker for Rolling * Iron release (#19) (#20) * Update micro-ROS conditional compilation - Replace both flags by a single RCL_MICROROS option, enabled by default, and the inverse RCL_MICROROS_COMPLETE_IMPL public definition - Ignore rcl_yaml_param_parser on the micro-ROS build (COLCON_IGNORE) * Disable get_type_description service (#22) * Remove type cache register methods (#23) - Exclude node_type_cache and the type hash emission from publishers, subscriptions, services, clients and action entities - Keep type_description_conversions and type_hash out of the build * Address memory issue of type hash - Store the type hash in each entity implementation instead of querying the node type cache on finalization * Fix tracetools - Export the tracetools dependency also on micro-ROS builds * exclude rcl_validate_enclave_name and rcl_get_security_options_from_environment from micro-ROS (#24) Dropped during the rebase as superseded by upstream: * Remove security directory (#2) * Remove test_security_directory test (#4) * Moving allocators init (#5) Co-authored-by: Pablo Garrido <pablogs9@gmail.com> Co-authored-by: Julián Bermúdez Ortega <julianbermudez@eprosima.com> Co-authored-by: acuadros95 <acuadros1995@gmail.com> Co-authored-by: Antón Casas <antoncasas@eprosima.com> Signed-off-by: David Laseca Perez <davidlaseca@eprosima.com>
1 parent e5754f0 commit f5436e7

31 files changed

Lines changed: 313 additions & 69 deletions

‎.github/workflows/fork_checker.yml‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: micro-ROS fork Update Checker
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
name:
6+
description: "Manual trigger"
7+
schedule:
8+
- cron: '0 4 * * *'
9+
10+
jobs:
11+
micro_ros_fork_update_check:
12+
runs-on: ubuntu-latest
13+
container: ubuntu:20.04
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
branches: [humble, jazzy, kilted, lyrical, rolling]
18+
steps:
19+
- name: Check
20+
id: check
21+
shell: bash
22+
run: |
23+
apt update; apt install -y git
24+
REPO=$(echo ${{ github.repository }} | awk '{split($0,a,"/"); print a[2]}')
25+
git clone -b ${{ matrix.branches }} https://github.com/micro-ros/$REPO
26+
cd $REPO
27+
git remote add ros2 https://github.com/ros2/$REPO
28+
git fetch ros2
29+
git fetch origin
30+
echo "::set-output name=merge_required::true"
31+
CMP=$(git rev-list --left-right --count ros2/${{ matrix.branches }}...origin/${{ matrix.branches }} | awk '{print $1}')
32+
if [ $CMP = "0" ]; then echo "::set-output name=merge_required::false"; fi
33+
34+
- name: Alert
35+
if: ${{ steps.check.outputs.merge_required == 'true' }}
36+
run: exit 1

‎.vscode/settings.json‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"files.associations": {
3+
"*.uml": "plantuml",
4+
"service_event_publisher.h": "c"
5+
}
6+
}

‎rcl/CMakeLists.txt‎

Lines changed: 68 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,43 @@ cmake_minimum_required(VERSION 3.20)
22

33
project(rcl)
44

5+
option(RCL_MICROROS "micro-ROS build mode" ON)
6+
57
find_package(ament_cmake_ros REQUIRED)
68
find_package(ament_cmake_ros_core REQUIRED)
79
find_package(ament_cmake_gen_version_h REQUIRED)
810

9-
find_package(libyaml_vendor REQUIRED)
1011
find_package(rcl_interfaces REQUIRED)
1112
find_package(rcl_logging_interface REQUIRED)
12-
find_package(rcl_yaml_param_parser REQUIRED)
1313
find_package(rcutils REQUIRED)
1414
find_package(rmw REQUIRED)
1515
find_package(rmw_implementation REQUIRED)
1616
find_package(rosidl_runtime_c REQUIRED)
1717
find_package(service_msgs REQUIRED)
1818
find_package(tracetools REQUIRED)
1919
find_package(type_description_interfaces REQUIRED)
20-
find_package(yaml REQUIRED)
20+
21+
if(NOT RCL_MICROROS)
22+
find_package(libyaml_vendor REQUIRED)
23+
find_package(yaml REQUIRED)
24+
find_package(rcl_yaml_param_parser REQUIRED)
25+
endif()
2126

2227
include(cmake/rcl_set_symbol_visibility_hidden.cmake)
2328

24-
# Determine the logging implementation to use
25-
include(cmake/get_default_rcl_logging_implementation.cmake)
26-
get_default_rcl_logging_implementation(RCL_LOGGING_IMPL)
27-
message(STATUS "RCL_LOGGING_IMPLEMENTATION: ${RCL_LOGGING_IMPL}")
29+
if(NOT RCL_MICROROS)
30+
# Determine the logging implementation to use
31+
include(cmake/get_default_rcl_logging_implementation.cmake)
32+
get_default_rcl_logging_implementation(RCL_LOGGING_IMPL)
33+
message(STATUS "RCL_LOGGING_IMPLEMENTATION: ${RCL_LOGGING_IMPL}")
34+
endif()
2835

2936
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
3037
add_compile_options(-Wall -Wextra -Wpedantic)
3138
endif()
3239

3340
set(${PROJECT_NAME}_sources
34-
src/rcl/arguments.c
41+
$<$<NOT:$<BOOL:${RCL_MICROROS}>>:src/rcl/arguments.c>
3542
src/rcl/client.c
3643
src/rcl/common.c
3744
src/rcl/context.c
@@ -47,13 +54,13 @@ set(${PROJECT_NAME}_sources
4754
src/rcl/init_options.c
4855
src/rcl/lexer.c
4956
src/rcl/lexer_lookahead.c
50-
src/rcl/logging_rosout.c
51-
src/rcl/logging.c
52-
src/rcl/log_level.c
57+
$<$<NOT:$<BOOL:${RCL_MICROROS}>>:src/rcl/logging_rosout.c>
58+
$<$<NOT:$<BOOL:${RCL_MICROROS}>>:src/rcl/logging.c>
59+
$<$<NOT:$<BOOL:${RCL_MICROROS}>>:src/rcl/log_level.c>
5360
src/rcl/network_flow_endpoints.c
5461
src/rcl/node.c
5562
src/rcl/node_options.c
56-
src/rcl/node_type_cache.c
63+
$<$<NOT:$<BOOL:${RCL_MICROROS}>>:src/rcl/node_type_cache.c>
5764
src/rcl/publisher.c
5865
src/rcl/remap.c
5966
src/rcl/node_resolve_name.c
@@ -65,7 +72,7 @@ set(${PROJECT_NAME}_sources
6572
src/rcl/time.c
6673
src/rcl/timer.c
6774
src/rcl/type_hash.c
68-
src/rcl/type_description_conversions.c
75+
$<$<NOT:$<BOOL:${RCL_MICROROS}>>:src/rcl/type_description_conversions.c>
6976
src/rcl/validate_enclave_name.c
7077
src/rcl/validate_topic_name.c
7178
src/rcl/wait.c
@@ -79,36 +86,62 @@ target_include_directories(${PROJECT_NAME} PUBLIC
7986
target_link_libraries(${PROJECT_NAME} PUBLIC
8087
ament_cmake_ros_core::ament_ros_defaults
8188
# TODO(clalancette): rcl_interfaces should be PRIVATE, but downstream depends on it for now
82-
rcl_interfaces::rcl_interfaces
89+
$<$<NOT:$<BOOL:${RCL_MICROROS}>>:rcl_interfaces::rcl_interfaces>
8390
# TODO(clalancette): rcl_logging_interface should be PRIVATE, but downstream depends on it for now
84-
rcl_logging_interface::rcl_logging_interface
85-
rcl_yaml_param_parser::rcl_yaml_param_parser
91+
$<$<NOT:$<BOOL:${RCL_MICROROS}>>:rcl_logging_interface::rcl_logging_interface>
8692
rcutils::rcutils
8793
rmw::rmw
8894
# TODO(clalancette): rmw_implementation should be PRIVATE, but downstream depends on it for now
8995
rmw_implementation::rmw_implementation
9096
rosidl_runtime_c::rosidl_runtime_c
9197
type_description_interfaces::type_description_interfaces
9298
)
99+
93100
target_link_libraries(${PROJECT_NAME} PRIVATE
94-
service_msgs::service_msgs
95101
tracetools::tracetools
96-
yaml
97102
)
98103

99-
# Link logging implementation based on configuration
100-
if(RCL_LOGGING_IMPL STREQUAL "rcl_logging_implementation")
101-
# Dynamic loading: use rcl_logging_implementation abstraction
104+
if(NOT RCL_MICROROS)
102105
target_link_libraries(${PROJECT_NAME} PRIVATE
103-
rcl_logging_implementation::rcl_logging_implementation
106+
service_msgs::service_msgs
107+
yaml
104108
)
105-
else()
106-
# Static linking: use specific logging implementation
107-
target_link_libraries(${PROJECT_NAME} PRIVATE
108-
${RCL_LOGGING_IMPL}::${RCL_LOGGING_IMPL}
109+
endif()
110+
111+
if(NOT RCL_MICROROS)
112+
ament_target_dependencies(${PROJECT_NAME}
113+
"rcl_yaml_param_parser"
114+
)
115+
endif()
116+
117+
if(NOT RCL_MICROROS)
118+
ament_target_dependencies(${PROJECT_NAME}
119+
${RCL_LOGGING_IMPL}
109120
)
110121
endif()
111122

123+
if(NOT RCL_MICROROS)
124+
target_compile_definitions(${PROJECT_NAME}
125+
PUBLIC
126+
RCL_MICROROS_COMPLETE_IMPL
127+
)
128+
endif()
129+
130+
if(NOT RCL_MICROROS)
131+
# Link logging implementation based on configuration
132+
if(RCL_LOGGING_IMPL STREQUAL "rcl_logging_implementation")
133+
# Dynamic loading: use rcl_logging_implementation abstraction
134+
target_link_libraries(${PROJECT_NAME} PRIVATE
135+
rcl_logging_implementation::rcl_logging_implementation
136+
)
137+
else()
138+
# Static linking: use specific logging implementation
139+
target_link_libraries(${PROJECT_NAME} PRIVATE
140+
${RCL_LOGGING_IMPL}::${RCL_LOGGING_IMPL}
141+
)
142+
endif()
143+
endif()
144+
112145
# Allow configuring the default discovery range
113146
if(DEFINED RCL_DEFAULT_DISCOVERY_RANGE)
114147
target_compile_definitions(${PROJECT_NAME} PRIVATE
@@ -145,14 +178,21 @@ ament_export_dependencies(ament_cmake_ros_core)
145178
ament_export_dependencies(rcl_interfaces)
146179
# TODO(clalancette): rcl_logging_interface shouldn't be exported, but downstream depends on it for now
147180
ament_export_dependencies(rcl_logging_interface)
148-
ament_export_dependencies(rcl_yaml_param_parser)
149181
ament_export_dependencies(rcutils)
150182
ament_export_dependencies(rmw)
151183
# TODO(clalancette): rmw_implementation shouldn't be exported, but downstream depends on it for now
152184
ament_export_dependencies(rmw_implementation)
153185
ament_export_dependencies(rosidl_runtime_c)
154186
ament_export_dependencies(type_description_interfaces)
155-
ament_generate_version_header(${PROJECT_NAME})
187+
ament_export_dependencies(tracetools)
188+
189+
if(NOT RCL_MICROROS)
190+
ament_export_dependencies(rcl_yaml_param_parser)
191+
endif()
192+
193+
if(NOT RCL_MICROROS)
194+
ament_export_dependencies(${RCL_LOGGING_IMPL})
195+
endif()
156196

157197
if(BUILD_TESTING)
158198
find_package(ament_lint_auto REQUIRED)

‎rcl/include/rcl/arguments.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@
2222
#include "rcl/macros.h"
2323
#include "rcl/types.h"
2424
#include "rcl/visibility_control.h"
25+
#ifdef RCL_MICROROS_COMPLETE_IMPL
2526
#include "rcl_yaml_param_parser/types.h"
27+
#else
28+
typedef struct rcl_params_s rcl_params_t;
29+
#endif // RCL_MICROROS_COMPLETE_IMPL
2630

2731
#ifdef __cplusplus
2832
extern "C"

‎rcl/include/rcl/context.h‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ extern "C"
2828

2929
#include "rmw/init.h"
3030

31+
#ifdef RCL_MICROROS_COMPLETE_IMPL
3132
#include "rcl/arguments.h"
33+
#endif // RCL_MICROROS_COMPLETE_IMPL
3234
#include "rcl/init_options.h"
3335
#include "rcl/macros.h"
3436
#include "rcl/types.h"
@@ -115,21 +117,18 @@ typedef struct rcl_context_impl_s rcl_context_impl_t;
115117
*/
116118
typedef struct rcl_context_s
117119
{
120+
#ifdef RCL_MICROROS_COMPLETE_IMPL
118121
/// Global arguments for all nodes which share this context.
119122
/** Typically generated by the parsing of argc/argv in rcl_init(). */
120123
rcl_arguments_t global_arguments;
124+
#endif // RCL_MICROROS_COMPLETE_IMPL
121125

122126
/// Implementation specific pointer.
123127
rcl_context_impl_t * impl;
124128

125129
// The assumption that this is big enough for an atomic_uint_least64_t is
126130
// ensured with a static_assert in the context.c file.
127131
// In most cases it should just be a plain uint64_t.
128-
/// @cond Doxygen_Suppress
129-
#if !defined(RCL_CONTEXT_ATOMIC_INSTANCE_ID_STORAGE_SIZE)
130-
#define RCL_CONTEXT_ATOMIC_INSTANCE_ID_STORAGE_SIZE sizeof(uint_least64_t)
131-
#endif
132-
/// @endcond
133132
/// Private storage for instance ID atomic.
134133
/**
135134
* Accessing the instance id should be done using the function
@@ -149,7 +148,7 @@ typedef struct rcl_context_s
149148
* See this paper for an effort to make this possible in the future:
150149
* http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0943r1.html
151150
*/
152-
RCL_ALIGNAS(8) uint8_t instance_id_storage[RCL_CONTEXT_ATOMIC_INSTANCE_ID_STORAGE_SIZE];
151+
uint32_t instance_id_storage;
153152
} rcl_context_t;
154153

155154
/// Return a zero initialization context object.

‎rcl/include/rcl/node.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ extern "C"
2727
#include <stdint.h>
2828

2929
#include "rcl/allocator.h"
30+
#ifdef RCL_MICROROS_COMPLETE_IMPL
3031
#include "rcl/arguments.h"
32+
#endif // RCL_MICROROS_COMPLETE_IMPL
3133
#include "rcl/context.h"
3234
#include "rcl/guard_condition.h"
3335
#include "rcl/macros.h"

‎rcl/include/rcl/node_options.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ extern "C"
2525
#include <stdbool.h>
2626

2727
#include "rcl/allocator.h"
28+
#ifdef RCL_MICROROS_COMPLETE_IMPL
2829
#include "rcl/arguments.h"
30+
#endif // RCL_MICROROS_COMPLETE_IMPL
2931
#include "rcl/domain_id.h"
3032
#include "rcl/macros.h"
3133
#include "rcl/types.h"
@@ -52,8 +54,10 @@ typedef struct rcl_node_options_s
5254
/// If false then only use arguments in this struct, otherwise use global arguments also.
5355
bool use_global_arguments;
5456

57+
#ifdef RCL_MICROROS_COMPLETE_IMPL
5558
/// Command line arguments that apply only to this node.
5659
rcl_arguments_t arguments;
60+
#endif // RCL_MICROROS_COMPLETE_IMPL
5761

5862
/// Flag to enable rosout for this node
5963
bool enable_rosout;

‎rcl/include/rcl/timer.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ extern "C"
3535
#include "rcl/types.h"
3636
#include "rcl/visibility_control.h"
3737

38+
// TEMPORARY (micro-ROS): ros2/rcl#1334 dropped this include, but downstream C code
39+
// (e.g. ros2/rclc rclc_parameter) still relies on getting rmw/qos_profiles.h through it.
40+
// Remove once rclc includes rmw/qos_profiles.h directly.
41+
#include "rmw/rmw.h"
42+
3843
typedef struct rcl_timer_impl_s rcl_timer_impl_t;
3944

4045
/// Structure which encapsulates a ROS Timer.

‎rcl/src/rcl/arguments_impl.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include "rcl/allocator.h"
2121
#include "rcl/arguments.h"
2222
#include "rcl/log_level.h"
23-
#include "rcl_yaml_param_parser/types.h"
2423
#include "./remap_impl.h"
2524

2625
#ifdef __cplusplus

‎rcl/src/rcl/client.c‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ extern "C"
2626
#include "rcl/allocator.h"
2727
#include "rcl/error_handling.h"
2828
#include "rcl/node.h"
29+
#ifdef RCL_MICROROS_COMPLETE_IMPL
2930
#include "rcl/node_type_cache.h"
31+
#endif // RCL_MICROROS_COMPLETE_IMPL
3032
#include "rcl/publisher.h"
3133
#include "rcl/time.h"
3234
#include "rcl/types.h"
@@ -176,6 +178,7 @@ rcl_client_init(
176178
atomic_init(&client->impl->sequence_number, 0);
177179
client->impl->in_use_by_waitset = false;
178180

181+
#ifdef RCL_MICROROS_COMPLETE_IMPL
179182
const rosidl_type_hash_t * hash = type_support->get_type_hash_func(type_support);
180183
if (hash == NULL) {
181184
RCL_SET_ERROR_MSG("Failed to get the type hash");
@@ -193,6 +196,7 @@ rcl_client_init(
193196
goto destroy_client;
194197
}
195198
client->impl->type_hash = *hash;
199+
#endif // RCL_MICROROS_COMPLETE_IMPL
196200

197201
RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME, "Client initialized");
198202
TRACETOOLS_TRACEPOINT(
@@ -254,15 +258,15 @@ rcl_client_fini(rcl_client_t * client, rcl_node_t * node)
254258
RCL_SET_ERROR_MSG(rmw_get_error_string().str);
255259
result = RCL_RET_ERROR;
256260
}
257-
261+
#ifdef RCL_MICROROS_COMPLETE_IMPL
258262
if (
259263
ROSIDL_TYPE_HASH_VERSION_UNSET != client->impl->type_hash.version &&
260264
RCL_RET_OK != rcl_node_type_cache_unregister_type(node, &client->impl->type_hash))
261265
{
262266
RCUTILS_SAFE_FWRITE_TO_STDERR(rcl_get_error_string().str);
263267
result = RCL_RET_ERROR;
264268
}
265-
269+
#endif // RCL_MICROROS_COMPLETE_IMPL
266270
allocator.deallocate(client->impl->remapped_service_name, allocator.state);
267271
client->impl->remapped_service_name = NULL;
268272

0 commit comments

Comments
 (0)