-
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?
Changes from all commits
0b383a7
5299e28
66b2d4a
aeb70e3
4e339eb
0f5c362
72819cd
7a4246e
36602a1
631b597
0720bca
bdecf5d
30186fa
502d125
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
""" Builds FastCDR. | ||
""" | ||
|
||
load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake") | ||
|
||
filegroup( | ||
name = "all_srcs", | ||
srcs = glob(["**"]), | ||
) | ||
|
||
cache_entries = { | ||
"CMAKE_POSITION_INDEPENDENT_CODE": "ON", # Must be set! | ||
"BUILD_SHARED_LIBS": "OFF", | ||
# FastCDR specific options. | ||
"APPEND_PROJECT_NAME_TO_INCLUDEDIR": "OFF", | ||
"BUILD_DOCUMENTATION": "OFF", | ||
"CHECK_DOCUMENTATION": "OFF", | ||
"EPROSIMA_BUILD": "OFF", | ||
"EPROSIMA_BUILD_TESTS": "OFF", | ||
"EPROSIMA_INSTALLER": "OFF", | ||
} | ||
|
||
cmake( | ||
name = "fastcdr", | ||
build_args = [ | ||
"--", | ||
"-j4", | ||
], | ||
cache_entries = cache_entries, | ||
lib_source = ":all_srcs", | ||
out_static_libs = ["libfastcdr.a"], | ||
visibility = ["//visibility:public"], | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
""" Builds FastDDS. | ||
""" | ||
|
||
load("@bazel_skylib//lib:dicts.bzl", "dicts") | ||
load("@bazel_skylib//lib:selects.bzl", "selects") | ||
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag") | ||
load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake") | ||
|
||
bool_flag( | ||
name = "enable_shm", | ||
build_setting_default = False, | ||
) | ||
|
||
config_setting( | ||
name = "enable_shm_on", | ||
flag_values = {":enable_shm": "True"}, | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
config_setting( | ||
name = "enable_shm_off", | ||
flag_values = {":enable_shm": "False"}, | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
selects.config_setting_group( | ||
name = "linux_or_macos", | ||
match_any = [ | ||
"@platforms//os:linux", | ||
"@platforms//os:macos", | ||
], | ||
) | ||
|
||
selects.config_setting_group( | ||
name = "linux_or_macos_with_shm", | ||
match_all = [ | ||
":linux_or_macos", | ||
":enable_shm_on", | ||
], | ||
) | ||
|
||
selects.config_setting_group( | ||
name = "qnx_with_shm", | ||
match_all = [ | ||
"@platforms//os:qnx", | ||
":enable_shm_on", | ||
], | ||
) | ||
|
||
selects.config_setting_group( | ||
name = "linux_or_macos_without_shm", | ||
match_all = [ | ||
":linux_or_macos", | ||
":enable_shm_off", | ||
], | ||
) | ||
|
||
selects.config_setting_group( | ||
name = "qnx_without_shm", | ||
match_all = [ | ||
"@platforms//os:qnx", | ||
":enable_shm_off", | ||
], | ||
) | ||
|
||
filegroup( | ||
name = "all_srcs", | ||
srcs = glob(["**"]), | ||
) | ||
|
||
cache_entries = { | ||
"CMAKE_POSITION_INDEPENDENT_CODE": "ON", # Must be set! | ||
"BUILD_SHARED_LIBS": "OFF", | ||
# FastDDS specific options. | ||
"BUILD_DOCUMENTATION": "OFF", | ||
"CHECK_DOCUMENTATION": "OFF", | ||
"COMPILE_EXAMPLES": "OFF", | ||
"COMPILE_TOOLS": "OFF", | ||
"FASTDDS_STATISTICS": "OFF", | ||
"INSTALL_EXAMPLES": "OFF", | ||
"INSTALL_TOOLS": "OFF", | ||
"NO_TLS": "ON", | ||
"SECURITY": "OFF", | ||
} | ||
|
||
cache_entries_with_shm = { | ||
"SHM_TRANSPORT_DEFAULT": "ON", | ||
} | ||
|
||
cache_entries_without_shm = { | ||
"SHM_TRANSPORT_DEFAULT": "OFF", | ||
} | ||
|
||
cmake( | ||
name = "fastrtps", | ||
build_args = [ | ||
"--", | ||
"-j4", | ||
], | ||
cache_entries = select( | ||
{ | ||
":enable_shm_on": dicts.add( | ||
cache_entries, | ||
cache_entries_with_shm, | ||
), | ||
":enable_shm_off": dicts.add( | ||
cache_entries, | ||
cache_entries_without_shm, | ||
), | ||
}, | ||
no_match_error = "Unsupported build configuration", | ||
), | ||
lib_source = ":all_srcs", | ||
linkopts = select( | ||
{ | ||
":linux_or_macos_with_shm": [ | ||
"-lpthread", | ||
"-lrt", | ||
], | ||
":qnx_with_shm": ["-lrt"], | ||
":linux_or_macos_without_shm": ["-lpthread"], | ||
":qnx_without_shm": [], | ||
}, | ||
no_match_error = "Only Linux, macOS and QNX are supported!", | ||
), | ||
out_static_libs = ["libfastrtps.a"], | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
"@asio", | ||
"@fastcdr", | ||
"@foonathan_memory", | ||
"@tinyxml2", | ||
], | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
""" Builds foonathan_memory. | ||
""" | ||
|
||
load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake") | ||
|
||
filegroup( | ||
name = "all_srcs", | ||
srcs = glob(["**"]), | ||
) | ||
|
||
cache_entries = { | ||
"CMAKE_POSITION_INDEPENDENT_CODE": "ON", # Must be set! | ||
"BUILD_SHARED_LIBS": "OFF", | ||
# foonathan_memory specific options. | ||
"FOONATHAN_MEMORY_BUILD_EXAMPLES": "OFF", | ||
"FOONATHAN_MEMORY_BUILD_TESTS": "OFF", | ||
} | ||
|
||
cmake( | ||
name = "foonathan_memory", | ||
build_args = [ | ||
"--", | ||
"-j4", | ||
], | ||
cache_entries = cache_entries, | ||
lib_source = ":all_srcs", | ||
out_static_libs = ["libfoonathan_memory-0.7.3.a"], | ||
visibility = ["//visibility:public"], | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
index 0b82f0b..50c1bb9 100644 | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -13,9 +13,6 @@ set(FOONATHAN_MEMORY_VERSION "${FOONATHAN_MEMORY_VERSION_MAJOR}.${FOONATHAN_MEMO | ||
CACHE STRING "version of memory" FORCE) | ||
|
||
|
||
-# set a debug postfix | ||
-set(CMAKE_DEBUG_POSTFIX "-dbg") | ||
- | ||
# installation destinations | ||
if(UNIX OR VXWORKS) | ||
include(GNUInstallDirs) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
diff --git a/rmw_fastrtps_dynamic_cpp/src/type_support_common.cpp b/rmw_fastrtps_dynamic_cpp/src/type_support_common.cpp | ||
index d602069..62e4362 100644 | ||
--- a/rmw_fastrtps_dynamic_cpp/src/type_support_common.cpp | ||
+++ b/rmw_fastrtps_dynamic_cpp/src/type_support_common.cpp | ||
@@ -25,12 +25,13 @@ | ||
bool | ||
using_introspection_c_typesupport(const char * typesupport_identifier) | ||
{ | ||
- return typesupport_identifier == rosidl_typesupport_introspection_c__identifier; | ||
+ return !std::string(typesupport_identifier) | ||
+ .compare(rosidl_typesupport_introspection_c__identifier); | ||
} | ||
|
||
bool | ||
using_introspection_cpp_typesupport(const char * typesupport_identifier) | ||
{ | ||
- return typesupport_identifier == | ||
- rosidl_typesupport_introspection_cpp::typesupport_identifier; | ||
+ return !std::string(typesupport_identifier) | ||
+ .compare(rosidl_typesupport_introspection_cpp::typesupport_identifier); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
""" Builds rmw_fastrtps. | ||
""" | ||
|
||
load( | ||
"@com_github_mvukov_rules_ros2//ros2:cc_defs.bzl", | ||
"ros2_cpp_binary", | ||
"ros2_cpp_library", | ||
) | ||
|
||
ros2_cpp_library( | ||
name = "rmw_fastrtps_shared_cpp", | ||
srcs = glob([ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. I think header files in |
||
"rmw_fastrtps_shared_cpp/src/*.cpp", | ||
"rmw_fastrtps_shared_cpp/src/**/*.hpp", | ||
]), | ||
hdrs = glob([ | ||
"rmw_fastrtps_shared_cpp/include/**/*.h", | ||
"rmw_fastrtps_shared_cpp/include/**/*.hpp", | ||
]), | ||
includes = ["rmw_fastrtps_shared_cpp/include"], | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
"@fastrtps", | ||
"@ros2_rcpputils//:rcpputils", | ||
"@ros2_rcutils//:rcutils", | ||
"@ros2_rmw//:rmw", | ||
"@ros2_rmw//:rmw_cpp", | ||
"@ros2_rmw_dds_common//:rmw_dds_common_lib", | ||
"@ros2_rosidl//:rosidl_runtime_c", | ||
"@ros2_rosidl//:rosidl_typesupport_introspection_c", | ||
"@ros2_rosidl//:rosidl_typesupport_introspection_cpp", | ||
"@ros2_tracing//:tracetools", | ||
], | ||
) | ||
|
||
ros2_cpp_binary( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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:
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 commentThe 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! |
||
name = "rmw_fastrtps_dynamic_cpp", | ||
srcs = glob([ | ||
"rmw_fastrtps_dynamic_cpp/include/**/*.h", | ||
"rmw_fastrtps_dynamic_cpp/include/**/*.hpp", | ||
"rmw_fastrtps_dynamic_cpp/src/*.cpp", | ||
"rmw_fastrtps_dynamic_cpp/src/*.hpp", | ||
]), | ||
copts = ["-fvisibility=hidden"], | ||
includes = ["rmw_fastrtps_dynamic_cpp/include"], | ||
linkopts = ["-fvisibility=hidden"], | ||
linkshared = True, | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
":rmw_fastrtps_shared_cpp", | ||
"@ros2_rosidl_typesupport_fastrtps//:rosidl_typesupport_fastrtps_c", | ||
"@ros2_rosidl_typesupport_fastrtps//:rosidl_typesupport_fastrtps_cpp", | ||
mvukov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
], | ||
) |
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
tochar*
?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.)