Skip to content

Support bridge namespaces #225

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Feb 26, 2025

Conversation

aaronchongth
Copy link
Contributor

@aaronchongth aaronchongth commented Jan 14, 2025

  • Add bridge namespace into Zenoh key in the form of {data_type}/{md5}/{bridge_namespace}/{topic}
  • Add to args and config, with default bridge namespace being the wildcard "*", representing handling topics across all bridge namespaces

I opted to use the environment variable for retrieving the namespace to prevent breaking API.

Testing

Using the README's quick test as examples,

Both default global namespaces works,

# build the bridge from source
cargo build -p zenoh-bridge-ros1
cd target/debug/
# terminal 1:
./zenoh-bridge-ros1 --with_rosmaster true --ros_master_uri http://localhost:10000
# terminal 2:
./zenoh-bridge-ros1 --with_rosmaster true --ros_master_uri http://localhost:10001
# terminal 3:
ROS_MASTER_URI=http://localhost:10000 rostopic pub /topic std_msgs/String -r 1 test_message
# terminal 4:
ROS_MASTER_URI=http://localhost:10001 rostopic echo /topic

Publish on global namespace, listen on bridge namespace test_ns, works

# build the bridge from source
cargo build -p zenoh-bridge-ros1
cd target/debug/
# terminal 1:
./zenoh-bridge-ros1 --with_rosmaster true --ros_master_uri http://localhost:10000
# terminal 2:
./zenoh-bridge-ros1 --with_rosmaster true --ros_master_uri http://localhost:10001 --bridge_namespace test_ns
# terminal 3:
ROS_MASTER_URI=http://localhost:10000 rostopic pub /topic std_msgs/String -r 1 test_message
# terminal 4:
ROS_MASTER_URI=http://localhost:10001 rostopic echo /topic

Publish on bridge namespace test_ns, listen on global namespace, works

# build the bridge from source
cargo build -p zenoh-bridge-ros1
cd target/debug/
# terminal 1:
./zenoh-bridge-ros1 --with_rosmaster true --ros_master_uri http://localhost:10000 --bridge_namespace test_ns
# terminal 2:
./zenoh-bridge-ros1 --with_rosmaster true --ros_master_uri http://localhost:10001
# terminal 3:
ROS_MASTER_URI=http://localhost:10000 rostopic pub /topic std_msgs/String -r 1 test_message
# terminal 4:
ROS_MASTER_URI=http://localhost:10001 rostopic echo /topic

Publish on bridge namespace test_ns, listen on bridge namespace test_ns, works

# build the bridge from source
cargo build -p zenoh-bridge-ros1
cd target/debug/
# terminal 1:
./zenoh-bridge-ros1 --with_rosmaster true --ros_master_uri http://localhost:10000 --bridge_namespace test_ns
# terminal 2:
./zenoh-bridge-ros1 --with_rosmaster true --ros_master_uri http://localhost:10001 --bridge_namespace test_ns
# terminal 3:
ROS_MASTER_URI=http://localhost:10000 rostopic pub /topic std_msgs/String -r 1 test_message
# terminal 4:
ROS_MASTER_URI=http://localhost:10001 rostopic echo /topic

Publish on bridge namespace test_ns1, listen on bridge namespace test_ns2, will not work

# build the bridge from source
cargo build -p zenoh-bridge-ros1
cd target/debug/
# terminal 1:
./zenoh-bridge-ros1 --with_rosmaster true --ros_master_uri http://localhost:10000 --bridge_namespace test_ns1
# terminal 2:
./zenoh-bridge-ros1 --with_rosmaster true --ros_master_uri http://localhost:10001 --bridge_namespace test_ns2
# terminal 3:
ROS_MASTER_URI=http://localhost:10000 rostopic pub /topic std_msgs/String -r 1 test_message
# terminal 4:
ROS_MASTER_URI=http://localhost:10001 rostopic echo /topic

Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
… namespaces

Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
Copy link

PR missing one of the required labels: {'internal', 'breaking-change', 'new feature', 'documentation', 'enhancement', 'dependencies', 'bug'}

Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
Copy link

PR missing one of the required labels: {'bug', 'documentation', 'new feature', 'internal', 'breaking-change', 'enhancement', 'dependencies'}

@JEnoch JEnoch added the enhancement New feature or request label Jan 14, 2025
@JEnoch
Copy link
Member

JEnoch commented Jan 24, 2025

It works as described and looks good to me.

Just a clarification please:
Is the "*" global namespace you refer is something different than the ROS global namespace which is "/" ?

Otherwise, I think using a relative topic name becomes confusing. See:

# terminal 1 - bridge with namespace:
./zenoh-bridge-ros1 --with_rosmaster true --ros_master_uri http://localhost:10000 --bridge_namespace test_ns
# terminal 2 - bridge without namespace:
./zenoh-bridge-ros1 --with_rosmaster true --ros_master_uri http://localhost:10001
# terminal 3 - publish on relative topic:
ROS_MASTER_URI=http://localhost:10000 rostopic pub topic std_msgs/String -r 1 test_message
# terminal 4 - topiclist doesn't show the namespace added by remote bridge:
ROS_MASTER_URI=http://localhost:10001 rostopic list
# Output: /topic - I would have expected /test_ns/topic
/topic

@aaronchongth
Copy link
Contributor Author

aaronchongth commented Feb 3, 2025

Hi @JEnoch! Sorry for the confusion, I meant using the wild card * as a namespace on the Zenoh key. I'll rephrase it in the description above to make it clearer.

In this example you provided, the first bridge on port 10000, will convert the ROS topic /topic into the Zenoh key {data_type}/{md5}/test_ns/topic.

While the second bridge on port 10001, using the wild card * as a bridge namespace, will convert the Zenoh key {data_type}/{md5}/*/topic into the ROS topic /topic, therefore picking up the messages published from the first bridge on zenoh key {data_type}/{md5}/test_ns/topic

edit: updated the help string and default config too, 695a04f, to not use the word wildcard instead of global

…ace as wildcard

Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
@JEnoch
Copy link
Member

JEnoch commented Feb 26, 2025

Hi @aaronchongth,
Thanks for the update and clarification! And sorry for the delay reviewing it...
This looks good to me now.

@JEnoch JEnoch merged commit 3d90897 into eclipse-zenoh:main Feb 26, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants