cyberbotics / webots_ros2

Webots ROS 2 packages
Apache License 2.0
402 stars 148 forks source link

The robot is already connected or your IP address is not allowed by this instance of Webots. #917

Open flyingdoraemon opened 6 months ago

flyingdoraemon commented 6 months ago

Describe the Bug After follow the tutorial in Installation (Windows) and try the Setting up a robot simulation (Basic), after executing ros2 launch my_package robot_launch.py, the problem is up above.

Steps to Reproduce

  1. Installed ROS2 + ros-iron-webots-ros2 on WSL2, Ubuntu-22.04
  2. Installed Webots on Windows11
  3. Configured workspace, sourced ROS, with WEBOTS_HOME=/mnt/d/Programs Files/Webots
  4. Started ros2 launch my_package robot_launch.py

Screenshots

$ ros2 launch my_package robot_launch.py
[INFO] [launch]: All log files can be found below /home/...
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [webots-1]: process started with pid [6539]
[INFO] [webots_controller_my_robot-2]: process started with pid [6541]
[webots_controller_my_robot-2] The Webots simulation world is not yet ready, pending until loading is done...
[webots_controller_my_robot-2] Error: The connection was closed by Webots. The robot is already connected or your IP address is not allowed by this instance of Webots.
[webots_controller_my_robot-2] [ros2run]: Process exited with failure 1
[ERROR] [webots_controller_my_robot-2]: process has died [pid 6541, exit code 1, cmd '/home/.../ros2_ws/install/webots_ros2_driver/share/webots_ros2_driver/scripts/webots-controller --robot-name=my_robot --protocol=tcp --ip-address=172.24.128.1 --port=1234 ros2 --ros-args -p robot_description:=/home/.../ros2_ws/install/my_package/share/my_package/resource/my_robot.urdf'].
[INFO] [webots-1]: process has finished cleanly [pid 6539]

System

Additional context The previous problem is here, and the question in this comment is the same, in #759 .

As is mentioned in #879 , if I set [experimental] dnsTunneling=true in .wslconfig, the error is

[webots_controller_my_robot-2] Cannot connect to Webots instance, retrying for another 50 seconds...
[webots_controller_my_robot-2] Cannot connect to Webots instance, retrying for another 45 seconds...
...

If I set .wslconfig to

[experimental]
networkingMode=nat
firewall=false
autoProxy=true

the error is mentioned above.

If I set networkingMode=mirrored, the output is just waiting for connection, after I Ctrl+C, the output is

[WARNING] [launch]: user interrupted with ctrl-c (SIGINT)
[webots_controller_my_robot-2] [ros2run]: Interrupt
[ERROR] [webots_controller_my_robot-2]: process has died [pid 609, exit code 254, cmd '/home/.../ros2_ws/install/webots_ros2_driver/share/webots_ros2_driver/scripts/webots-controller --robot-name=my_robot --protocol=tcp --ip-address=8.8.8.8 --port=1234 ros2 --ros-args -p robot_description:=/home/.../ros2_ws/install/my_package/share/my_package/resource/my_robot.urdf'].

(wondering why the ip-address is 8.8.8.8)


The method in this comment helped me checked there are no port 1234 in use and there are no firewall issues. And the test: telnet 172.24.128.1 1234 while webots is running is ok.

The output of running demo packages is the same, like ros2 launch webots_ros2_universal_robot multirobot_launch.py, except that it will endlessly try to reconnect.

I tried to search for methods but failed, please help and thanks a lot!!!

ZJZ0405 commented 2 months ago

I try to run “/opt/ros/humble/share/webots_ros2_driver/scripts/webots-controller --robot-name=my_robot --protocol=tcp --ip-address=10.255.255.254 --port=1234 ros2 --ros-args -p robot_description:=/home/mol/ws/my_package/install/my_package/share/my_package/resource/my_robot.urdf”, and change "--ip-address=10.255.255.254". It works.