0
$\begingroup$

Rosanswers logo

Hello all,

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_IP / 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.


Originally posted by kotoko on ROS Answers with karma: 122 on 2017-10-17

Post score: 0


Original comments

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 ROS_HOSTNAME?

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 jayess on 2017-10-18:
You should definitely set the environment variables and try running everything again. Please read this carefully http://wiki.ros.org/ROS/EnvironmentVariables

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!

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Turns out I need to do export ROS_MASTER_URI=http://containerIP:11311/ at every bash console that I open.


Originally posted by kotoko with karma: 122 on 2017-10-18

This answer was ACCEPTED on the original site

Post score: 3

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.