ROS2: Unable to send images using ros2 topics

Hi.

I am trying to send video from my webcam (approximately at 30 fps) to another device in the same network. Both devices are connected via husarnet.

I followed all the instructions available here - Using Husarnet & ROS 2 | Husarnet

I am also able to view the /chatter topic as given in the above tutorial. I am using FastDDS with the default configuration xml created by husarnet.

I ran the following commands-

PC1-
ros2 run image_tools cam2image

PC2-
ros2 run image_tools showimage

After going through the documentation of FastDDS available here - 15.3. Large Data Rates — Fast DDS 2.12.0 documentation, it seems we need to do some changes in the xml file.

Could you help in creating the new xml file?

PS- If I do not use husarnet and follow the above process by setting the same domain ID for both the PCs connected to the same network, I am able to clearly view the video on PC2.

Looking forward to your reply.

Hi @amit , please take a look at this example showing you how to use Husarnet in a ROS 2 system where robot is sending compressed camera images to the laptop: GitHub - husarion/rosbot-telepresence: Real-Time Internet Control and Video Streaming with ROSbot 2R / 2 PRO.

Please review all branches, because each of them presents how to achieve the same goal over Husarnet VPN, but with different setups.

Best,
Dominik

Hi @dominik ,

Thank you for your reply. I did test what was mentioned in the above GitHub repo. With that I am able to send compressed images. However, I am not able to send the raw images even when both the computers are on the same WiFi network.

To test the issue, I uninstalled husarnet, and sent the same image by connecting to the same router and setting the ROS_DOMAIN_ID parameter. It works flawlessly.

Could you guide where I am going wrong in using husarnet?

To give you context, I want to transfer the video and depth stream coming from a realsense depth camera. I had tried this in ROS1 using husarnet, and it worked flawlessly.

Hi @amit , have you tried tips from Useful tips section?

Especially this one:

sudo sysctl -w net.ipv6.ip6frag_time=3 # 3s
sudo sysctl -w net.ipv6.ip6frag_high_thresh=134217728 # (128 MB)

Best,
Dominik

Yes. After running this, I was able to view images received on compressed image topic. However raw images and depth stream are still not working.

Also, ifstat -i hnet0 command shows KB/s of out as 10,000+ .

@dominik Please let me know if you have any other resource for solving this.

@amit , have you tried reducing the size of the raw image? Also what htop shows where you are sending large raw images?

Yes. Reducing the image size and using compressed image works. However raw image or depth topic doesn’t.

htop shows this-

As mentioned before-

To test the issue, I uninstalled husarnet, and sent the same image by connecting to the same router and setting the ROS_DOMAIN_ID parameter. It works flawlessly.

How can this work with husarnet installed? Do I have to make any changes to XML?

@dominik Any update regarding this?

Hi @amit , maybe try with Husarnet and ROS 2 Router? Please take a look at one of our latest blog posts: ROS 2 Router for Remote Robotics and Topic Filtering | Husarnet

Hi Amit and Dominik, I met with almost the same issue. Small-size compressed jpeg image can be sent and received, however not possible for 1280p jpeg. Do you have any updates or possible solutions about it?

CHeers

It’s actually the DDS issue, the DDS is not actually meant for huge data over latency prone network like wifi. You may try zenoh dds it will help.

Let me know the updates too.

There are multiple DDS setups you can choose @rosconnectivity . Recently we have updated the tutorial covering that topic: Using Husarnet & ROS 2 | Husarnet

Please also check the Large Data mode in FastDDS: 15.1.2. Large Data with configuration options — Fast DDS 3.0.0 documentation

I believe I have followed your guidance correctly and it didn’t solve my problems. In my current configuration, I have two nodes on different networks successfully transmitting JPEG images with a resolution of 640x480. However, when I increase the resolution to 1280x720, the subscriber node fails to receive any images.

Following your suggestion, I added the following settings to my FastDDS configuration:: “1048576
4194304”. I am sure these parameters are below the system maximum value, however I still cannot receive images, even with higher buffer size. Have you tried to stream these 1280x720 resolution of images? Looking forward to your reply.

In my current configuration, I have two nodes on different networks successfully transmitting JPEG images with a resolution of 640x480. However, when I increase the resolution to 1280x720, the subscriber node fails to receive any images. I tried to increase buffer size but it didn’t solve my issue. I am not sure whether husarnet support zenoh since I never used it that way.

Please also take a look at these settings in the telepresence project for ROSbot XL mobile platform.

As you can see some system buffers for IPv4 and IPv6 are increased for sending video stream over Husarnet.

These settings are based on the DDS tunning guide for ROS 2

Hi Dominik,

I’ve looked into the repository, but I’m a bit confused about how to use Husarnet with my setup. In my configuration, I build my ROS2 Docker container alongside a Husarnet VPN sidecar image using Docker Compose. If I understand correctly, to apply certain system settings, you need to run these commands on the host machine:
"sudo sysctl -w net.core.wmem_max=12582912

  • sudo sysctl -w net.core.rmem_max=12582912*"

These sysctl settings cannot be directly applied within Docker, so they must be executed on the host machine. To ensure these settings are passed to the Docker container, you would typically use network_mode: host in your Docker Compose file.

However, since I’m using Husarnet, I would need to set network_mode: service:husarnet instead. This creates a conflict because the necessary system settings might not be passed through when using Husarnet’s network mode.

Could you please confirm if my understanding is correct? Have you tested this configuration, and if so, what solution did you find for applying these settings while using Husarnet? You response will be very helpful. I believe these kind of high resolution image stream transmission is very important for many potential husarnet users.

I mean, when using network_mode: service:husarnet, the container is not directly using the host’s network stack but instead relies on Husarnet’s virtual network service. so the sysctl settings are not applied to the docker.

Hi, in the provided ROSbot XL telepresence example, Husarnet is running directly on the host OS, so you need to run these

sudo sysctl -w net.core.wmem_max=12582912
...

commands directly in the host terminal.

It’s a good question whether to apply those setting to the Husarnet container (running withouth network_mode: host), we also need to run it directrly on the host OS level.

My guess is, we need to run it both on host OS and in compose.yaml.

In the typical configurations, like this one, Husarnet sidecar service looks like this:

  husarnet:
    image: husarnet/husarnet:2.0.180
    volumes:
      - /var/lib/husarnet
    sysctls:
      - net.ipv6.conf.all.disable_ipv6=0
    cap_add:
      - NET_ADMIN
    devices:
      - /dev/net/tun
    environment:
      - HOSTNAME=my-container
      - JOINCODE
      - HUSARNET_DEBUG=1

So maybe, to apply those settings to Husarnet container you need to do it like that:

  husarnet:
    image: husarnet/husarnet:2.0.180
    volumes:
      - /var/lib/husarnet
    sysctls:
      - net.ipv6.conf.all.disable_ipv6=0
      - net.ipv6.ip6frag_time=3
      - net.ipv6.ip6frag_high_thresh=134217728
      - net.core.wmem_max=12582912
      - net.core.rmem_max=12582912
      - net.core.wmem_default=16384000
      - net.core.rmem_default=16384000
    cap_add:
      - NET_ADMIN
    devices:
      - /dev/net/tun
    environment:
      - HOSTNAME=my-container
      - JOINCODE
      - HUSARNET_DEBUG=1

Currently I can’t test it, but maybe this is the right direction?

Best,
Dominik