ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Robot + Docker + ROS

asked 2019-04-30 09:59:53 -0500

elementaryshr gravatar image

updated 2019-04-30 11:35:27 -0500

Hello,

Currently I am working on a project which has following specifications:

  1. A controllable robot base and sensors
  2. Velodyne LIDARS connected via Ethernet.
  3. Few ros packages with a custom catkin workspace
  4. Nginx webpage based robot controller

Now, for past few days, I am trying to dockerize my system. I have:

  1. Created my own docker file from ros melodic base image which installs necessary packages.
  2. Nginx setup using bridge network
  3. Docker-compose file which opens up ports, mounts volumes and sets up networking mode as host\

Unfortunately, I am still very confused about how to tie everything together. In the tutorials, it is mentioned to create your own network, but I have ros messages coming from host machine (velodyne messages) and bi-directional flow of messages from web based controller. But if I opt for a default docker bridge network, the ros_master_uri is messed up. For easy access, "host" option seems the best, but it does not work well as you cannot use a ros master container. What is the correct way to configure such application?

Thanks, Shreyas

Edit: Added Links, commented on "host" n/w

edit retag flag offensive close merge delete

Comments

1

In the tutorials, [..]

which tutorials?

gvdhoorn gravatar image gvdhoorn  ( 2019-04-30 10:07:07 -0500 )edit

This one. Related qn: is separate roscore docker container necessary?

elementaryshr gravatar image elementaryshr  ( 2019-04-30 10:11:24 -0500 )edit

I run both roscore and nodes in the same docker container. I assume either way would work fine.

fvd gravatar image fvd  ( 2019-05-01 05:30:41 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2019-04-30 13:23:37 -0500

ruffsl gravatar image

But if I opt for a default docker bridge network, the ros_master_uri is messed up. For easy access, "host" option seems the best, but it does not work well as you cannot use a ros master container. What is the correct way to configure such application?

If you have containerized ros nodes that need to connect to other nodes outside the host machine, then provisioning your host's containers with the host network driver is perhaps the simplest method. Additionally, provisioning a container with the host network driver does not prevent you from running ros master from inside that same container. Infact, such may be necessary for other nodes outside the host machine to register themselves in the ros graph, that is if you'd rather not host the ros master process directly on the host OS or other machine on the accessible network.

See this previous answer for more details:
https://answers.ros.org/question/2915...

edit flag offensive delete link more

Comments

Thank you for the answer. After reading suggestions, I am going with following route: One roscore container, one ros application node container, and one nginx container (which, by the way, also has roslib js for communication with ros applicattion). Everything has network_mode: "host".

The host does NOT have ROS.

Now, how to set ROS_MASTER_URI and ROS_HOST or ROS_IP environment variables at runtime when roscore sets this dynamically based on tag of the container. Or somehow I must configure it statically and then set it via docker-compose? (Even if don't use another container for roscore and use the application container itself, the ENV parameters need to be set in nginx)

Also, is it possible to trigger new docker containers based on inputs received in another docker container?

elementaryshr gravatar image elementaryshr  ( 2019-05-02 08:08:17 -0500 )edit
2

That a big comment to unpack, perhaps best asked with a separate question, but for the environment variables, when using --net=host, the variables should be equivalent to just running ROS as if it were on the host.

ruffsl gravatar image ruffsl  ( 2019-05-07 16:34:19 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2019-04-30 09:59:53 -0500

Seen: 1,215 times

Last updated: Apr 30 '19