Skip to content

refactor(ros2): replace Fast DDS with rclcpp + rmw to support multiple middleware backends#9641

Draft
habby1012 wants to merge 2 commits intocarla-simulator:ue5-devfrom
habby1012:rclcpp-rmw
Draft

refactor(ros2): replace Fast DDS with rclcpp + rmw to support multiple middleware backends#9641
habby1012 wants to merge 2 commits intocarla-simulator:ue5-devfrom
habby1012:rclcpp-rmw

Conversation

@habby1012
Copy link
Copy Markdown

@habby1012 habby1012 commented Apr 2, 2026

Description
Draft PR — sharing early to get feedback before going further.

This replaces CARLA's direct Fast DDS usage with rclcpp + rmw, allowing users to switch ROS 2 middleware at runtime via the RMW_IMPLEMENTATION environment variable. Verified with rmw_zenoh, rmw_fastrtps, and rmw_cyclonedds on ue5-dev.

I know @JesusAnaya is working on a DDS-level abstraction (#9589). This explores an alternative approach by moving the abstraction to the rclcpp/rmw layer instead of the DDS layer. Both approaches have trade-offs.

Related: #9294, #9579, #9589

Why:
CARLA's ROS 2 integration is currently tied to Fast DDS. Many users (especially Autoware users) require CycloneDDS or Zenoh. This makes it possible to switch middleware without modifying CARLA code.

What's different from PR #9589:
PR #9589 abstracts at the DDS layer — each new backend requires its own publisher/subscriber implementation. This uses rclcpp + rmw instead:
Before: CARLA → Fast DDS API
After: CARLA → rclcpp → rmw → FastDDS / CycloneDDS / Zenoh / ...
Pros: no code changes required to support new backends, supports non-DDS middleware (e.g., Zenoh), simpler publisher and subscriber implementation.
Cons: larger build system changes, requires ROS 2 build tools at build time, adds ~10–15 minutes to the initial build.

Changes:

  • Ros2Native/CMakeLists.txt — rclcpp dependency chain replaces foonathan + Fast DDS. Adds rmw_zenoh_cpp, rmw_fastrtps_cpp, and rmw_cyclonedds_cpp backends. All compiled with UE5 clang.
  • Ros2Native/LibCarlaRos2Native/CMakeLists.txt — links rclcpp + ROS 2 message packages instead of libfastrtps
  • All publishers/subscribers rewritten from Fast DDS API to rclcpp
  • listeners/ removed — replaced with rclcpp callbacks
  • types/ removed — using standard ROS 2 message packages
  • Added Ros2Native/carla_msgs/ for CARLA-specific messages

Testing:
Basic sensors verified:
Clock, RGB/Depth/SS/IS/OpticalFlow/Normals cameras (image + camera_info), GNSS, IMU, Lidar, Semantic Lidar, Radar, Collision, Transform.

Backends tested:

  • rmw_zenoh_cpp ✓
  • rmw_fastrtps_cpp ✓
  • rmw_cyclonedds_cpp ✓
    Runtime switching via RMW_IMPLEMENTATION env var works.

About build dependencies:
Now requires ROS 2 Jazzy build tools (ament_cmake, rosidl generators) at build time. These are only used during compilation (CMake + Python) and do not introduce runtime .so dependencies into UE5. Still figuring out the best way to handle this. Options include automating in InstallPrerequisites.sh, vendoring the build tools, or building them from source in CMake.

Limitations:

  • ue5-dev only for now
  • Runtime requires environment variables (RMW_IMPLEMENTATION, AMENT_PREFIX_PATH, LD_LIBRARY_PATH) — planning to handle this with a launch script
  • Binary packaging not done yet
  • Subscriber (EgoVehicleControl) topic is created but external ros2 topic pub don't reach CARLA.

What's next:

  • Debug EgoVehicleControl subscriber
  • CMakeLists.txt cleanup and better documentation for the workarounds
  • Packaging and usability improvements (build prerequisites, runtime environment setup, binary/shipping build)

Where has this been tested?

  • Platform(s): Ubuntu 24.04
  • Python version(s): 3.12
  • Unreal Engine version(s): UE 5.5

This change is Reviewable

@update-docs
Copy link
Copy Markdown

update-docs Bot commented Apr 2, 2026

Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would update our CHANGELOG.md based on your changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant