feat(LibCarla, Carla): add Zenoh ROS2 middleware - #9735
Conversation
JArmandoAnaya
left a comment
There was a problem hiding this comment.
I added one very small suggestion.
There was a problem hiding this comment.
The PR adds --rmw=zenohz support to CARLA but the companion PythonAPI/examples/ros2/Dockerfile only handles rmw_fastrtps_cpp and rmw_cyclonedds_cpp.
It should be extended to install ros-${ROS_DISTRO}-rmw-zenoh-cpp when RMW_IMPLEMENTATION=rmw_zenoh_cpp is passed
I've tested this end-to-end on the feat/zenoh-ros2-middleware branch on Ubuntu 24.04.
The implementation is clean.
Great addition.
|
@LuisPovedaCano It would be great to add this update to the project's Docker script so we can test Zenoh features in the future. |
Install ros-${ROS_DISTRO}-rmw-zenoh-cpp in the Dockerfile when selected
and accept --rmw=zenoh in run_rviz.sh, mirroring the --rmw=zenoh support
added to the CARLA server. Addresses post-approval review feedback.
|
Thanks for the reviews! Added Zenoh support to the ROS2 example as suggested by @JArmandoAnaya and @LuisPovedaCano:
|
|
Thanks again @JArmandoAnaya @LuisPovedaCano ! |
|
Hello @habby1012, Thank you for the commit. I'll test this locally as soon as possible. I will let you know my review. |
|
@JArmandoAnaya, Sure, thanks! |
|
I wasn't able to run the example. The topics are published but not subscribed. Enabling the logs with debug it appeared this: so changing in inline std::string zenoh_make_topic_keyexpr(
const std::string& domain,
const std::string& topic_no_rt,
const char* type_name,
const char* type_hash)
{
return domain + "/" + topic_no_rt + "/" + type_name + "/" + type_hash;
}to: inline std::string zenoh_make_topic_keyexpr(
const std::string& domain,
const std::string& topic_no_rt,
const char* type_name,
const char* /* type_hash */)
{
return domain + "/" + topic_no_rt + "/" + type_name + "/TypeHashNotSupported";
}Has worked for me, now I can subscribe to the topics. Were you able to get it to work with RViz displaying the images without having to make this change? The steps I followed to run the example are:
For DDS implementations, the step 1 was not required. |
|
Hi @LuisPovedaCano, sorry this one tripped you up on humble, and thanks a lot for digging into it. Even finding a workaround really helped me pin it down. Humble doesn't subscribe because CARLA publishes each topic with its real RIHS01 type hash. On jazzy and rolling, rmw_zenoh builds the subscriber key expression with that same hash, so they line up. Humble's rmw_zenoh doesn't do type hashes, so it always uses TypeHashNotSupported, which never matches CARLA's RIHS01_.... That's the Subscription count: 0 you saw. (and why it worked for me, I was on jazzy). Forcing TypeHashNotSupported fixes humble but would break jazzy/rolling, so instead I just wildcarded the hash part of the key expression (.../* instead of .../<hash>), which matches both. RViz shows everything on humble and jazzy now. I also added one step to the example README, which is starting rmw_zenohd. Thanks again, really appreciate the careful review! Pushed both changes whenever you get a chance to look. |
|
@habby1012 Really nice work, thanks a lot! Do you also plan to add Zenoh in the CARLA UE5 Version? I guess this would also he helpful for many other users. |
|
Hello @cgeller 👋, yes, it is the idea. We are in the middle of a porting process to pull all existing ROS2 improvements from the UE4 branch into UE5. But since this process also requires closing a current gap between the two sides about some previous ROS2 features missing in UE5 before merging the ROS2 middleware decoupling that exists now in UE4. I hope we can finish that in the next few weeks. |
Description
Adds Zenoh as a third ROS 2 middleware backend on top of the existing abstraction. Users select it at runtime via
--rmw=zenoh, alongside--rmw=fastddsand--rmw=cyclonedds.New Zenoh middleware —
LibCarla/source/carla/ros2/middleware/zenoh/:ZenohSharedSession— opens a process-wide Zenoh session on first use and declares thecarla_bridgenode so rmw_zenoh peers see it. Defaults to connecting attcp/localhost:7447, and it can be overridden viaZENOH_SESSION_CONFIG_URIorZENOH_CONFIG_OVERRIDE.ZenohWireFormat— small helpers that build the keyexpr, liveliness token string, and per-message attachment in the format rmw_zenoh expects.ZenohPublisherMiddleware/ZenohSubscriberMiddleware— implement the existingIPublisherMiddleware/ISubscriberMiddlewareinterfaces. CDR serialization is shared with the FastDDS / CycloneDDS paths.Wire it into the factory:
Middleware.h,MiddlewareFactory.h— add aZenohenum value and a factory branch that constructsZenohPublisherMiddleware/ZenohSubscriberMiddlewarewhenCARLA_ROS2_MIDDLEWARE_ZENOHis defined.LibCarla/cmake/CMakeLists.txt,cmake/ros2/CMakeLists.txt,cmake/zenoh/CMakeLists.txt(new) — compile zenoh sources intocarla_ros2and install zenoh headers +libzenohc.ato the LibCarla dependencies dir.Build & runtime selection:
Util/BuildTools/Setup.sh— download prebuilt zenoh-c 1.8.0 andstrip --strip-debugthe static library.Carla.Build.cs— defineCARLA_ROS2_MIDDLEWARE_ZENOHand linklibzenohc.ainto the UE4 plugin.CarlaSettings.h— acceptzenohas a value for--rmw=.Tests —
test_ros2_middleware.cpp: mirror the existing fastdds / cyclonedds cases for zenoh (to/from string, availability check, factory get/set, factory create-when-unavailable).Where has this been tested?
Tests run:
make LibCarla ARGS="--ros2": passed.make check.LibCarla ARGS="--ros2": 406 / 406 pass across all four configs (server release 137, client release 66, server debug 137, client debug 66).make launch ARGS="--ros2 --rmw=fastdds"thenpython -m nose2 -v smoke.test_ros2: 5 / 5 pass in 39.1 s.make launch ARGS="--ros2 --rmw=cyclonedds"thenpython -m nose2 -v smoke.test_ros2: 5 / 5 pass in 38.4 s.make launch ARGS="--ros2 --rmw=zenoh"thenpython -m nose2 -v smoke.test_ros2: 5 / 5 pass in 38.6 s.Possible Drawbacks
make setup --ros2.--rmw=fastdds/--rmw=cycloneddspaths; existing behavior preserved.This change is