cyberbotics / webots_ros2

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

`webots_ros2_driver` cannot connect when using Docker and macOS #888

Closed adamlm closed 8 months ago

adamlm commented 8 months ago

Describe the Bug

The webots_ros2_driver node running in a Docker container does not connect to the local simulation server running on a macOS host. The webots_tcp_client never connects, so it never starts Webots. The webots_controller instance is also unable to connect, presumably because Webots never actually launches.

Steps to Reproduce

  1. Install Webots on the host according to the instructions. (I installed it only for the current user, not system wide.)
  2. Download the local_simulation_server.py script on the host
  3. Install the ROS dependencies on the guest (Docker container) according to the ROS Webots tutorial. Make sure to mount your Webots shared folder when creating the container.
  4. On the guest, follow the Webots driver tutorial
  5. On the host, run the local_simualtion_server.py script
  6. Run the tutorial driver on the guest with ros2 launch my_package robot_launch.py

[!NOTE] I am running ROS in a Docker container instead of a virtual machine, unlike the ROS tutorials.

Expected behavior The WebotsLauncher and WebotsController instances launched on the guest should connect with the simulation server running on the host, and the Webots simulation app should launch. The webots_ros2_driver should connect to the spawned robot.

Affected Packages List of affected packages:

Screenshots Here's a printout snippet of the actual behavior when invoking

$ `ros2 launch my_package robot_launch.py`
[INFO] [launch]: All log files can be found below /home/vscode/.ros/log/2024-01-21-22-34-21-503797-67e608fcf059-19766
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [webots_tcp_client-1]: process started with pid [19768]
[INFO] [webots_controller_my_robot-2]: process started with pid [19770]
[webots_tcp_client-1] WARNING: Unable to start Webots. Please start the local simulation server on your host machine. Next connection attempt in 1 second.
[webots_controller_my_robot-2] Cannot connect to Webots instance, retrying for another 50 seconds...
[webots_tcp_client-1] WARNING: Unable to start Webots. Please start the local simulation server on your host machine. Next connection attempt in 1 second.
[webots_tcp_client-1] WARNING: Unable to start Webots. Please start the local simulation server on your host machine. Next connection attempt in 1 second.

System

Additional context

I assume there are Docker routing issues that prevents the ROS nodes (running on the guest) from connecting to the local server (running on the host). I confirmed there are no macOS firewall settings preventing a connection.