You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
micro-ROS targets microcontroller, devices with low memory resources.
7
-
With that in mind, micro-ROS try to address the memory management issue prioritizing the use of static memory instead of dynamic memory and optimizing the memory footprint of the applications. This, of course, has a cost that the users must agree to pay, a precompile tunning.
7
+
With that in mind, micro-ROS try to address the memory management issue prioritizing the use of static memory instead of dynamic memory and optimizing the memory footprint of the applications.
8
+
This, of course, has a cost that the users must agree to pay, a precompile tunning.
8
9
9
10
This tutorial explains which are the memory resources managed by micro-ROS and how to tune them for a particular application.
11
+
It also addresses the RMW run-time configuration API where the user can configure the micro-ROS Agent endpoints or the Micro XRCE-DDS session `client_key`.
10
12
11
-
## Memory resources
13
+
## Memory resources optimization
12
14
13
-
micro-ROS deal with two different memory resources related with Micro XRCE-DDS library and its RMW implementation named rmw-microxrcedds.
15
+
micro-ROS deals with two different memory resources related with the Micro XRCE-DDS library and its RMW implementation named rmw-microxrcedds.
14
16
15
17
### Micro XRCE-DDS
16
18
17
-
Micro XRCE-DDS messages flows between Client and Agent throw **streams**.
18
-
A stream represents an independent ordered flow of information, that is, it is a sort of messaging queue.
19
+
Micro XRCE-DDS messages flow between Client and Agent throw **streams**.
20
+
A stream represents an independent ordered flow of information, so it is a sort of messaging queue.
19
21
There are two kinds of streams, **best-effort** and **reliable**.
20
-
Both, best-effort and reliable streams, have a raw buffer (`uint8_t` array) associated with them, but the layout is different.
22
+
Both best-effort and reliable streams, have a raw buffer (`uint8_t` array) associated with them, but the layout is different.
21
23
22
24
On the one hand, best-effort streams could be interpreted as a single message queue.
23
-
Therefore, the raw buffer a single data buffer where only one message is popped/pushed.
25
+
Therefore, the raw buffer is a single data buffer where only one message is popped/pushed.
24
26
25
27

26
28
27
-
On the other hand, reliable streams contains multiple messages which are popped/pushed according to the reliable communication protocol described in the DDS-XRCE specification.
28
-
It is achieved splitting the raw buffer into chucks, each one of those could contain a single message.
29
+
On the other hand, reliable streams contain multiple messages which are popped/pushed according to the reliable communication protocol described in the DDS-XRCE specification.
30
+
It is achieved splitting the raw buffer into chucks, each of which each contains a single message.
29
31
30
32

31
33
32
-
The size of the best-effort and reliable stream can be set by two sets of CMake flags.
34
+
The size of the best-effort and reliable stream can be configured by two sets of CMake flags.
33
35
34
-
*`UCLIENT_UDP_TRANSPORT_MTU`, `UCLIENT_TCP_TRANSPORT_MTU` and `UCLIENT_SERIAL_TRANSPORT_MTU` (depending of the transport selected): control the size of the best-effort stream buffer which matches with the size of each chunk of the reliable stream.
36
+
*`UCLIENT_UDP_TRANSPORT_MTU`, `UCLIENT_TCP_TRANSPORT_MTU` and `UCLIENT_SERIAL_TRANSPORT_MTU` (depending on the transport selected): these flags control the size of the best-effort stream buffer which matches with the size of each chunk of the reliable stream.
35
37
*`RMW_UXRCE_MAX_HISTORY`: sets the number of slots for the reliable streams.
36
38
37
39
The size of the stream sets indirectly the maximum message size (MMS) of the micro-ROS application.
38
40
This MMS is (`UCLIENT_<XXX>_TRANSPORT_MTU` - 12 B) for best-effort messages and (`UCLIENT_<XXX>_TRANSPORT_MTU` * (`RMW_UXRCE_MAX_HISTORY` - 12 B)) in the case of reliable messages.
39
41
40
42
The use of best-effort or reliable stream is handled by the `rmw_qos_reliability_policy_t` set in the `rmw_qos_profile_t` for a particular publisher or subscription.
41
-
In the case of `RMW_QOS_POLICY_RELIABILITY_BEST_EFFORT` best-effort streams are used and for `RMW_QOS_POLICY_RELIABILITY_RELIABLE` reliable streams.
43
+
In the case of `RMW_QOS_POLICY_RELIABILITY_BEST_EFFORT` best-effort streams are used and for `RMW_QOS_POLICY_RELIABILITY_RELIABLE` reliable streams are used instead.
42
44
43
45
### rmw-microxrcedds
44
46
@@ -48,16 +50,16 @@ The size of these memory pools could be set through CMake flags,
48
50
for example, the `RMW_UXRCE_MAX_PUBLISHERS` sets the size of the `rcl_publisher_t`'s pool memory.
49
51
It should be noted that the size of these memory pools restricts the maximum number of entities that a micro-ROS application could use.
50
52
51
-
The figure below summarizes the relation between the `rcl` entities and the CMake flags, which the size of the memory pool associated with such entity.
53
+
The figure below summarizes the relation between the `rcl` entities and the CMake flags, which set the size of the memory pool associated with such entities.
52
54
53
55

54
56
55
57
Another important memory resource managed by the rmw-microxrcedds is the message history.
56
-
The rmw-microxrcedds uses static-memory message queue in order to keep the subscription messages before the user read these.
58
+
The rmw-microxrcedds uses a static-memory message queue where to to keep the subscription messages before the user reads them.
57
59
The size of this message queue could be set by the `RMW_UXRCE_MAX_HISTORY`.
58
60
59
-
It is worth noting that all the afore mentioned CMake flags shall be set in a `.meta` for each platform supported in [micro-ros-build](https://github.com/micro-ROS/micro-ros-build).
60
-
For example, the [ping-pong](https://micro-ros.github.io//docs/tutorials/core/first_application_linux/) the host [configuration file](https://github.com/micro-ROS/micro-ros-build/blob/dashing/micro_ros_setup/config/host/generic/client-host-colcon.meta) which can be optimized with the following modifications:
61
+
It is worth noting that all the aforementioned CMake flags shall be set in a `.meta` for each platform supported in [micro-ros-build](https://github.com/micro-ROS/micro-ros-build).
62
+
For example, in the [ping-pong application](https://micro-ros.github.io//docs/tutorials/core/first_application_linux/) the host [configuration file](https://github.com/micro-ROS/micro-ros-build/blob/dashing/micro_ros_setup/config/host/generic/client-host-colcon.meta) can be optimized with the following modifications:
61
63
62
64
```
63
65
{
@@ -78,3 +80,38 @@ For example, the [ping-pong](https://micro-ros.github.io//docs/tutorials/core/fi
78
80
}
79
81
}
80
82
```
83
+
84
+
## Run-time configuration
85
+
86
+
There are some build time parameters related to Client-to-Agent connection (such as **CONFIG_RMW_DEFAULT_UDP_PORT**, **CONFIG_RMW_DEFAULT_UDP_IP** and **CONFIG_RMW_DEFAULT_SERIAL_DEVICE**) that can be configured either at build time or at run-time.
87
+
This means that you can set them in the [configuration file](https://github.com/micro-ROS/micro-ros-build/blob/dashing/micro_ros_setup/config/host/generic/client-host-colcon.meta) mentioned above and that micro-ROS provides a user configuration API for setting some RMW and middleware parameters at run-time.
88
+
89
+
The following example code shows the [API](https://github.com/micro-ROS/rmw-microxrcedds/blob/dashing/rmw_microxrcedds_c/include/rmw_uros/options.h) calls needed to set the agent's IP address, port or serial device:
Notice that it is also possible to set the Micro XRCE-DDS `client_key`, which would otherwise be set randomly. This feature is useful for reusing DDS entities already created on the agent side. Further information can be found [here](https://micro-xrce-dds.readthedocs.io/en/latest/deployment.html#configurate-the-publisher).
0 commit comments