Robotics StackExchange | Archived questions

Not able to run rviz on ros docker

Hello,

I have created a dockerfile with ubuntu16, ros kinetic. I have been able to build the image and I am trying to run rviz on it but I get this error

root@bcec7cce1809:/opt/libglvnd# rviz
QXcbConnection: Could not connect to display :1
Aborted (core dumped)

I referred this tutorial (http://wiki.ros.org/docker/Tutorials/GUI) and this link (https://github.com/henry2423/docker-ros-x11)

So, before running my docker I entered these command

$ XSOCK=/tmp/.X11-unix
$ XAUTH=/tmp/.docker.xauth
$ touch $XAUTH
$ xauth nlist $DISPLAY | sed -e 's/^..../ffff/' | xauth -f $XAUTH nmerge -
$ xhost +si:localuser:root

Then I run my built docker image as

sudo docker run -it --env="DISPLAY"     --env="QT_X11_NO_MITSHM=1"     --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" pankhurivanjani/roskineticslam:v1 bash

Can anyone help me in figuring out if I am using something in the wrong way?

P.S. My local system has ubuntu 20 and ros noetic installed in it.

Asked by petal on 2022-01-17 06:40:35 UTC

Comments

Answers

This is a docker error, not a ROS error: the docker image is telling you that it "can't connect to display :1". In more human-readable language, it's telling you that you've told it to connect to display :1 but that no such display exists.

Try running xrandr in your docker image to see if 1) it can find any displays and 2) if you're addressing the displays correctly. If the answer to 1) is no, then there's some problem with how you're launching the image. If the answer to 2) is no, xrandr should help you find what the appropriate way to address the display is. It looks to me like you may have problems with both of those steps: the display ":1" is only valid if you have two displays (the first display is ":0" because of zero indexing), and you should be able to correct that by setting the DISPLAY environment variable (right now it's not being set to anything, try -e DISPLAY=unix$DISPLAY instead).

Asked by cst0 on 2022-01-17 21:30:23 UTC

Comments

Hope this will help you as well.

Asked by aarsh_t on 2022-01-18 13:11:40 UTC

Hi! Thanks for your response. 1. I tried running inside docker image I got

xrandr 
Can't open display 

I understood we can get correct display in environment but I am not able to solve this problem (1) of finding any displays.

I tried a random image tiryoh/ros-kinetic-desktop from https://github.com/Tiryoh/docker-ros-kinetic-desktop too, but I can't seem to get the rviz in this too.

I used this command to launch the image

docker run -it --rm --env="DISPLAY"     --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" tiryoh/ros-kinetic-desktop

Do you think something is wrong in the way I am launching the above image by above command?

Or Is it something related to local PC ?

Asked by petal on 2022-01-18 16:25:19 UTC

Also, I read somewhere to use --net=host while running docker but it wasn't recommended. I still gave one try

docker run --rm -ti --net=host -e DISPLAY=:1 pankhurivanjani/roskineticslam:v1

But, I am getting this error while running this command, which might be due to --net=host (Checked about this error an web and it seems like so from the comments)

root@pankhuri-G5-5500:/opt/libglvnd# rviz
[ INFO] [1642542868.771662107]: rviz version 1.12.17
[ INFO] [1642542868.771720714]: compiled against Qt version 5.5.1
[ INFO] [1642542868.771738302]: compiled against OGRE version 1.9.0 (Ghadamon)
process 35: D-Bus library appears to be incorrectly set up; failed to read machine uuid: UUID file '/etc/machine-id' should contain a hex string of length 32, not length 0, with no other text
See the manual page for dbus-uuidgen to correct this issue.
Could not initialize OpenGL for RasterGLSurface, reverting to RasterSurface.

Asked by petal on 2022-01-18 17:04:59 UTC

one simplest way (but not the safest) I can suggest is, run docker ps -a copy the containerID of desired container. somewhere on your PC make file <name>.sh put this things inside the .sh file

xhost +local:`docker inspect --format='{{ .Config.Hostname }}' <containerID>`
docker start <containerID>
docker exec -it <containerID>  bash

now whenever you want to start the container, just do ./<name>.sh And all your problem related to the display will be solved

Asked by aarsh_t on 2022-01-19 01:33:51 UTC

Hi! I tried it all, I am actually able to solve the display issues now, but getting segmentation fault as soon as I start roscore

rosrun rviz rviz
[ INFO] [1642851474.328465376]: rviz version 1.12.17
[ INFO] [1642851474.328496937]: compiled against Qt version 5.5.1
[ INFO] [1642851474.328506137]: compiled against OGRE version 1.9.0 (Ghadamon)
Could not initialize OpenGL for RasterGLSurface, reverting to RasterSurface.
Segmentation fault (core dumped)

Is there any way to check whether OpenGL is working properly on docker container?

Asked by petal on 2022-01-22 06:43:42 UTC

No it still looks like the docker. Can I ask how you had ran the container from the image in the very beginning? Also do you have nvidia gpu?

Asked by aarsh_t on 2022-01-24 07:40:02 UTC