Skip to content

Conversation

caguero
Copy link
Collaborator

@caguero caguero commented Oct 13, 2025

🎉 New feature

Closes #698

Summary

This patch adds the ability to load a Zenoh configuration file. The Zenoh router is also supported.

Right now, you can set the configuration file with two methods:

  1. Using the ZENOH_CONFIG environment variable. This is the option with the highest priority and we leverage zenoh::Config::from_env(), which looks for this environment variable. That's why we don't need to create a custom environment variable for it.

  2. Using the default configuration file under $HOME/.gz/transport/gz_zenoh_session.json5. The patch provides a default configuration file (it's actually this one from ROS RMW Zenoh) that it's installed. When gz-transport runs, the default config files are installed if they don't exist.

  3. If (1) isn't set and (2) failed, the default Zenoh configuration is used without any external file.

Note: The tests are expected to fail. See the Discussion section.

Test it

Follow these instructions to install the Zenoh router.

  1. In a separate terminal, run the router with the router configuration file (also included in this patch).
./zenohd -c /home/caguero/.gz/transport/gz_zenoh_router_config.json5
  1. Compile the examples, and in a separate terminal, run the publisher:
GZ_TRANSPORT_IMPLEMENTATION=zenoh ./publisher
  1. In a separate terminal, run the subscriber:
GZ_TRANSPORT_IMPLEMENTATION=zenoh ./subscriber

Discussion

  1. Testing strategy. Right now, the default configuration files are based on ROS RMW Zenoh, which requires the Zenoh router to be running and multicast is disabled. Then, for testing, we should run the Zenoh router (not done in this patch) and distribute it. Alternatively, we could provide a separate configuration file with multicast enabled and not needing the Zenoh router. Another variant could be that our default configuration file has multicast enabled and doesn't require the router.

  2. Order in which we look for the configuration file. Right now, the default configuration file is the last resort. We first check for an environment variable, and then, for the existence of the user configuration file. If we don't find the user config file, we install it. Unless something goes wrong, it's not possible to use a default configuration, we'll almost always load a config file. We could consider other alternatives:

    2.1 Default config first unless we explicitly set ZENOH_CONFIG.
    2.2 Default config unless we explicitly set ZENOH_CONFIG or a config file is present at the default location. We could decide not to install the user config ourselves.

  3. Installable user config file. This patch installs a new user config file if it's not present in the default location (~/.gz/transport). My main concern is how to disitribute new versions of this file once the users already have an existing config file in their systems.

I'm looking for some feedback on (1), (2) and (3).

I'm slightly leaning towards leaving this patch as it is but with the configuration file set with multicast enabled and not requiring the router. This way, the default experience is the same as right now, tests should work without extra work and users have an installed config file to play with and with the possibility of using the router if needed.

Checklist

  • Signed all commits for DCO
  • Added tests
  • Added example and/or tutorial
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • Consider updating Python bindings (if the library has them)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers
  • Was GenAI used to generate this PR? If so, make sure to add "Generated-by" to your commits. (See this policy for more info.)

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by and Generated-by messages.

Signed-off-by: Carlos Agüero <caguero@osrfoundation.org>
Signed-off-by: Carlos Agüero <caguero@osrfoundation.org>
Signed-off-by: Carlos Agüero <caguero@osrfoundation.org>
Signed-off-by: Carlos Agüero <caguero@osrfoundation.org>
Signed-off-by: Carlos Agüero <caguero@osrfoundation.org>
Signed-off-by: Carlos Agüero <caguero@osrfoundation.org>
Signed-off-by: Carlos Agüero <caguero@osrfoundation.org>
Signed-off-by: Carlos Agüero <caguero@osrfoundation.org>
Signed-off-by: Carlos Agüero <caguero@osrfoundation.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Inbox

Development

Successfully merging this pull request may close these issues.

1 participant