Ask Your Question

How to start a python script that launches master using Docker

asked 2021-04-05 10:18:44 -0500

Chris1343 gravatar image

updated 2021-04-05 10:22:24 -0500

I have a python file that executes a bash script. That bash script starts a ros master by running

roslaunch rosbridge_server rosbridge_websocket.launch

Python file works as expected when ran on its own.

Now I want to start that python script using a Dockerfile (or Docker container). I've seen this tutorial but this doesn't help me as the master is started from the container itself.

My question is how can I run the python script inside a Dockerfile and somehow include the ROS noetic module inside the container to let the script know about it?

This is the Dockerfile I have at the moment:

FROM python:3
COPY . .
RUN pip install -r requirements.txt
ENTRYPOINT ["/bin/bash", "-c", "source ../setup.bash"]
CMD [ "python", "" ]
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2021-04-06 14:42:55 -0500

ruffsl gravatar image

The roslaunch utility checks the network for an existing rosmaster before attempting to start one itself. If you run roslaunch from an isolated container (with its own separate network interface by default), then it may not find rosmaster already running on the host machine. You can either configure the ROS network environment variables with a different kind of virtual network bridge interface attached to the container to reach the rosmaster on the host, or you could attach the container to the host's network interfaces directly:

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2021-04-05 10:05:45 -0500

Seen: 20 times

Last updated: Apr 06