0
$\begingroup$

Rosanswers logo

I am experimenting creating a standard environment for my students to run ROS without having to install anything, because that always goes wrong somehow. In other posts I have questions about VNC and X. This question is similar: Is it possible, and how, to create a docker image based on Ubuntu and ROS that when launched will allow ROS development and testing to happen including running tools like Gazebo, RViz, RQT etc etc. Have you done it? Have you seen it written up? I am successful at this point to get everything to work in the container, EXCEPT trying to run say RQT which fails with "QXcbConnection: Could not connect to display" and many other errors. If desired I will attach my Dockerfile.


Originally posted by pitosalas on ROS Answers with karma: 628 on 2019-01-25

Post score: 5

$\endgroup$

4 Answers 4

0
$\begingroup$

Rosanswers logo

(Strictly speaking, this is not an answer, but I needed more characters than the comment allowed)

For students, I would take a look at Singularity.

It uses the same techniques, but doesn't require super user rights, mounts $HOME by default, runs everything as the $USER that started the container, and allows access to devices and GPUs by default.

There isn't even any special configuration needed with Singularity containers to be able to use GUIs.

And it allows you to import/run/exec Docker images, so you can start from osrf/ros:kinetic-desktop-full for instance.


Edit: as an answer to your original question: yes, it's certainly possible to run GUI applications from inside Docker containers. Some of the approaches are documented over at wiki/docker. An alternative can be seen at osrf/car_demo.


Edit2: here's a three line example to get RViz running from inside a Singularity "shell" (essentially equivalent to a docker run -it ..):

# needed once: converts Docker image into Singularity image on your local system singularity pull --name ros-kinetic-desktop-full.simg docker://osrf/ros:kinetic-desktop-full # in terminal 1: roscore singularity exec -p ./ros-kinetic-desktop-full.simg bash -c 'source /opt/ros/kinetic/setup.bash; roscore' # in terminal 2: rviz # if you have nvidia hw and the proprietary driver installed: singularity exec --nv -p ./ros-kinetic-desktop-full.simg bash -c 'source /opt/ros/kinetic/setup.bash; rviz' # if you have a built-in Intel GPU or are using nouveau singularity exec -p ./ros-kinetic-desktop-full.simg bash -c 'source /opt/ros/kinetic/setup.bash; rviz' 

Note: I'm using Singularity 2.5.2 commands here. Singularity 2.6 (and 3.0) will have changed the way it interacts with NVidia hw.

The -p is to make sure all child processes in the container are terminated when the container terminates.


Originally posted by gvdhoorn with karma: 86574 on 2019-01-25

This answer was NOT ACCEPTED on the original site

Post score: 3


Original comments

Comment by ruffsl on 2019-01-28:
+1 for the three line Singularity example. When you have the time, a post or wiki about using ROS with singularity would be cool. It seems v3.0 has changed up some things, but searching the docs, I didn't see anything much on nvidia/gpu.

Comment by gvdhoorn on 2019-01-29:
I've been meaning to, but as always, time and other obligations have prevented me from doing that so far.

re: 3.0 changes: yes, it's a complete rewrite (in golang) and it's changed quite a few things.

re: gpu: there is nothing special to do, as Singularity allows access to /dev by default. What is needed is to "install" the required drivers in the image. But as you don't want to do that, a similar trick to what nvidia-docker(2) did/does is used: mount those into the container. The specifics of that have changed between 2.x and 3.x, but in principle things "just work".

Comment by pitosalas on 2019-01-29:
@gvdhoorn thanks for the example. And yes of course I know docker. That's what I've been using (among other things) to get this to work. It seems that Singularity only works natively on unix and needs a VM to run on Mac, which is my environment. Will it perform ok then? I worry about docker + vm

Comment by gvdhoorn on 2019-01-29:\

And yes of course I know docker.

You wrote:

[..] without a handle on what the thing does, which keeps me from just typing in the commands!

Which made me ask myself (and you) whether you (truely) know what Docker does when you give it a command. I merely found it a curious thing to say.

It seems that Singularity only works natively on unix and needs a VM to run on Mac, which is my environment. Will it perform ok then? I worry about docker + vm

Singularity right now apparently only runs natively under Linux, but can be made to run on OSX. See sylabs/singularity#109.

I've not done that myself and it's probably not something I'd recommend doing in a production environment/class/uni course where you depend on your tools being stable.

re: vm: Singularity is not magic, so will suffer in a VM as any other tool would. How much of an impact there is of course depends on the types of workloads.

Comment by pitosalas on 2019-01-29:
It was a curious answer, and yet it was true. I would say my level of docker expertise is intermediate not expert. But really without context the singularity web site doesnt explain what it does. I couldnt even tell for sure if it was software I installed or it was a cloud service.

Comment by gvdhoorn on 2019-03-05:
Seems there is some movement on the OSX + Singularity front: sylabs/singularity#2675 just got merged.

$\endgroup$
0
$\begingroup$

Rosanswers logo

You might be interested in a small python tool from OSRF named Rocker

A tool to run docker containers with overlays and convenient options for things like GUIs etc.

https://github.com/osrf/rocker

It's basically helpful CLI around Docker that enables display/audio forwarding and hardware acceleration to container to simplify using ROS GUIs with Docker. I'm sure @tfoote would appreciate any feedback should you try out the project.


Edit: Just to throw it out there, you may also want to checkout web based environments for developing ROS, e.g:

However, web based environments may pose their own challenges if your intent is to also interact with physical robots locally in a lab/class room. Still I imagine a combination of the theses methods would do nicely. E.g RDS/AWS for homework and Docker/Singularity for in lab sessions.


Originally posted by ruffsl with karma: 1094 on 2019-01-28

This answer was NOT ACCEPTED on the original site

Post score: 3


Original comments

Comment by gvdhoorn on 2019-01-28:
@pitosalas: rocker is what is used in osrf/car_demo I linked to in my answer.

I still feel Singularity makes more sense in an environment with students, if only for the fact that it doesn't need super user privileges.

Comment by pitosalas on 2019-01-28:
@gvdhoorn I looked at singularity's web site and admit I don't understand how to use it. I kind of understand what they say it does but I am lost on where to start. I did read the doc and the quick start but without a handle on what the thing does, which keeps me from just typing in the commands!

Comment by gvdhoorn on 2019-01-28:
You'll want to check the user manual. Especially the quick start and introduction sections.

Comment by gvdhoorn on 2019-01-28:\

I did read the doc and the quick start but without a handle on what the thing does, which keeps me from just typing in the commands!

do you know what Docker does?

$\endgroup$
0
$\begingroup$

Rosanswers logo

I use the latest ros image (e.g., ros:melodic) and install the ROS desktop version (my simple custom Dockerfile for the GUI tools). Then I start all GUI tools with x11docker.

Works like a charm:

$ x11docker --hostnet ros:gui rviz $ x11docker --hostnet ros:gui rqt_graph 

I'm using --hostnet (cf. --network=host) for simplicity. ros:gui is the tag of my custom Docker image.


Originally posted by dratasich with karma: 11 on 2019-02-25

This answer was NOT ACCEPTED on the original site

Post score: 1


Original comments

Comment by pitosalas on 2020-01-18:
I am on Mac so x11docker is not available to me... :(

$\endgroup$
0
$\begingroup$

Rosanswers logo

For those, who are still looking for an easy ROS usage: https://hub.docker.com/r/johannhaselberger/coros

This will allow you to use all ROS GUI tools within your browser - on mac, linux and even windows.


Originally posted by Johann.Haselberger with karma: 21 on 2020-02-11

This answer was NOT ACCEPTED on the original site

Post score: 1


Original comments

Comment by pitosalas on 2020-03-04:
@Johann.Haselberger thanks. I am not sure how I launch your docker container from there. Can you give me the sequence? Thanks.

Comment by pitosalas on 2020-04-23:
@johann.haselberger can I ask you a question about #coros?

Comment by Johann.Haselberger on 2020-04-24:
@pitosalas: Yes feel free to ask, you could also create an issue on the GitHub project.

Also on docker hub / GitHub there is a small documentation. The section Start the service is exactly what you are looking for.

Comment by pitosalas on 2020-04-25:
@johann.Haselberger thanks. I tried it on a cloud host and it worked and now I am trying it locally on my Mac and it seems to work nicely too. Question: it says FROM ros:melodic but where is that Dockerfile so I can see what it is doing?

$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.