Skip to content

refactor(LibCarla, Carla): rename DDS middleware abstraction to Middleware - #9711

Merged
LuisPovedaCano merged 4 commits into
carla-simulator:ue4-devfrom
habby1012:ue4-dev
May 12, 2026
Merged

refactor(LibCarla, Carla): rename DDS middleware abstraction to Middleware#9711
LuisPovedaCano merged 4 commits into
carla-simulator:ue4-devfrom
habby1012:ue4-dev

Conversation

@habby1012

@habby1012 habby1012 commented May 6, 2026

Copy link
Copy Markdown

Description

This PR drops the DDS prefix from the ROS 2 middleware abstraction layer:

  • Directory dds/middleware/
  • Interfaces IDDSPublisher/SubscriberMiddlewareIPublisher/ISubscriberMiddleware
  • Enum DDSMiddlewareMiddleware
  • Factory DDSMiddlewareFactoryMiddlewareFactory
  • Macros CARLA_ROS2_DDS_*CARLA_ROS2_MIDDLEWARE_*
  • UPROPERTY UCarlaSettings::DDSMiddlewareNameMiddlewareName
  • Test file test_dds_middleware.cpptest_middleware.cpp

I have read #9692. The DDS-prefixed names were kept on purpose, and future non-DDS RMWs (like Zenoh) are meant to live alongside DDS, not replace it.

However, when I looked at how a non-DDS RMW would actually fit in, I saw a problem in PublisherImpl.h (and the matching SubscriberImpl.h). The base publishers that use this template are already generic — they don't care which backend is used. But inside PublisherImpl<T>, the _middleware field is typed as IDDSPublisherMiddleware, which ties it to DDS.

So a non-DDS RMW has only two ways to fit in:

  • Make a copy of PublisherImpl<T> for its own family (e.g. ZenohPublisherImpl<T> holding an IZenohPublisherMiddleware), and update every high-level publisher (CarlaImagePublisher, CarlaLidarPublisher, …) to pick the right one. Same again for subscribers. That's a lot of duplication.
  • Have a class like ZenohPublisher inherit IDDSPublisherMiddleware directly. No duplication, but the name doesn't match — a Zenoh class implementing a DDS-named interface, and a DDSMiddleware enum that needs a Zenoh member.

Looking at IDDSPublisherMiddleware itself — its methods are Init, Publish, IsAlive, GetTopicName — none of these are DDS-specific; they describe what any publisher needs to do. So a third way is to drop the DDS prefix from IDDSPublisherMiddleware / IDDSSubscriberMiddleware (and the related enum / factory). A new family can then implement IPublisherMiddleware directly and reuse PublisherImpl<T> and the base publishers without changes. No code duplication, no name mismatch. To me this fits the "alongside" idea more naturally, and that's what this PR does.

For context, our next step is a separate PR adding a Zenoh implementation under middleware/zenoh/, alongside fastdds/ and cyclonedds/. This rename clears the way for ZenohPublisherMiddleware to inherit IPublisherMiddleware directly.

@JArmandoAnaya — since this builds on the DDS abstraction you have introduce, would appreciate your thoughts on the naming.

Where has this been tested?

  • Platform(s): Ubuntu 24.04
  • Python version(s): 3.12
  • Unreal Engine version(s): UE4.26

I have tested both build and launch locally — both work fine.


This change is Reviewable

@habby1012
habby1012 requested a review from a team as a code owner May 6, 2026 02:55
@JArmandoAnaya

JArmandoAnaya commented May 6, 2026

Copy link
Copy Markdown
Contributor

Hello! It could work. But in my opinion, some names are not explicit enough in context. You changed DDS to simply Middleware. DDS is a very specific context name, whereas Middleware is more generic and could refer to anything else, which could become confusing over time. For some elements like libcarla_carla_middleware_headers (not limited to this example; there are more), you can probably add the ROS2 name to the suffix or prefix, e.g., libcarla_carla_ros2_middleware_headers.

What is inside the folder carla/ros2 could be correct if you call it "Middleware", since it could implicitly include the ROS2 context. But all defined outside this path must be more explicit, for example, the changes defined inside the folder Unreal/CarlaUE4/Plugins/Carla/Source/Carla or LibCarla/source/test/.

Comment thread LibCarla/cmake/cyclone_dds/CMakeLists.txt Outdated
Comment thread LibCarla/cmake/cyclone_dds/CMakeLists.txt Outdated
Comment thread LibCarla/cmake/fast_dds/CMakeLists.txt Outdated
Comment thread LibCarla/cmake/fast_dds/CMakeLists.txt Outdated
Comment thread LibCarla/cmake/test/CMakeLists.txt Outdated
Comment thread Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Settings/CarlaSettings.h Outdated
Comment thread Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Settings/CarlaSettings.cpp Outdated
Comment thread Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Game/CarlaEngine.cpp Outdated
Comment thread Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Game/CarlaEngine.cpp Outdated
Comment thread Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Game/CarlaEngine.cpp Outdated
@JArmandoAnaya

JArmandoAnaya commented May 6, 2026

Copy link
Copy Markdown
Contributor

I added some inline code suggestions with the changes I think you should make to provide a clearer ROS2 context for this refactoring in the project.

You also should rename the file LibCarla/source/test/server/test_middleware.cpp to LibCarla/source/test/server/test_ros2_middleware.cpp.

And probably update the text description in the CHANGELOG.md.

@habby1012

Copy link
Copy Markdown
Author

Thanks @JArmandoAnaya, very helpful feedback! I have pushed new commit with all 10 suggestions applied, the file rename, and the CHANGELOG update.

Comment thread CHANGELOG.md Outdated
@habby1012

habby1012 commented May 11, 2026

Copy link
Copy Markdown
Author

Hi @LuisPovedaCano , this PR has been reviewed by @JArmandoAnaya . Could you help merge when you have a moment? Thanks!

@LuisPovedaCano LuisPovedaCano left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the clean rename.
I've left a requested change inline, please address it before merge.

Comment thread LibCarla/source/carla/ros2/middleware/Middleware.h Outdated
@LuisPovedaCano LuisPovedaCano self-assigned this May 11, 2026
@habby1012

Copy link
Copy Markdown
Author

The smoke test failure looks unrelated — it's a physics determinism test, and all ROS 2 tests passed. Could you re-run the failed CI? Thanks!

@JArmandoAnaya

Copy link
Copy Markdown
Contributor

I already tested locally on top of the current ue4-dev: built LibCarla --ros2 and ran the unit tests; packaged with --ros2; and manually verified the simulator end-to-end with both --rmw=fastdds and --rmw=cyclonedds using the PythonAPI/examples/ros2 scripts. ROS2 features remain stable; the rename does not affect runtime behavior. Ready to merge.

@LuisPovedaCano
LuisPovedaCano merged commit 17122b4 into carla-simulator:ue4-dev May 12, 2026
3 of 4 checks passed
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.

3 participants