Skip to content

Commit 542e070

Browse files
pablogs9BorjaOuterelo
authored andcommitted
micro-ROS rcutils dependencies (#92)
* Added rcutils + freertos analisys of problematic dependencies * Updates
1 parent 4b04ecf commit 542e070

1 file changed

Lines changed: 139 additions & 0 deletions

File tree

  • _docs/concepts/client_library/rcutils_analysis
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
## Proposed changes
2+
3+
The main issues found when porting rcutils package to embedded systems with RTOS during micro-ROS development were:
4+
- the lack of filesystem
5+
- dynamic memory allocations out of the RTOS control (usually with standar library implementations of `malloc` and `free`)
6+
- the POSIX API dependency
7+
8+
This document addresses the first two items.
9+
10+
In order to avoid the **filesystem** dependency without modifiying high level layers (such as `rcl` or `rmw`), it is proposed to use a combination between the available `rcl_logging_noop` package and a modified version of the filesystem dependecies in `rcutils`. This approach is enabled using `RCUTILS_NO_FILESYSTEM` flag in compilation time.
11+
12+
**Dynamic memory allocation** must be bounded to ROS2 custom allocators. `rcl` and `rmw` layers usually rely on `rcutils_get_default_allocator` function in order to obtain allocators, so a setter function is proposed.
13+
This way, using `rcutils_set_default_allocator` function is possible to modify the defaults easing the use of custom memory management in embedded systems.
14+
15+
Dynamic memory allocation is also found when dealing with error handling in `rcutils`. By using `RCUTILS_AVOID_DYNAMIC_ALLOCATION` some string related `memmove` functions along the error handling are avoided.
16+
17+
## Dependencies in `rcl`, `rcutils` and `rmw`
18+
19+
*Test folders are excluded.*
20+
21+
### error_handling.h
22+
23+
- Macro **RCUTILS_SAFE_FWRITE_TO_STDERR** in `rcutils` error_handling.h:
24+
[Check here](https://github.com/micro-ROS/rcutils/commit/bcaa00a6ed12fc62d05dc5e44521a1648fd2d07f#diff-1b06d4a1ccca0f0dff66d961923143a1L42)
25+
- Problem: use `fwrite` to print to stderr and relies on a filesytem
26+
- Appears in:
27+
- rcl/rcl/src/rcl/expand_topic_name.c
28+
- rcl/rcl/src/rcl/logging_rosout.c
29+
- rcl/rcl/src/rcl/logging.c
30+
- rcl/rcl/src/rcl/context.c
31+
- rcl/rcl_yaml_param_parser/src/parser.c
32+
- rcutils/src/split.c
33+
- rcutils/src/error_handling.c
34+
- rcutils/src/allocator.c
35+
- rcutils/src/logging.c
36+
- rcutils/src/error_handling_helpers.h
37+
- rcutils/include/rcutils/logging.h
38+
- rcutils/include/rcutils/error_handling.h
39+
- rcl/rcl/src/rcl/expand_topic_name.c
40+
- rcl/rcl/src/rcl/logging_rosout.c
41+
- rcl/rcl/src/rcl/logging.c
42+
- rcl/rcl/src/rcl/context.c
43+
- rcl/rcl_yaml_param_parser/src/parser.c
44+
- rmw/rmw/include/rmw/error_handling.h
45+
46+
- Macro **RCUTILS_SET_ERROR_MSG** in `rcutils` error_handling.h: [Check here](https://github.com/micro-ROS/rcutils/commit/bcaa00a6ed12fc62d05dc5e44521a1648fd2d07f#diff-1b06d4a1ccca0f0dff66d961923143a1R202)
47+
- Problem: use inconditionally `memmove` inside `__rcutils_copy_string()` inside `rcutils_set_error_state`. It implies dynamic memory allocation.
48+
- Dependecies:
49+
- rcl/rcl/include/rcl/error_handling.h
50+
- rcutils/src/security_directory.c
51+
- rcutils/src/time_unix.c
52+
- rcutils/src/split.c
53+
- rcutils/src/error_handling.c
54+
- rcutils/src/time.c
55+
- rcutils/src/string_map.c
56+
- rcutils/src/uint8_array.c
57+
- rcutils/src/hash_map.c
58+
- rcutils/src/char_array.c
59+
- rcutils/src/logging.c
60+
- rcutils/src/string_array.c
61+
- rcutils/src/array_list.c
62+
- rcutils/include/rcutils/types/array_list.h
63+
- rcutils/include/rcutils/types/hash_map.h
64+
- rcutils/include/rcutils/allocator.h
65+
- rcutils/include/rcutils/error_handling.h
66+
- rcl/rcl/include/rcl/error_handling.h
67+
- rmw/rmw/include/rmw/error_handling.h
68+
69+
- Macro **RCUTILS_SET_ERROR_MSG_WITH_FORMAT_STRING** in `rcutils` error_handling.h:. [Check here](https://github.com/micro-ROS/rcutils/commit/bcaa00a6ed12fc62d05dc5e44521a1648fd2d07f#diff-1b06d4a1ccca0f0dff66d961923143a1R218)
70+
- Problem: use `RCUTILS_SET_ERROR_MSG`, see above.
71+
- Dependecies:
72+
- rcl/rcl/include/rcl/error_handling.h
73+
- rcutils/src/security_directory.c
74+
- rcutils/src/string_map.c
75+
- rcutils/src/logging.c
76+
- rcutils/include/rcutils/error_handling.h
77+
- rcl/rcl/include/rcl/error_handling.h
78+
- rmw/rmw/include/rmw/error_handling.h
79+
80+
### security_directory.c (moved from `rcl` to `rcutils`)
81+
82+
- Function **get_best_matching_directory** in `rcutils` security_directory.c [Check here](https://github.com/micro-ROS/rcutils/commit/9804287c3489ce9c88b714832abf54f9a7b7198d#diff-1ca0173d6a68ba1bdcd9ff908b769911R91)
83+
- Problem: use **tinydir** library which relies on filesytem
84+
- Dependecies:
85+
- rcutils/src/security_directory.c
86+
- rcl/rcl/src/rcl/security_directory.c
87+
88+
- Function **prefix_match_lookup**. [Check here](https://github.com/micro-ROS/rcutils/commit/9804287c3489ce9c88b714832abf54f9a7b7198d#diff-1ca0173d6a68ba1bdcd9ff908b769911L151)
89+
- Problem: use **tinydir** library which relies on filesytem
90+
- Dependencies:
91+
- rcutils/src/security_directory.c
92+
- rcl/rcl/src/rcl/security_directory.c
93+
94+
### allocator.c
95+
96+
- Function **rcutils_get_default_allocator**. [Check here](https://github.com/micro-ROS/rcutils/commit/3abb1eb2c9b206054101293997c0d4e541b1c657)
97+
- Problem: use static allocated **default_allocator** which uses malloc/free. **rcutils_set_default_allocator** is proposed.
98+
- Dependecies:
99+
- rcl/rcl/include/rcl/allocator.h
100+
- rcl/rcl/include/rcl/expand_topic_name.h
101+
- rcutils/src/allocator.c
102+
- rcutils/src/logging.c
103+
- rcutils/include/rcutils/types/string_map.h
104+
- rcutils/include/rcutils/types/array_list.h
105+
- rcutils/include/rcutils/types/string_array.h
106+
- rcutils/include/rcutils/types/hash_map.h
107+
- rcutils/include/rcutils/allocator.h
108+
- rmw_implementation/rmw_implementation/src/functions.cpp
109+
- rcl/rcl/include/rcl/allocator.h
110+
- rcl/rcl/include/rcl/expand_topic_name.h
111+
- rmw/rmw/src/allocators.c
112+
113+
### filesystem.c
114+
115+
- Functions **rcutils_get_cwd**, **rcutils_is_directory**, **rcutils_is_file**, **rcutils_exists**, **rcutils_is_readable**, **rcutils_is_writable** and **rcutils_is_readable_and_writable**. [Check here](https://github.com/micro-ROS/rcutils/commit/9804287c3489ce9c88b714832abf54f9a7b7198d)
116+
- Problem: rely on filesystem
117+
- Dependecies **rcutils_get_cwd()**:
118+
- rcutils/src/filesystem.c
119+
- rcutils/include/rcutils/filesystem.h
120+
- Dependecies **rcutils_is_directory()**:
121+
- rcutils/src/security_directory.c
122+
- rcutils/src/filesystem.c
123+
- rcutils/include/rcutils/filesystem.h
124+
- rcl/rcl/src/rcl/security_directory.c
125+
- Dependecies **rcutils_is_file()**:
126+
- rcutils/src/filesystem.c
127+
- rcutils/include/rcutils/filesystem.h
128+
- Dependencies **rcutils_exists()**:
129+
- rcutils/src/filesystem.c
130+
- rcutils/include/rcutils/filesystem.h
131+
- Dependencies **rcutils_is_readable()**:
132+
- rcutils/src/filesystem.c
133+
- rcutils/include/rcutils/filesystem.h
134+
- Dependencies **rcutils_is_writable()**:
135+
- rcutils/src/filesystem.c
136+
- rcutils/include/rcutils/filesystem.h
137+
- Dependencies **rcutils_is_readable_and_writable()**:
138+
- rcutils/src/filesystem.c
139+
- rcutils/include/rcutils/filesystem.h

0 commit comments

Comments
 (0)