Skip to content

Commit 1781634

Browse files
Enforce power-of-two for history setting in CMakeLists (#271) (#273)
* STREAM_HISTORY option requires power-of-two value Signed-off-by: gavanderhoorn <g.a.vanderhoorn@tudelft.nl> * Also mention power-of-two requirement in readme Signed-off-by: gavanderhoorn <g.a.vanderhoorn@tudelft.nl> * cmake: enforce power-of-two for history setting Signed-off-by: gavanderhoorn <g.a.vanderhoorn@tudelft.nl> Signed-off-by: gavanderhoorn <g.a.vanderhoorn@tudelft.nl> (cherry picked from commit fb2dca6) # Conflicts: # README.md Co-authored-by: G.A. vd. Hoorn <g.a.vanderhoorn@tudelft.nl>
1 parent 5d133d6 commit 1781634

2 files changed

Lines changed: 72 additions & 4 deletions

File tree

README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,48 @@ The implementation wraps the latest code from eProsima's Micro XRCE-DDS client t
1919
This library defines the interface used by upper layers in the ROS 2 stack, and that is implemented using XRCE-DDS middleware in the lower layers.
2020
For further information about `rmw_microxrcedds` click [here](https://github.com/micro-ROS/micro-ROS-doc/blob/dashing/rmw_microxrcedds/README.md).
2121

22+
<<<<<<< HEAD
2223
#### Library build Configurations
24+
=======
25+
#### Library configuration
26+
27+
This RMW implementation can be configured via CMake arguments, its usual to configure them via `colcon.meta` file in a micro-ROS enviroment.
28+
29+
Most of these configuration are related to memory management because this RMW implementation tries to fully rely on static memory assignations. This leads to an upper bound in memory assignations, which is configured by the user before the build process.
30+
By default, the package sets the values for all memory bounded. The upper bound is configurable by a file that sets the values during the build process.
31+
32+
More details about RMW Micro XRCE-DDS can be found [here](https://micro.ros.org/docs/tutorials/advanced/microxrcedds_rmw_configuration/).
33+
All the configurable parameters are:
34+
35+
| Name | Description | Default |
36+
| ----------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
37+
| RMW_UXRCE_TRANSPORT | Sets Micro XRCE-DDS transport to use. (udp, serial, custom) | udp |
38+
| RMW_UXRCE_IPV | Sets Micro XRCE-DDS IP version to use. (ipv4, ipv6) | ipv4 |
39+
| RMW_UXRCE_CREATION_MODE | Sets creation mode in Micro XRCE-DDS. (bin, refs) | bin |
40+
| RMW_UXRCE_MAX_HISTORY | This value sets the number of history slots available for RMW subscriptions, </br> requests and replies | 8 |
41+
| RMW_UXRCE_MAX_SESSIONS | This value sets the maximum number of Micro XRCE-DDS sessions. | 1 |
42+
| RMW_UXRCE_MAX_NODES | This value sets the maximum number of nodes. | 4 |
43+
| RMW_UXRCE_MAX_PUBLISHERS | This value sets the maximum number of topic publishers for an application. | 4 |
44+
| RMW_UXRCE_MAX_SUBSCRIPTIONS | This value sets the maximum number of topic subscriptions for an application. | 4 |
45+
| RMW_UXRCE_MAX_SERVICES | This value sets the maximum number of service servers for an application. | 4 |
46+
| RMW_UXRCE_MAX_CLIENTS | This value sets the maximum number of service clients for an application. | 4 |
47+
| RMW_UXRCE_MAX_TOPICS | This value sets the maximum number of topics for an application. </br> If set to -1 RMW_UXRCE_MAX_TOPICS = RMW_UXRCE_MAX_PUBLISHERS + </br> RMW_UXRCE_MAX_SUBSCRIPTIONS + RMW_UXRCE_MAX_NODES. | -1 |
48+
| RMW_UXRCE_MAX_WAIT_SETS | This value sets the maximum number of wait sets for an application. | 4 |
49+
| RMW_UXRCE_MAX_GUARD_CONDITION | This value sets the maximum number of guard conditions for an application. | 4 |
50+
| RMW_UXRCE_NODE_NAME_MAX_LENGTH | This value sets the maximum number of characters for a node name. | 60 |
51+
| RMW_UXRCE_TOPIC_NAME_MAX_LENGTH | This value sets the maximum number of characters for a topic name. | 60 |
52+
| RMW_UXRCE_TYPE_NAME_MAX_LENGTH | This value sets the maximum number of characters for a type name. | 100 |
53+
| RMW_UXRCE_REF_BUFFER_LENGTH | This value sets the maximum number of characters for a reference buffer. | 100 |
54+
| RMW_UXRCE_ENTITY_CREATION_DESTROY_TIMEOUT | This value sets the default maximum time to wait for an XRCE entity creation </br> and destroy in milliseconds. If set to 0 best effort is used. | 1000 |
55+
| RMW_UXRCE_ENTITY_CREATION_TIMEOUT | This value sets the maximum time to wait for an XRCE entity creation </br> in milliseconds. If set to 0 best effort is used. | 1000 |
56+
| RMW_UXRCE_ENTITY_DESTROY_TIMEOUT | This value sets the maximum time to wait for an XRCE entity destroy </br> in milliseconds. If set to 0 best effort is used. | 1000 |
57+
| RMW_UXRCE_PUBLISH_RELIABLE_TIMEOUT | This value sets the default time to wait for a publication in a </br> reliable mode in milliseconds. | 1000 |
58+
| RMW_UXRCE_STREAM_HISTORY | This value sets the number of MTUs to buffer, both input and output. Must be a power-of-two. | 4 |
59+
| RMW_UXRCE_STREAM_HISTORY_INPUT | This value sets the number of MTUs to input buffer. </br> It will be ignored if RMW_UXRCE_STREAM_HISTORY_OUTPUT is blank. If set, must be a power-of-two. | - |
60+
| RMW_UXRCE_STREAM_HISTORY_OUTPUT | This value sets the number of MTUs to output buffer. </br> It will be ignored if RMW_UXRCE_STREAM_HISTORY_INPUT is blank. If set, must be a power-of-two. | - |
61+
| RMW_UXRCE_GRAPH | Allows to perform graph-related operations to the user | OFF |
62+
| RMW_UXRCE_ALLOW_DYNAMIC_ALLOCATIONS | Enables increasing static pools with dynamic allocation when needed. | OFF |
63+
>>>>>>> fb2dca6 (Enforce power-of-two for history setting in CMakeLists (#271))
2364
2465
The middleware implementation uses static memory assignations.
2566
Because of this, assignations of the memory are upper bounded so must be configured by the user before the build process.

rmw_microxrcedds_c/CMakeLists.txt

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,44 @@ if(RMW_UXRCE_ENTITY_DESTROY_TIMEOUT STREQUAL "")
8383
set(RMW_UXRCE_ENTITY_DESTROY_TIMEOUT ${RMW_UXRCE_ENTITY_CREATION_DESTROY_TIMEOUT})
8484
endif()
8585

86-
set(RMW_UXRCE_STREAM_HISTORY "4" CACHE STRING "This value sets the number of MTUs to buffer, both input and output.")
86+
set(RMW_UXRCE_STREAM_HISTORY "4" CACHE STRING
87+
"This value sets the number of MTUs to buffer, both input and output. Must be a power of two.")
8788
set(RMW_UXRCE_STREAM_HISTORY_INPUT "" CACHE STRING
88-
"This value sets the number of MTUs to input buffer. It will be ignored if RMW_UXRCE_STREAM_HISTORY_OUTPUT is blank.")
89+
"This value sets the number of MTUs to input buffer. It will be ignored if RMW_UXRCE_STREAM_HISTORY_OUTPUT is blank. \
90+
If set, must be a power of two.")
8991
set(RMW_UXRCE_STREAM_HISTORY_OUTPUT "" CACHE STRING
90-
"This value sets the number of MTUs to output buffer. It will be ignored if RMW_UXRCE_STREAM_HISTORY_INPUT is blank.")
92+
"This value sets the number of MTUs to output buffer. It will be ignored if RMW_UXRCE_STREAM_HISTORY_INPUT is blank. \
93+
If set, must be a power of two.")
9194

9295
if(RMW_UXRCE_STREAM_HISTORY_INPUT STREQUAL "" OR RMW_UXRCE_STREAM_HISTORY_OUTPUT STREQUAL "")
9396
unset(RMW_UXRCE_STREAM_HISTORY_INPUT)
9497
unset(RMW_UXRCE_STREAM_HISTORY_OUTPUT)
98+
99+
# check power-of-two requirement
100+
# from: http://graphics.stanford.edu/~seander/bithacks.html#DetermineIfPowerOf2
101+
math(EXPR __RMW_UXRCE_STREAM_HISTORY_CHECK "${RMW_UXRCE_STREAM_HISTORY} & (${RMW_UXRCE_STREAM_HISTORY} - 1)")
102+
if(${__RMW_UXRCE_STREAM_HISTORY_CHECK} GREATER 0)
103+
message(FATAL_ERROR "STREAM_HISTORY must be a power-of-two (not: ${RMW_UXRCE_STREAM_HISTORY})")
104+
endif()
105+
unset(__RMW_UXRCE_STREAM_HISTORY_CHECK)
106+
95107
else()
96108
unset(RMW_UXRCE_STREAM_HISTORY)
109+
110+
# check power-of-two requirement
111+
# from: http://graphics.stanford.edu/~seander/bithacks.html#DetermineIfPowerOf2
112+
math(EXPR __RMW_UXRCE_STREAM_HISTORY_INPUT_CHECK "${RMW_UXRCE_STREAM_HISTORY_INPUT} & (${RMW_UXRCE_STREAM_HISTORY_INPUT} - 1)")
113+
math(EXPR __RMW_UXRCE_STREAM_HISTORY_OUTPUT_CHECK "${RMW_UXRCE_STREAM_HISTORY_OUTPUT} & (${RMW_UXRCE_STREAM_HISTORY_OUTPUT} - 1)")
114+
115+
if(${__RMW_UXRCE_STREAM_HISTORY_INPUT_CHECK} GREATER 0)
116+
message(FATAL_ERROR "STREAM_HISTORY_INPUT must be a power-of-two (not: ${RMW_UXRCE_STREAM_HISTORY_INPUT})")
117+
endif()
118+
if(${__RMW_UXRCE_STREAM_HISTORY_OUTPUT_CHECK} GREATER 0)
119+
message(FATAL_ERROR "STREAM_HISTORY_OUTPUT must be a power-of-two (not: ${RMW_UXRCE_STREAM_HISTORY_OUTPUT})")
120+
endif()
121+
122+
unset(__RMW_UXRCE_STREAM_HISTORY_INPUT_CHECK)
123+
unset(__RMW_UXRCE_STREAM_HISTORY_OUTPUT_CHECK)
97124
endif()
98125

99126
# Transport handle define macros.
@@ -397,4 +424,4 @@ if(BUILD_DOCUMENTATION)
397424
install(DIRECTORY ${PROJECT_BINARY_DIR}/doc/api_reference
398425
DESTINATION ${DOC_INSTALL_DIR}
399426
COMPONENT documentation)
400-
endif()
427+
endif()

0 commit comments

Comments
 (0)