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
fix(LibCarla/ros2): address review comments and fix CycloneDDS runtime availability
Fix 5 issues flagged in the PR review and one structural CMake bug that caused
--dds-middleware=cyclonedds to fail at runtime.
Review fixes
- FastDDSPublisherMiddleware: use current_count instead of total_count in
on_publication_matched. total_count is cumulative and only grows, so
_alive latched true permanently after the first match (DDS v1.4 §2.2.4.5).
- FastDDSSubscriberMiddleware: same fix in on_subscription_matched.
- cmake/cyclone_dds: remove CARLA_ROS2_DDS_FASTDDS from the CycloneDDS
target compile definitions; each vendor lib should define only its own macro.
- cmake/fast_dds: remove CARLA_ROS2_DDS_CYCLONEDDS from the FastDDS
target compile definitions (same reason).
- cmake/fast_dds: fix source glob that mistakenly included
dds/cyclonedds/*.cpp instead of dds/fastdds/*.cpp.
CMake restructure (root cause: CycloneDDS unavailable at runtime)
Removing the cross-defines exposed a deeper problem: the shared ros2 sources
(ROS2.cpp, all publishers/subscribers/types) were compiled into both
carla_fastdds.a and carla_cyclonedds.a, each copy with only one middleware
macro defined. The linker picks one copy at final link; whichever archive is
scanned first wins all those symbols. The winning copy's #if defined guards
then make the other middleware invisible at runtime:
ERROR: ROS2: middleware 'CycloneDDS' is not compiled into this binary.
Fix: introduce cmake/ros2/CMakeLists.txt, which compiles ALL ros2 code once
with both CARLA_ROS2_DDS_FASTDDS and CARLA_ROS2_DDS_CYCLONEDDS defined,
including dds/cyclonedds/CycloneDDSSertype.cpp (already guarded internally
by #ifdef CARLA_ROS2_DDS_CYCLONEDDS). Both fast_dds and cyclone_dds become
install-only subprojects (vendor headers and vendor .a files, no library
targets). Carla.Build.cs links carla_ros2 for all compiled ros2 code, plus
the vendor runtime archives (libddsc.a, libfastcdr.a, libfastrtps.a,
libfoonathan_memory-0.7.3.a) unchanged.
Final CMake layout:
cmake/ros2/ -> libcarla_ros2.a (all ros2 code, both macros)
cmake/fast_dds/ -> install-only (FastDDS headers + vendor .a)
cmake/cyclone_dds/ -> install-only (CycloneDDS headers + vendor .a)
0 commit comments