-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add fastrtps (Fast-DDS) as supported dds middleware #148
base: main
Are you sure you want to change the base?
Conversation
dda45f1
to
49ce3de
Compare
I tried to fix the typesupport generation in interfaces.bzl, but getting errors of detail__* and time__* files not generated. Typesupport for fastrtps doesn't have those. |
) | ||
|
||
|
||
ros2_cpp_binary( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, fastdds supports two modes per https://fast-dds.docs.eprosima.com/en/latest/fastdds/ros2/ros2.html#ros-2-using-fast-dds-middleware:
rmw_fastrtps_dynamic_cpp
that can use introspection-based type-support that we already have. This one should be easy to integrate. cyclonedds rmw uses introspection-based type-support.rmw_fastrtps_cpp
that uses their custom type-support. This is involved as fastdds-specific IDL code generation needs to be implemented.
This is for rclc/rclcpp part, I think. I'm not 100% sure, should be checked, which type-support rclpy expects/can work with.
My take: as a first step, if it suits your needs, just integrate rmw_fastrtps_dynamic_cpp.
If we want to go with rmw_fastrtps_cpp then we will also need to use dds_vendor switch in IDL code-generation, to only generate what's necessary. This might get involved -- haven't studied what generated code fastdds needs.
Please let me know what you think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will switch it to dynamic instead. I tried this before, but didn't have improving results. Let's see if I can make it work!
load("@com_github_mvukov_rules_ros2//ros2:cc_defs.bzl", "ros2_cpp_library") | ||
|
||
string_flag( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move this and the two config settings to //ros2/BUILD.bazel. Where this is actually used is an implementation detail from user perspective, IMO.
.github/workflows/main.yml
Outdated
@@ -45,11 +45,22 @@ jobs: | |||
toolchain: | |||
- "gcc" | |||
- "clang" | |||
dds_vendor: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CI changes are OK, but lets leave this for a follow-up. For instance, I have to check how much buildbuddy remote cache we use and not overspend on it.
data = select( | ||
{ | ||
":use_cyclonedds": ["@ros2_rmw_cyclonedds//:rmw_cyclonedds"], | ||
":use_fastdds": ["@ros2_rmw_fastrtps//:rmw_fastrtps"], | ||
}, | ||
no_match_error = "Unsupported dds vendor", | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯
Switched to Getting a new, a bit more descriptive error: Executing tests from //ros2/test:generic_publisher_tests
-----------------------------------------------------------------------------
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from TestGenericPublisher
[ RUN ] TestGenericPublisher.WhenPublisherDeletedInThread_EnsureCleanNodeCleanup
>>> [rcutils|error_handling.c:108] rcutils_set_error_state()
This error state is being overwritten:
'Unknown typesupport identifier, at external/ros2_rmw_fastrtps/rmw_fastrtps_dynamic_cpp/src/type_support_registry.cpp:93'
with this new error message:
'create_publisher() failed to get message_type_support, at external/ros2_rmw_fastrtps/rmw_fastrtps_dynamic_cpp/src/publisher.cpp:181'
rcutils_reset_error() should be called after error handling to avoid this.
<<<
unknown file: Failure
C++ exception with description "failed to initialize rcl node: error not set, at external/ros2_rcl/rcl/src/rcl/publisher.c:116" thrown in the test body.
[ FAILED ] TestGenericPublisher.WhenPublisherDeletedInThread_EnsureCleanNodeCleanup (5 ms)
[----------] 1 test from TestGenericPublisher (5 ms total)
[----------] Global test environment tear-down
[==========] 1 test from 1 test suite ran. (5 ms total)
[ PASSED ] 0 tests.
[ FAILED ] 1 test, listed below:
[ FAILED ] TestGenericPublisher.WhenPublisherDeletedInThread_EnsureCleanNodeCleanup |
Hi, this is somewhat likely related to #2 -- I suspect you'll need to patch rmw_fastrtps_dynamic_cpp in a similar way we patched rmw_cyclone_dds. |
Aha! I actually just came to the exact same conclusion haha 😄 == does not work for c strings. It passed when I used strcmp instead! We should raise issues in the corresponding repos, if not done already. |
@mvukov tests are passing and chatter example ran with fastdds 🚀 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I run tests, I get errors related to
==================== Test output for //ros2/test:test_rclcpp:
terminate called after throwing an instance of 'rclcpp::exceptions::RCLError'
what(): failed to initialize rcl init options: failed to load shared library 'external/ros2_rmw_fastrtps/librmw_fastrtps_dynamic_cpp.so' due to dlopen error: external/ros2_rmw_fastrtps/librmw_fastrtps_dynamic_cpp.so: undefined symbol: shm_open, at external/ros2_rcutils/src/shared_library.c:99, at external/ros2_rmw_implementation/rmw_implementation/src/functions.cpp:88, at external/ros2_rcl/rcl/src/rcl/init_options.c:75
Please check what shm_open expects and document it. Perhaps add SHM under a flag, like we do for iceoryx.
You should not manually edit repositories/ros2_repositories_impl.bzl, but edit repositories/ros2_repo_mappings.yaml and then run bazel run //repositories/private:resolver
(if all up-to-date git diff must be empty for this the _impl.bzl file). If needed, you can override a package version from the yaml file.
repositories/fastcdr.BUILD.bazel
Outdated
"EPROSIMA_INSTALLER": "OFF", | ||
"EPROSIMA_BUILD": "OFF", | ||
"EPROSIMA_BUILD_TESTS": "OFF", | ||
"APPEND_PROJECT_NAME_TO_INCLUDEDIR": "OFF", | ||
"BUILD_DOCUMENTATION": "OFF", | ||
"CHECK_DOCUMENTATION": "OFF", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please alph-sort by keys.
repositories/fastrtps.BUILD.bazel
Outdated
"SECURITY": "OFF", | ||
"NO_TLS": "ON", | ||
"SHM_TRANSPORT_DEFAULT": "ON", | ||
"COMPILE_TOOLS": "OFF", | ||
"INSTALL_TOOLS": "OFF", | ||
"FASTDDS_STATISTICS": "OFF", | ||
"COMPILE_EXAMPLES": "OFF", | ||
"INSTALL_EXAMPLES": "OFF", | ||
"BUILD_DOCUMENTATION": "OFF", | ||
"CHECK_DOCUMENTATION": "OFF", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please alph-sort by keys.
{ | ||
- return typesupport_identifier == rosidl_typesupport_introspection_c__identifier; | ||
+ return !std::string(typesupport_identifier) | ||
+ .compare(rosidl_typesupport_introspection_c__identifier); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would std::strcmp work if you would cast rosidl_typesupport_introspection_c__identifier
to char*
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
strcmp works, I just wanted to use the same method as the patch for cyclonedds to be consistent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As pointed out in ros2/rmw_cyclonedds#320, std::strcmp is a bit of an optimization and will avoid an extra mem. alloc. (Eventually we should also refactor the rwm_cyclonedds patch, but that's for a follow-up.)
|
||
ros2_cpp_library( | ||
name = "rmw_fastrtps_shared_cpp", | ||
srcs = glob([ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please split into hdrs and srcs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think header files in src
belong in srcs
. They don't look like they're intended for downstream rules to #include directly.
ros2/BUILD.bazel
Outdated
@@ -64,3 +66,25 @@ py_binary( | |||
"@ros2cli//:ros2lifecycle", | |||
], | |||
) | |||
|
|||
# DDS vendor settings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Obvious comments, please rm.
|
||
config_setting( | ||
name = "use_fastdds", | ||
flag_values = {":dds_vendor": "fastdds"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be fastdds_dynamic IMO.
Strange, I do not get this error when running the tests. I will investigate a bit. |
I ran this command and then the urls were removed from the http_archive rules. |
@mvukov fixed comments
|
OK, I will investigate this. |
Strange, I am getting the same error as you when running a regular listener node with fastdds active: [micro_ros_listener_example_task-2] terminate called after throwing an instance of 'rclcpp::exceptions::RCLError'
[micro_ros_listener_example_task-2] what(): failed to initialize rcl init options: failed to load shared library
'external/ros2_rmw_fastrtps/librmw_fastrtps_dynamic_cpp.so' due to dlopen error:
external/ros2_rmw_fastrtps/librmw_fastrtps_dynamic_cpp.so: undefined symbol: shm_open, at
external/ros2_rcutils/src/shared_library.c:99, at
external/ros2_rmw_implementation/rmw_implementation/src/functions.cpp:88, at
external/ros2_rcl/rcl/src/rcl/init_options.c:75 It works when enabling shared memory transport, but not without... |
@mvukov I have learned that we should link all binaries and tests (using e.g This is because some pointers are shared between libraries and static linking creates separate object files which breaks this: linking dynamically means we do not need to patch this for example: |
Okay so this works ros2_cpp_test(
name = "generic_publisher_tests",
srcs = ["generic_publisher_tests.cc"],
linkstatic = False,
idl_deps = [
"@ros2_common_interfaces//:std_msgs",
],
deps = [
"@com_google_googletest//:gtest",
"@ros2_rclcpp//:rclcpp",
],
) since However, it still doesnt work when ros2_cpp_binary(
name = "publisher",
srcs = ["publisher.cc"],
linkstatic = False,
deps = [
"@ros2_common_interfaces//:cpp_std_msgs",
"@ros2_rclcpp//:rclcpp",
],
) I believe something is not correct with interface generation |
Okay so this is strange, When I run 'Unknown typesupport identifier, at external/ros2_rmw_fastrtps/rmw_fastrtps_dynamic_cpp/src/type_support_registry.cpp:93' But if I do set However, the test does not work, it throws the same error despite Could it be the extra dependency |
As a result from this issue: ros2/rmw_fastrtps#700
… as a dependency externally
I'm afraid Interesting discussion in ros2/rmw_fastrtps#703. FWIW, my take: relying on dynamic linking for correction operation of the code if fragile. Are there other places where |
@henriksod Any plans to finish this up? |
Sorry I haven't had time. Best to put it on hold if no one else wants to take it up. |
I'm going to try finishing this up. I'm going to respond to comments in this PR, but I don't think I can push to henriksod's branch so I'll open a new PR from my fork. I'm planning to use the |
Now that #299 is merge I hope adding fastrtps support will be way easier. |
As requested in this discussion #145
This is an attempt to add Fast-DDS as a supported dds middleware to this repo. I am using versions compatible with ROS2 Humble.
Added repo dependencies:
I have added a build flag
dds_vendor
, which will becyclonedds
by default. It controls a switch inrmw_implementation.BUILD.bazel
.This is how you can set it to use fastdds instead: