Can't publish any message from machine running Ubuntu WSL to my robot

asked 2023-05-16 09:45:58 -0500

updated 2023-05-17 05:43:49 -0500

Hi ;), i have a problem with my setup. As described in the title i am unable to publish any message from my machine with Ubuntu 20.04 installed on WSL 2 on windows 11 to an other machine running native Ubuntu 20.04. I did some tests using teleop and a dummy topic and while the subscriber node is found by the publisher (on WSL), the message doesn't arrive.

In the case of teleop_twist_keyboard,by running rosnode list in the WSL machine it finds the subscriber node.

By running rostopic info /cmd_vel I get:

Publishers:
   /teleop_twist_keyboard (http://172.27.4.159:40755) <-- IP of WSl machine
Subscribers:
   /rostopic _56247... (http://192.168.118.61:44663)  <-- IP of Ubuntu machine

But now if I run teleop_twist_keyboard it says waiting for subscribers...

I did the standard multi machine setup by exporting the variables ROS_IP and ROS_MASTER_URI on both machines. I am using ROS noetic

edit retag flag offensive close merge delete

Comments

Can you ping the IP-addresses from both direction?

Andromeda gravatar image Andromeda  ( 2023-05-17 02:32:28 -0500 )edit

WSL 2 uses NAT by default AFAIK. This will not work with ROS, as nodes on the other machine (ie: native install) will not be able to connect to nodes running "inside" your WSL install.

This is the same situation as trying to connect ROS nodes with a NAT router in between them (a simple residential internet gateway fi, like your ISPs router). Going from 'behind' the NAT to the other side typically works, trying to reach anything behind the NAT/router will not work without additional configuration.

WSL 2 has the same problem, and that's probably what you're running into.

See threads like Connecting to WSL2 server via local network [closed] this on SO for more discussion. The ROS nodes "inside" WSL are basically servers, and your other ROS nodes are clients in this setup.

All-in-all, this is not a ROS problem, but a networking one. Additionally ...(more)

gvdhoorn gravatar image gvdhoorn  ( 2023-05-17 02:46:04 -0500 )edit

Also: I'm sorry to have to do this for something seemingly minor, but please don't post screenshots of terminal text or source code in question on ROS Answers. It's all text, so there is no need. Just copy-paste the text from the terminal or the source into your question text. Do make sure to format it properly by selecting the text and pressing ctrl+k (or clicking the Preformatted Text button (the one with 101010 on it)).

You don't need to post a new question, just edit your curent one. You can use the edit button/link for this.

After you replace the screenshot with the error message itself, we can re-open your question.

gvdhoorn gravatar image gvdhoorn  ( 2023-05-17 02:48:23 -0500 )edit

Thank you for the answer, I'll check the provided link. I removed the images as requested, sorry for that

AlessioParmeggiani gravatar image AlessioParmeggiani  ( 2023-05-17 05:46:01 -0500 )edit

I removed the images as requested, sorry for that

no need to apologise. Thanks for updating your question.

gvdhoorn gravatar image gvdhoorn  ( 2023-05-17 05:48:14 -0500 )edit

@Andromeda Actually no, the ping does not work in both directions. Ping only works on WSL by pinging the machine with Ubuntu. Pinging the WSL machine from Ubuntu does not work

AlessioParmeggiani gravatar image AlessioParmeggiani  ( 2023-05-17 09:48:40 -0500 )edit