I'm working on having a docker container to use later on the robot. My approach is to have a multiple machine setup where the master is in the container and Gazebo and all sorts of other GUI intensive stuff can work from outside the container.
So I started by following the Multiple Machines tutorial inside the container (just to see how far I could get). It turns out that if I start a roscore on one bash and call rosrun from another they do not hear each other.
According to docker documentation,
you can supply -P or --publish-all=true|false to docker run which is a blanket operation that identifies every port with an EXPOSE line in the image’s Dockerfile
sudo docker run -P -it osrf/ros:kinetic-desktop-xenial Start docker container (using -P )
roscore It went straight into the container so this is already inside the container, on the first bash
docker exec -it <name> this is done in another terminal to open another bash for the same container
Here name is just a placeholder for the name of the container (like optimistic_aryabhata)
Inside this second bash, I set up for the tutorial
source /opt/ros/$ROS_DISTRO/setup.bash apt-get update apt-get install wget wget http://packages.ros.org/ros.key -O - | apt-key add - apt-get update apt-get install python-catkin-tools
And follow the tutorial instructions for multiple machines
export ROS_MASTER_URI=http://<name>:11311 rosrun rospy_tutorials listener.py
The last command gives me
Unable to register with master node [http://<name>:11311]: master may not be running yet. Will keep trying.
I was asked what was the
ROS_HOSTNAME. I was not aware of the
ROS_HOSTNAME environmental variables. Neither is set. (I'm exploring this right now)
Another question was about NetworkSetup. I did not follow this tutorial yet under the assumption that first I need to be able to make roscore discoverable between terminals of the same machine to go into this part of the setup.
Post score: 0
Comment by jayess on 2017-10-17:
Are you literally using the host name
<name> or is this some place holder that you're using for your question? Also, what do you have for
Comment by PeterMilani on 2017-10-17:
Does your docker container expose the master port 11311. What is your Dockerfile? If you look at the ros networking page, these and a couple of environment variables are required to allow external computers connect to a ros master.
Comment by kotoko on 2017-10-18:
@jayess I updated the answer. I was not aware of these variables, will look into it now. If you have any advice it is most welcome :D @PeterMilani Also updated the answer to reflect the information you asked for. Thanks for the input!