eclipse-zenoh / zenoh-plugin-ros1

Other
15 stars 9 forks source link

[Bug] ROS subscribers not automatically bridged despite subscriber_bridging_mode="auto" #92

Open AnneCK0 opened 1 week ago

AnneCK0 commented 1 week ago

Describe the bug

I am using the Docker image eclipse/zenoh-bridge-ros1:latest, started with the docker-compose service:

ros1-zenoh-bridge:
    image: eclipse/zenoh-bridge-ros1:latest
    init: true
    network_mode: host    
    environment:
      ROS_IP: localhost
      ROS_MASTER_URI: "http://localhost:11311"
      ROS_DISTRO: noetic 

I have another 'subscriber' Docker container where a ROS subscriber to the topic /chatter is active. This container is also configured in network_mode: host

Lastly, I have a third 'publisher' Docker container where a ROS publisher to the topic /chatter is active. Also with network_mode: host.

The problem that I encountered, is that the ros1-zenoh-bridge only bridges the topic /chatter, when the publisher is actively sending messages. If I do not start this publisher container, the topic /chatter is not bridged despite the subscriber in the subscriber container being active.

I would expect that the topic would be bridged, because of the default configuration subscriber_bridging_mode="auto", which states: "bridge topics once they are declared locally or discovered remotely."

I need this for a usecase where I'm making a bridge between Docker containers where one container has ROS1 installed, and the other one does not. Currently, thanks to your bridge I can read (in bare python code) the messages that are sent by a ROS1 publisher, but I cannot yet send messages (from bare python code) to a ROS1 subscriber since the topic seems not to get bridged without having a publisher on the topic.

To reproduce

  1. Start a ROS subscriber to topic /chatter in a ROS container, configured with network_mode: host
  2. Start ros1-zenoh-bridge container with
    ros1-zenoh-bridge:
        image: eclipse/zenoh-bridge-ros1:latest
        init: true
        network_mode: host    
        environment:
          ROS_IP: localhost
          ROS_MASTER_URI: "http://localhost:11311"
          ROS_DISTRO: noetic 

System info

AnneCK0 commented 1 week ago

Also, something similar happens when running your example.

If I run your whole example, it works. It also works if I run everything except for the rostopic echo (bottom right terminal in your example), since the logging of the bridge then says that that both ROS1 -> Zenoh and Zenoh -> ROS1 bridges are made for /topic.

However, If I run everything except for the rostopic pub (bottom left terminal in your example), then these bridges are no longer made.

AnneCK0 commented 1 week ago

I stand corrected: running the full example when using the docker containers does not work. On the 'rostopic echo /topic' side, there is a publisher node /ros1_to_zenoh_bridge, but the message test_message is not actually received. The used compose file for a reproducible example:

version: "3.3"

services:

  ros1-zenoh-bridge1:
    image: eclipse/zenoh-bridge-ros1:latest
    init: true
    network_mode: host    
    environment:
      ROS_IP: localhost
      ROS_MASTER_URI: "http://localhost:10000"
      ROS_DISTRO: noetic  

  ros1-zenoh-bridge2:
    image: eclipse/zenoh-bridge-ros1:latest
    init: true
    network_mode: host    
    environment:
      ROS_IP: localhost
      ROS_MASTER_URI: "http://localhost:10001"
      ROS_DISTRO: noetic 

  rosmaster1:
    init: true
    image: ros:noetic
    command: rosmaster -p 10001
    network_mode: host

  rosmaster2:
    init: true
    image: ros:noetic
    command: rosmaster -p 10000
    network_mode: host

  # ### ROS listener ###
  ros1-listener:
    init: true
    image: ros:noetic
    command: rostopic echo /topic
    network_mode: host 
    depends_on:
      - rosmaster2
    environment:
      ROS_MASTER_URI: http://localhost:10001

  ### ROS publisher ###
  ros1-talker:
    init: true
    image: ros:noetic
    command: rostopic pub /topic std_msgs/String -r 1 test_message
    network_mode: host 
    depends_on:
      - rosmaster1
    environment:
      ROS_MASTER_URI: http://localhost:10000