Skip to content

Commit 3221dbc

Browse files
Add rcutils dependencies (#98)
* Add article to client library section. * Improve text formating. * Ignore touched files. * Compare with origin. * Fix broken link.
1 parent 542e070 commit 3221dbc

3 files changed

Lines changed: 132 additions & 117 deletions

File tree

_data/docs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
- concepts/client_library/system_modes
1414
- concepts/client_library/embedded_tf
1515
- concepts/client_library/decision_paper
16+
- concepts/client_library/rcutils_analysis
1617

1718
- title: Middleware
1819
docs:
Lines changed: 118 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
1+
---
2+
title: Embedded rcutils analysis
3+
permalink: /docs/concepts/client_library/rcutils_analysis/
4+
---
5+
16
## Proposed changes
27

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
8+
The main issues found when porting rcutils package to embedded systems with RTOS during micro*ROS development were:
9+
* the lack of filesystem
10+
* dynamic memory allocations out of the RTOS control (usually with standard library implementations of `malloc` and `free`)
11+
* the POSIX API dependency
712

813
This document addresses the first two items.
914

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.
15+
To avoid the **filesystem** dependency without modifying 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 dependencies in `rcutils`. This approach is enabled using the `RCUTILS_NO_FILESYSTEM` flag in compilation time.
1116

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.
17+
**Dynamic memory allocation** must be bounded to ROS2 custom allocators. `rcl` and `rmw` layers usually rely on `rcutils_get_default_allocator` function to obtain allocators, so a setter function is proposed.
1318
This way, using `rcutils_set_default_allocator` function is possible to modify the defaults easing the use of custom memory management in embedded systems.
1419

1520
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.
@@ -20,120 +25,120 @@ Dynamic memory allocation is also found when dealing with error handling in `rcu
2025

2126
### error_handling.h
2227

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
28+
* Macro **RCUTILS_SAFE_FWRITE_TO_STDERR** in `rcutils` error_handling.h:
29+
[Check here](https://github.com/micro-ROS/rcutils/commit/bcaa00a6ed12fc62d05dc5e44521a1648fd2d07f#diff-1b06d4a1ccca0f0dff66d961923143a1L42)
30+
* Problem: use `fwrite` to print to stderr and relies on a filesytem
31+
* Appears in:
32+
* rcl/rcl/src/rcl/expand_topic_name.c
33+
* rcl/rcl/src/rcl/logging_rosout.c
34+
* rcl/rcl/src/rcl/logging.c
35+
* rcl/rcl/src/rcl/context.c
36+
* rcl/rcl_yaml_param_parser/src/parser.c
37+
* rcutils/src/split.c
38+
* rcutils/src/error_handling.c
39+
* rcutils/src/allocator.c
40+
* rcutils/src/logging.c
41+
* rcutils/src/error_handling_helpers.h
42+
* rcutils/include/rcutils/logging.h
43+
* rcutils/include/rcutils/error_handling.h
44+
* rcl/rcl/src/rcl/expand_topic_name.c
45+
* rcl/rcl/src/rcl/logging_rosout.c
46+
* rcl/rcl/src/rcl/logging.c
47+
* rcl/rcl/src/rcl/context.c
48+
* rcl/rcl_yaml_param_parser/src/parser.c
49+
* rmw/rmw/include/rmw/error_handling.h
50+
51+
* Macro **RCUTILS_SET_ERROR_MSG** in `rcutils` error_handling.h: [Check here](https://github.com/micro-ROS/rcutils/commit/bcaa00a6ed12fc62d05dc5e44521a1648fd2d07f#diff-1b06d4a1ccca0f0dff66d961923143a1R202)
52+
* Problem: use inconditionally `memmove` inside `__rcutils_copy_string()` inside `rcutils_set_error_state`. It implies dynamic memory allocation.
53+
* Dependecies:
54+
* rcl/rcl/include/rcl/error_handling.h
55+
* rcutils/src/security_directory.c
56+
* rcutils/src/time_unix.c
57+
* rcutils/src/split.c
58+
* rcutils/src/error_handling.c
59+
* rcutils/src/time.c
60+
* rcutils/src/string_map.c
61+
* rcutils/src/uint8_array.c
62+
* rcutils/src/hash_map.c
63+
* rcutils/src/char_array.c
64+
* rcutils/src/logging.c
65+
* rcutils/src/string_array.c
66+
* rcutils/src/array_list.c
67+
* rcutils/include/rcutils/types/array_list.h
68+
* rcutils/include/rcutils/types/hash_map.h
69+
* rcutils/include/rcutils/allocator.h
70+
* rcutils/include/rcutils/error_handling.h
71+
* rcl/rcl/include/rcl/error_handling.h
72+
* rmw/rmw/include/rmw/error_handling.h
73+
74+
* 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)
75+
* Problem: use `RCUTILS_SET_ERROR_MSG`, see above.
76+
* Dependecies:
77+
* rcl/rcl/include/rcl/error_handling.h
78+
* rcutils/src/security_directory.c
79+
* rcutils/src/string_map.c
80+
* rcutils/src/logging.c
81+
* rcutils/include/rcutils/error_handling.h
82+
* rcl/rcl/include/rcl/error_handling.h
83+
* rmw/rmw/include/rmw/error_handling.h
7984

8085
### security_directory.c (moved from `rcl` to `rcutils`)
8186

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+
* Function **get_best_matching_directory** in `rcutils` security_directory.c [Check here](https://github.com/micro-ROS/rcutils/commit/9804287c3489ce9c88b714832abf54f9a7b7198d#diff-1ca0173d6a68ba1bdcd9ff908b769911R91)
88+
* Problem: use **tinydir** library which relies on filesytem
89+
* Dependecies:
90+
* rcutils/src/security_directory.c
91+
* rcl/rcl/src/rcl/security_directory.c
8792

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+
* Function **prefix_match_lookup**. [Check here](https://github.com/micro-ROS/rcutils/commit/9804287c3489ce9c88b714832abf54f9a7b7198d#diff-1ca0173d6a68ba1bdcd9ff908b769911L151)
94+
* Problem: use **tinydir** library which relies on filesytem
95+
* Dependencies:
96+
* rcutils/src/security_directory.c
97+
* rcl/rcl/src/rcl/security_directory.c
9398

9499
### allocator.c
95100

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
101+
* Function **rcutils_get_default_allocator**. [Check here](https://github.com/micro-ROS/rcutils/commit/3abb1eb2c9b206054101293997c0d4e541b1c657)
102+
* Problem: use static allocated **default_allocator** which uses malloc/free. **rcutils_set_default_allocator** is proposed.
103+
* Dependecies:
104+
* rcl/rcl/include/rcl/allocator.h
105+
* rcl/rcl/include/rcl/expand_topic_name.h
106+
* rcutils/src/allocator.c
107+
* rcutils/src/logging.c
108+
* rcutils/include/rcutils/types/string_map.h
109+
* rcutils/include/rcutils/types/array_list.h
110+
* rcutils/include/rcutils/types/string_array.h
111+
* rcutils/include/rcutils/types/hash_map.h
112+
* rcutils/include/rcutils/allocator.h
113+
* rmw_implementation/rmw_implementation/src/functions.cpp
114+
* rcl/rcl/include/rcl/allocator.h
115+
* rcl/rcl/include/rcl/expand_topic_name.h
116+
* rmw/rmw/src/allocators.c
112117

113118
### filesystem.c
114119

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
120+
* 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)
121+
* Problem: rely on filesystem
122+
* Dependecies **rcutils_get_cwd()**:
123+
* rcutils/src/filesystem.c
124+
* rcutils/include/rcutils/filesystem.h
125+
* Dependecies **rcutils_is_directory()**:
126+
* rcutils/src/security_directory.c
127+
* rcutils/src/filesystem.c
128+
* rcutils/include/rcutils/filesystem.h
129+
* rcl/rcl/src/rcl/security_directory.c
130+
* Dependecies **rcutils_is_file()**:
131+
* rcutils/src/filesystem.c
132+
* rcutils/include/rcutils/filesystem.h
133+
* Dependencies **rcutils_exists()**:
134+
* rcutils/src/filesystem.c
135+
* rcutils/include/rcutils/filesystem.h
136+
* Dependencies **rcutils_is_readable()**:
137+
* rcutils/src/filesystem.c
138+
* rcutils/include/rcutils/filesystem.h
139+
* Dependencies **rcutils_is_writable()**:
140+
* rcutils/src/filesystem.c
141+
* rcutils/include/rcutils/filesystem.h
142+
* Dependencies **rcutils_is_readable_and_writable()**:
143+
* rcutils/src/filesystem.c
144+
* rcutils/include/rcutils/filesystem.h

scripts/cibuild

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
#!/usr/bin/env bash
22
set -e # halt script on error
33

4-
IGNORE_HREFS=$(ruby -e 'puts %w{
4+
CHANGED_FILES=$(git diff --name-only origin/master)
5+
if grep -q "_docs" <<< $CHANGED_FILES; then
6+
TOUCHED=${TOUCHED:+$TOUCHED }micro-ros.github.io//docs
7+
else if grep -q "_posts" <<< $CHANGED_FILES; then
8+
TOUCHED=${TOUCHED:+$TOUCHED,}micro-ros.github.io//blog
9+
fi
10+
fi
11+
12+
IGNORE_HREFS=${IGNORE_HREFS:+$IGNORE_HREFS,}$(ruby -e "puts %w{
513
vimeo.com
6-
micro-ros.github.io//blog
7-
}.map{|h| "/#{h}/"}.join(",")'
14+
${TOUCHED}
15+
}.map{|h| \"/#{h}/\"}.join(\",\")"
816
)
917

18+
echo "Ignoring urls: " $IGNORE_HREFS
1019
bundle exec jekyll build
11-
bundle exec htmlproofer --check_html --check-favicon --assume-extension --empty-alt-ignore --only-4xx --url-ignore $IGNORE_HREFS $@ ./_site
20+
bundle exec htmlproofer --check_html --check-favicon --assume-extension --empty-alt-ignore --only-4xx --url-ignore $IGNORE_HREFS $@ ./_site

0 commit comments

Comments
 (0)