Skip to content
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

No external controller connection(ROS2 on WLS to Webots on Windows) #759

Closed
Dan010123 opened this issue May 24, 2023 · 20 comments
Closed

No external controller connection(ROS2 on WLS to Webots on Windows) #759

Dan010123 opened this issue May 24, 2023 · 20 comments
Assignees

Comments

@Dan010123
Copy link

Describe the Bug
launched ROS2 Webot demos open Webots, show the world but stuck on waiting for extern controller connection on IPC or TCP which newer happens.

Steps to Reproduce

  1. Installed ROS2 + ros-humble-webots-ros2 on WSL Ubuntu 22.04
  2. Installed Webots on Windows10
  3. Configured workspace, sourced ROS, exported WEBOTS_HOME=/mnt/d/Programs/Webots
  4. Started (for example) ros2 launch webots_ros2_turtlebot robot_launch.py

Expected behavior
Simulation running

Screenshots
изображение
изображение

System

  • WIndows 10 + Ubuntu 22.04 on WSL

Additional context
I guess I should somehow get IPC or TCP configured, but can't find info on how to manage this....
Thanks!

@suresh-venkate
Copy link

suresh-venkate commented May 25, 2023

I am facing the same problem as well. Hope someone can help to resolve this issue. Same configuration as in the above message.

Thanks

@ygoumaz ygoumaz transferred this issue from cyberbotics/webots May 25, 2023
@ygoumaz ygoumaz self-assigned this May 25, 2023
@ygoumaz
Copy link
Contributor

ygoumaz commented May 25, 2023

I will take a look at your issue. It is possible that the package is somehow broken on Windows.

Could you just give me a few more details:

  • Have you built the ROS 2 package (webots_ros2) from sources or installed from apt binaries?
  • What version of the package are you using? You can execute the following command to get it: ros2 pkg xml webots_ros2 | grep version.

@suresh-venkate
Copy link

I will take a look at your issue. It is possible that the package is somehow broken on Windows.

Could you just give me a few more details:

  • Have you built the ROS 2 package (webots_ros2) from sources or installed from apt binaries?
  • What version of the package are you using? You can execute the following command to get it: ros2 pkg xml webots_ros2 | grep version.

In my case, I have installed from apt binaries using this command: 'sudo apt-get install ros-$ROS_DISTRO-webots-ros2'. (ROS_DISTRO is humble).

The package version that I see is ' 2023.0.3'

Thanks

@ygoumaz
Copy link
Contributor

ygoumaz commented May 25, 2023

I am not able to reproduce the issue. I tried the package from sources and apt binaries and both work in version 2023.0.3 in WSL (Humble). Could you please try to install it from sources by following these instructions: https://docs.ros.org/en/humble/Tutorials/Advanced/Simulators/Webots/Installation-Ubuntu.html. Remove the apt package to avoid conflicts. The current version of sources is 2023.0.4, which is released and should be synchronized with Humble and Iron very soon.

The weird part in the logs provided by @Dan010123, is that the driver and supervisor nodes are started but they don't produce any logs and don't crash. They should write messages like the following one:

[driver-4] The Webots simulation world is not ready yet, retrying for another 50 seconds...

Are there any other logs related to these nodes?

@suresh-venkate
Copy link

  • ros2 pkg xml webots_ros2 | grep version

I tried installing through source but still facing the same issue.

image

After I run the launch command, my Webots window opens up and the world gets loaded but I am not able to communicate with webots after that.

I tried running teleop on a new Ubuntu window but there is no response in Webots to any of the key presses.

image

@ygoumaz
Copy link
Contributor

ygoumaz commented May 25, 2023

Your controllers are started correctly, but there seems to be a problem preventing the extern controllers from connecting to the simulation.

When starting a controller node from the launch file, the WEBOTS_CONTROLLER_URL environment variable must be set to target the correct instance of Webots and the correct robot.

Now that you have the package installed from the sources, could you please open the launch file of any project (for example the epuck: ros2_ws/src/webots_ros2/webots_ros2_epuck/launch/robot_launch.py) and print the value of controller_url_prefix()? You can add the following line:

print(controller_url_prefix())

Could you also try to start the mavic example? It is even simpler than the epuck and turtlebot. This would allow to discard potential issues coming from other packages like ros_control.

@suresh-venkate
Copy link

I tried the mavic example. I am again unable to communicate with the webots window using teleop_twist_keyboard.

I see this now in the webots console.

image

Regarding the print statement, can you tell me where exactly in the robot_launch.py file, I need to add this command? Should I add it below the import statements at the top or inside one of the functions defined in the launch.py file?

@ygoumaz
Copy link
Contributor

ygoumaz commented May 26, 2023

You can add the following line anywhere in the get_ros2_nodes(*args) function.

print('prefix: ' + controller_url_prefix())

When running the launch file, you should get a line in the console with the prefix.

@suresh-venkate
Copy link

suresh-venkate commented May 26, 2023

This is the output on the console with the print statement included.

image

@ygoumaz
Copy link
Contributor

ygoumaz commented May 26, 2023

In all the logs you've provided, the counter doesn't go below 50 or 45 seconds. Can you confirm that it is still looking for the Webots instance?

According to the output of the prefix, the packet correctly detects the WSL environment and tries to connect via TCP connection. There may be a problem with the firewall somehow preventing the connection. You can check if the Webots instance is detected by WSL by following these steps:

  • Start Webots on the host.
  • Intall nmap in WSL:
sudo apt install nmap
  • In WSL, scan for open ports:
nmap 172.18.112.1 -Pn

Is the 1234 port detected?

In addition, you can also try the following command to test the TCP connection (with Webots still open):

telnet 172.18.112.1 1234

@Dan010123
Copy link
Author

Dan010123 commented May 26, 2023

For me the prefix was tcp://172.18.224.1:1234/
Independent whether Webots is running or not, the port 1234 isn't opened with all firewalls being off
With nmap 172.18.224.1 -Pn I have only
PORT STATE SERVICE
1042/tcp open afrog
1043/tcp open boinc
The :1234 is opened in Windows, according to the netstat, so Webots is listening.
Maybe :1234 is somehow blocked in WSL/Ubuntu?

Later: made New-NetFirewallRule -DisplayName "WSL2 Port Bridge" -Direction Inbound -Action Allow -Protocol TCP -LocalPort 1234
to allow :1234 in Powershell

now nmap in WSL/Ubuntu shows
PORT STATE SERVICE
1042/tcp open afrog
1043/tcp open boinc
1234/tcp open hotline

and got after trying to launch a package from WSL-ROS2

[driver-2] Error: Unknown Webots response
d.
[ERROR] [driver-2]: process has died [pid 12684, exit code 1, cmd '/opt/ros/humble/lib/webots_ros2_driver/driver --ros-args --params-file /tmp/launch_params_ohsh86ip']

Webots started, but still INFO: 'my_robot' extern controller: waiting for connection on ipc://1234/my_robot or on tcp://<ip_address>:1234/my_robot

next time I got response
prefix: tcp://172.18.224.1:1234/
[INFO] [webots-1]: process started with pid [12812]
[INFO] [driver-2]: process started with pid [12814]
[driver-2] Error: Unknown Webots response �.
[ERROR] [driver-2]: process has died [pid 12814, exit code 1, cmd '/opt/ros/humble/lib/webots_ros2_driver/driver --ros-args --params-file /tmp/launch_params_0691d1en'].
[INFO] [webots-1]: process has finished cleanly [pid 12812]
[ERROR] [launch]: Caught exception in launch (see debug for traceback): [Errno 1] Operation not permitted: '/tmp/.tmp7br1zc5i_world_with_URDF_robot.wbproj'
[ERROR] [launch]: Caught exception in launch (see debug for traceback): [Errno 1] Operation not permitted: '/tmp/.tmp7br1zc5i_world_with_URDF_robot.wbproj'

And later: removed Humble totally
reinstalled ROS2 Iron
and ros-iron-webots-ros2

all the same with Epuck robot:
.....
[ros2_supervisor.py-2] Error: Unknown Webots response ��;c�.
[driver-18] Error: Unknown Webots response rN;W�.
[ERROR] ....

I'm at a loss.... Don't know what to try else

@Dan010123
Copy link
Author

Dan010123 commented May 28, 2023

Seems I've found the reason.

  1. in Windows Defender Firewall I allowed all inbound connections on UDP/TCP to D:\programs\webots\msys64\mingw64\bin\webots-bin.exe (source folder for Webots is D:/Programs/ in my case)

  2. in cmd(or Pwrshell) with adm privileges
    netstat -ab
    showed that port 1234 was used even when Webots was not running (in my case - by iphlpsvc)
    netsh interface portproxy show all
    showed that 1234 was used namely by netsh
    netsh interface portproxy delete v4tov4 listenport=1234 listenaddress=0.0.0.0
    removed netsh from 1234

  3. now netstat -ab shows the port 1234 is not used

  4. start the Webot, netstat -ab to make sure that 1234 is used only by webots-bin.exe

  5. with Webots running, from terminal in WSL Ubuntu telnet 172.18.224.1 1234 (172.18... - the ip of Ethernet adapter vEthernet (WSL), the one that was returned by "prefix" from Launch.py) - it should connect

  6. if not - the Firewall settings should be checked, for example,

изображение

may be vEthernet(WSL) should be checked-off according to the shown

@michaelperino
Copy link

I fought this issue for a while and it was windows firewall on my end. When you have the firewall popup and click "allow for private networks", it creates a matching rule which blocks for public networks. Disabling the matching block for public networks and extending the original inbound rule to work for both private and public networks was the solution for me.

@ygoumaz
Copy link
Contributor

ygoumaz commented May 31, 2023

It indeed seems to be a firewall issue. @Dan010123, were you able to launch your webots_ros2 examples after your fix? If so, I think it would be great to open a new post on https://robotics.stackexchange.com/ with the webots and ros2 tags. I think there is a way to post a Q&A style question where you can provide the question and the answer at the same time. This could then be used as a reference for future users who encounter this problem.

@cyberbotics cyberbotics deleted a comment from best-pureer Jun 13, 2023
@ygoumaz
Copy link
Contributor

ygoumaz commented Jul 26, 2023

@Dan010123, @suresh-venkate, any updates on this issue? Are you able to run demos now? If not feel free to reopen the issue.

@ygoumaz ygoumaz closed this as completed Jul 26, 2023
@nanjo712
Copy link

hey, I meet the same problem in webots R2023b with Ubuntu 22.04 on WSL 2.0.11.
It seems that the latest WSL has the same network enviroment as the Host. But my ROS humble still cannot connect to Webots instance.

@nanjo712
Copy link

image
if I use NAT mode in WSL ,it will start to listen on port 1234. But ROS still cannot connect to webots.
If I use mirrored mode in WSL, it will tell me that it cannot open the port 1234 , using 1235 instead.

@maze-debug
Copy link

@nanjo712 hi i have the same issue has you and can't find any solution did you succeed to fix the problem ?

@cjmess01
Copy link

I was experiencing the same problem as above. I was using WSL 2.2.0. I uninstalled wsl and reinstalled version 2.1.5.0, and that solved the issue for me.

@mstuettgen
Copy link

I was using WSL version: 2.3.24.0 and ran into the same issues. Downgrading to WSL 2.1.5.0 solved the issue for me as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

8 participants