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

Not able to run rviz on ros docker

asked 2022-01-17 05:40:35 -0600

petal gravatar image

updated 2022-01-17 05:41:58 -0600

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-r...)

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.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-01-17 20:30:23 -0600

cst0 gravatar image

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).

edit flag offensive delete link more

Comments

Hope this will help you as well.

aarsh_t gravatar image aarsh_t  ( 2022-01-18 12:11:40 -0600 )edit

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

petal gravatar image petal  ( 2022-01-18 15:25:19 -0600 )edit

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.
petal gravatar image petal  ( 2022-01-18 16:04:59 -0600 )edit

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

aarsh_t gravatar image aarsh_t  ( 2022-01-19 00:33:51 -0600 )edit

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?

petal gravatar image petal  ( 2022-01-22 05:43:42 -0600 )edit

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?

aarsh_t gravatar image aarsh_t  ( 2022-01-24 06:40:02 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2022-01-17 05:40:35 -0600

Seen: 1,929 times

Last updated: Jan 17 '22