RobotecAI / ros2-for-unity

High-performance ROS2 solution for Unity3D
Apache License 2.0
446 stars 58 forks source link

Connection problem between ROS2 in WSL2 and Unity in Windows(In ros2-for-unity) #107

Open sdyby2006 opened 3 months ago

sdyby2006 commented 3 months ago

Hello! Thank you for your outstanding work.

I am trying to build a system, which includes using ROS2 robots and some of its tools.

However, I don't want to install ROS2 on Windows, as it doesn't meet my actual needs, so I installed ROS2 in WSL2 and have modified the system to RMW=rmw_cyclonedds_cppROS_DOMAIN_ID=42.

On Windows, I have installed Unity and used the standalone version of R2FU, and through the system environment, I have modified the system to RMW=rmw_cyclonedds_cpp, ROS_DOMAIN_ID=42.

But when the Unity project is running, it can't connect to the ROS2 system in WSL2.

I'm sorry, I don't know if there is any special instruction or setting to enable it.

I don't know where to write this request, so I decided to write it as a question.

Thank you for your help.

s-m-asjad commented 2 months ago

This is not a problem with Unity - WSL2. Apparently, if one installs ROS2 on Windows and WSL2 on the same machine, the two are not able to communicate. This has something to do with the communication/firewall settings of WSL2 and windows.

The best you may achieve is seeing topic names being listed on WSL2 when you run a node on Windows but nothing more.

I had to install husarnet on both my Windows and WSL2 system to get around this issue. I also had a standalone build in Unity of R2FU for unrelated reasons, and the only way ROS2 nodes in Unity were able to talk to the ROS2 nodes in WSL2/any other machine was via husarnet.

P.S. I am not sure if it works without an explicit installation of ROS2 on Windows as well but you can give it a try since you now know that there is a limitation outside of Unity :smile:

Edit: fixing grammar