Skip to content

Commit 4e92a88

Browse files
committed
micro-ROS Lyrical patch
Signed-off-by: David Laseca Perez <davidlaseca@eprosima.com>
1 parent 07b34cd commit 4e92a88

30 files changed

Lines changed: 302 additions & 65 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,28 +2,35 @@ 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_gen_version_h REQUIRED)
79

8-
find_package(libyaml_vendor REQUIRED)
910
find_package(rcl_interfaces REQUIRED)
1011
find_package(rcl_logging_interface REQUIRED)
11-
find_package(rcl_yaml_param_parser REQUIRED)
1212
find_package(rcutils REQUIRED)
1313
find_package(rmw REQUIRED)
1414
find_package(rmw_implementation REQUIRED)
1515
find_package(rosidl_runtime_c REQUIRED)
1616
find_package(service_msgs REQUIRED)
1717
find_package(tracetools REQUIRED)
1818
find_package(type_description_interfaces REQUIRED)
19-
find_package(yaml REQUIRED)
19+
20+
if(NOT RCL_MICROROS)
21+
find_package(libyaml_vendor REQUIRED)
22+
find_package(yaml REQUIRED)
23+
find_package(rcl_yaml_param_parser REQUIRED)
24+
endif()
2025

2126
include(cmake/rcl_set_symbol_visibility_hidden.cmake)
2227

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

2835
# Default to C11
2936
if(NOT CMAKE_C_STANDARD)
@@ -41,7 +48,7 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
4148
endif()
4249

4350
set(${PROJECT_NAME}_sources
44-
src/rcl/arguments.c
51+
$<$<NOT:$<BOOL:${RCL_MICROROS}>>:src/rcl/arguments.c>
4552
src/rcl/client.c
4653
src/rcl/common.c
4754
src/rcl/context.c
@@ -57,13 +64,13 @@ set(${PROJECT_NAME}_sources
5764
src/rcl/init_options.c
5865
src/rcl/lexer.c
5966
src/rcl/lexer_lookahead.c
60-
src/rcl/logging_rosout.c
61-
src/rcl/logging.c
62-
src/rcl/log_level.c
67+
$<$<NOT:$<BOOL:${RCL_MICROROS}>>:src/rcl/logging_rosout.c>
68+
$<$<NOT:$<BOOL:${RCL_MICROROS}>>:src/rcl/logging.c>
69+
$<$<NOT:$<BOOL:${RCL_MICROROS}>>:src/rcl/log_level.c>
6370
src/rcl/network_flow_endpoints.c
6471
src/rcl/node.c
6572
src/rcl/node_options.c
66-
src/rcl/node_type_cache.c
73+
$<$<NOT:$<BOOL:${RCL_MICROROS}>>:src/rcl/node_type_cache.c>
6774
src/rcl/publisher.c
6875
src/rcl/remap.c
6976
src/rcl/node_resolve_name.c
@@ -75,7 +82,7 @@ set(${PROJECT_NAME}_sources
7582
src/rcl/time.c
7683
src/rcl/timer.c
7784
src/rcl/type_hash.c
78-
src/rcl/type_description_conversions.c
85+
$<$<NOT:$<BOOL:${RCL_MICROROS}>>:src/rcl/type_description_conversions.c>
7986
src/rcl/validate_enclave_name.c
8087
src/rcl/validate_topic_name.c
8188
src/rcl/wait.c
@@ -88,36 +95,62 @@ target_include_directories(${PROJECT_NAME} PUBLIC
8895
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>")
8996
target_link_libraries(${PROJECT_NAME} PUBLIC
9097
# TODO(clalancette): rcl_interfaces should be PRIVATE, but downstream depends on it for now
91-
rcl_interfaces::rcl_interfaces
98+
$<$<NOT:$<BOOL:${RCL_MICROROS}>>:rcl_interfaces::rcl_interfaces>
9299
# TODO(clalancette): rcl_logging_interface should be PRIVATE, but downstream depends on it for now
93-
rcl_logging_interface::rcl_logging_interface
94-
rcl_yaml_param_parser::rcl_yaml_param_parser
100+
$<$<NOT:$<BOOL:${RCL_MICROROS}>>:rcl_logging_interface::rcl_logging_interface>
95101
rcutils::rcutils
96102
rmw::rmw
97103
# TODO(clalancette): rmw_implementation should be PRIVATE, but downstream depends on it for now
98104
rmw_implementation::rmw_implementation
99105
rosidl_runtime_c::rosidl_runtime_c
100106
type_description_interfaces::type_description_interfaces
101107
)
108+
102109
target_link_libraries(${PROJECT_NAME} PRIVATE
103-
service_msgs::service_msgs
104110
tracetools::tracetools
105-
yaml
106111
)
107112

108-
# Link logging implementation based on configuration
109-
if(RCL_LOGGING_IMPL STREQUAL "rcl_logging_implementation")
110-
# Dynamic loading: use rcl_logging_implementation abstraction
113+
if(NOT RCL_MICROROS)
111114
target_link_libraries(${PROJECT_NAME} PRIVATE
112-
rcl_logging_implementation::rcl_logging_implementation
115+
service_msgs::service_msgs
116+
yaml
113117
)
114-
else()
115-
# Static linking: use specific logging implementation
116-
target_link_libraries(${PROJECT_NAME} PRIVATE
117-
${RCL_LOGGING_IMPL}::${RCL_LOGGING_IMPL}
118+
endif()
119+
120+
if(NOT RCL_MICROROS)
121+
ament_target_dependencies(${PROJECT_NAME}
122+
"rcl_yaml_param_parser"
123+
)
124+
endif()
125+
126+
if(NOT RCL_MICROROS)
127+
ament_target_dependencies(${PROJECT_NAME}
128+
${RCL_LOGGING_IMPL}
118129
)
119130
endif()
120131

132+
if(NOT RCL_MICROROS)
133+
target_compile_definitions(${PROJECT_NAME}
134+
PUBLIC
135+
RCL_MICROROS_COMPLETE_IMPL
136+
)
137+
endif()
138+
139+
if(NOT RCL_MICROROS)
140+
# Link logging implementation based on configuration
141+
if(RCL_LOGGING_IMPL STREQUAL "rcl_logging_implementation")
142+
# Dynamic loading: use rcl_logging_implementation abstraction
143+
target_link_libraries(${PROJECT_NAME} PRIVATE
144+
rcl_logging_implementation::rcl_logging_implementation
145+
)
146+
else()
147+
# Static linking: use specific logging implementation
148+
target_link_libraries(${PROJECT_NAME} PRIVATE
149+
${RCL_LOGGING_IMPL}::${RCL_LOGGING_IMPL}
150+
)
151+
endif()
152+
endif()
153+
121154
# Allow configuring the default discovery range
122155
if(DEFINED RCL_DEFAULT_DISCOVERY_RANGE)
123156
target_compile_definitions(${PROJECT_NAME} PRIVATE
@@ -156,14 +189,21 @@ ament_export_dependencies(ament_cmake)
156189
ament_export_dependencies(rcl_interfaces)
157190
# TODO(clalancette): rcl_logging_interface shouldn't be exported, but downstream depends on it for now
158191
ament_export_dependencies(rcl_logging_interface)
159-
ament_export_dependencies(rcl_yaml_param_parser)
160192
ament_export_dependencies(rcutils)
161193
ament_export_dependencies(rmw)
162194
# TODO(clalancette): rmw_implementation shouldn't be exported, but downstream depends on it for now
163195
ament_export_dependencies(rmw_implementation)
164196
ament_export_dependencies(rosidl_runtime_c)
165197
ament_export_dependencies(type_description_interfaces)
166-
ament_generate_version_header(${PROJECT_NAME})
198+
ament_export_dependencies(tracetools)
199+
200+
if(NOT RCL_MICROROS)
201+
ament_export_dependencies(rcl_yaml_param_parser)
202+
endif()
203+
204+
if(NOT RCL_MICROROS)
205+
ament_export_dependencies(${RCL_LOGGING_IMPL})
206+
endif()
167207

168208
if(BUILD_TESTING)
169209
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
@@ -25,7 +25,9 @@ extern "C"
2525
#include "rmw/init.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/init_options.h"
3032
#include "rcl/macros.h"
3133
#include "rcl/types.h"
@@ -112,21 +114,18 @@ typedef struct rcl_context_impl_s rcl_context_impl_t;
112114
*/
113115
typedef struct rcl_context_s
114116
{
117+
#ifdef RCL_MICROROS_COMPLETE_IMPL
115118
/// Global arguments for all nodes which share this context.
116119
/** Typically generated by the parsing of argc/argv in rcl_init(). */
117120
rcl_arguments_t global_arguments;
121+
#endif // RCL_MICROROS_COMPLETE_IMPL
118122

119123
/// Implementation specific pointer.
120124
rcl_context_impl_t * impl;
121125

122126
// The assumption that this is big enough for an atomic_uint_least64_t is
123127
// ensured with a static_assert in the context.c file.
124128
// In most cases it should just be a plain uint64_t.
125-
/// @cond Doxygen_Suppress
126-
#if !defined(RCL_CONTEXT_ATOMIC_INSTANCE_ID_STORAGE_SIZE)
127-
#define RCL_CONTEXT_ATOMIC_INSTANCE_ID_STORAGE_SIZE sizeof(uint_least64_t)
128-
#endif
129-
/// @endcond
130129
/// Private storage for instance ID atomic.
131130
/**
132131
* Accessing the instance id should be done using the function
@@ -146,7 +145,7 @@ typedef struct rcl_context_s
146145
* See this paper for an effort to make this possible in the future:
147146
* http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0943r1.html
148147
*/
149-
RCL_ALIGNAS(8) uint8_t instance_id_storage[RCL_CONTEXT_ATOMIC_INSTANCE_ID_STORAGE_SIZE];
148+
uint32_t instance_id_storage;
150149
} rcl_context_t;
151150

152151
/// 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
@@ -25,7 +25,9 @@ extern "C"
2525
#include <stdint.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/context.h"
3032
#include "rcl/guard_condition.h"
3133
#include "rcl/macros.h"

‎rcl/include/rcl/node_options.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ extern "C"
2323
#endif
2424

2525
#include "rcl/allocator.h"
26+
#ifdef RCL_MICROROS_COMPLETE_IMPL
2627
#include "rcl/arguments.h"
28+
#endif // RCL_MICROROS_COMPLETE_IMPL
29+
#include "rcl/macros.h"
2730

2831
#include "rcl/domain_id.h"
2932

@@ -46,8 +49,10 @@ typedef struct rcl_node_options_s
4649
/// If false then only use arguments in this struct, otherwise use global arguments also.
4750
bool use_global_arguments;
4851

52+
#ifdef RCL_MICROROS_COMPLETE_IMPL
4953
/// Command line arguments that apply only to this node.
5054
rcl_arguments_t arguments;
55+
#endif // RCL_MICROROS_COMPLETE_IMPL
5156

5257
/// Flag to enable rosout for this node
5358
bool enable_rosout;

‎rcl/src/rcl/arguments_impl.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
#include "rcl/arguments.h"
1919
#include "rcl/log_level.h"
20-
#include "rcl_yaml_param_parser/types.h"
2120
#include "./remap_impl.h"
2221

2322
#ifdef __cplusplus

‎rcl/src/rcl/client.c‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ extern "C"
2424

2525
#include "rcl/error_handling.h"
2626
#include "rcl/node.h"
27+
#ifdef RCL_MICROROS_COMPLETE_IMPL
2728
#include "rcl/node_type_cache.h"
29+
#endif // RCL_MICROROS_COMPLETE_IMPL
2830
#include "rcl/publisher.h"
2931
#include "rcl/time.h"
3032
#include "rcutils/logging_macros.h"
@@ -169,6 +171,7 @@ rcl_client_init(
169171
atomic_init(&client->impl->sequence_number, 0);
170172
client->impl->in_use_by_waitset = false;
171173

174+
#ifdef RCL_MICROROS_COMPLETE_IMPL
172175
const rosidl_type_hash_t * hash = type_support->get_type_hash_func(type_support);
173176
if (hash == NULL) {
174177
RCL_SET_ERROR_MSG("Failed to get the type hash");
@@ -186,6 +189,7 @@ rcl_client_init(
186189
goto destroy_client;
187190
}
188191
client->impl->type_hash = *hash;
192+
#endif // RCL_MICROROS_COMPLETE_IMPL
189193

190194
RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME, "Client initialized");
191195
TRACETOOLS_TRACEPOINT(
@@ -247,15 +251,15 @@ rcl_client_fini(rcl_client_t * client, rcl_node_t * node)
247251
RCL_SET_ERROR_MSG(rmw_get_error_string().str);
248252
result = RCL_RET_ERROR;
249253
}
250-
254+
#ifdef RCL_MICROROS_COMPLETE_IMPL
251255
if (
252256
ROSIDL_TYPE_HASH_VERSION_UNSET != client->impl->type_hash.version &&
253257
RCL_RET_OK != rcl_node_type_cache_unregister_type(node, &client->impl->type_hash))
254258
{
255259
RCUTILS_SAFE_FWRITE_TO_STDERR(rcl_get_error_string().str);
256260
result = RCL_RET_ERROR;
257261
}
258-
262+
#endif // RCL_MICROROS_COMPLETE_IMPL
259263
allocator.deallocate(client->impl->remapped_service_name, allocator.state);
260264
client->impl->remapped_service_name = NULL;
261265

‎rcl/src/rcl/client_impl.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ struct rcl_client_impl_s
2929
atomic_int_least64_t sequence_number;
3030
rcl_service_event_publisher_t * service_event_publisher;
3131
char * remapped_service_name;
32+
#ifdef RCL_MICROROS_COMPLETE_IMPL
3233
rosidl_type_hash_t type_hash;
34+
#endif // RCL_MICROROS_COMPLETE_IMPL
3335
bool in_use_by_waitset;
3436
};
3537

0 commit comments

Comments
 (0)