cyberbotics / webots_ros2

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

Compatibility for Docker on macOS #848

Open kalle264 opened 1 year ago

kalle264 commented 1 year ago

Description Hey, I want to use Webots with ROS running in Docker on macOS and not in the VM since the rest of my project runs in docker anyway. So I made changes so that you can provide a host ip address in the launch file for WebotsLauncher and WebotsController. If you don't, they will just use the get_host_ip function like before.

webots = WebotsLauncher(
        world=PathJoinSubstitution([package_dir, 'worlds', world]),
        host_ip="host.docker.internal",
        ros2_supervisor=False
)
epuck_driver = WebotsController(
        robot_name='e-puck',
        ip_address="host.docker.internal",
        parameters=[
            {'robot_description': robot_description_path,
             'use_sim_time': use_sim_time,
             'set_robot_state_publisher': True},
            ros2_control_params
        ],
        remappings=mappings,
        respawn=True
    )

Affected Packages List of affected packages:

kalle264 commented 1 year ago

Yes no problem, but probably not until next week.

jyjblrd commented 11 months ago

This is a nice PR. I also just ran into this issue while using parallels instead of UTM, so it would be nice to get this merged.

The current way get_host_ip "finds" the host ip address seems pretty fragile to me, im not even sure that code should be there. Perhaps just forcing the user to put in the hardcoded value would reduce confusion.

kalle264 commented 11 months ago

Hey @jyjblrd, unfortunately we switched over to Gazebo and my free time is currently also pretty full. You can contribute to the documentation if you want.

jyjblrd commented 11 months ago

Yeah no worries, I can finish it up in the next few days

kalle264 commented 11 months ago

Cool, thank you. Then I don't have to feel guilty every time I open Github :D

brian7989 commented 11 months ago

This is very helpful. When do you expect this PR to be merged?

jyjblrd commented 7 months ago

@omichel still looking for this PR to be merged? sorry for airing this thread for so long, I've been busy but I've been using this fork for a while and I think it is very worthwhile to get on the main branch, and I have some time now

jyjblrd commented 7 months ago

889 this PR fixes the problem for docker, but I am running a Parallels VM on my mac, which still requires the ip address to be put in manually. Happy to merge this PR in with the work done by #889

omichel commented 7 months ago

Hi, yes, please go ahead and let's merge this PR when it is fully tested and properly documented.

krzysztofzz1 commented 4 months ago

When will it be merged to fix?

omichel commented 4 months ago

When will it be merged to fix?

Whenever someone fixes the failing tests.