1

I am using ROS Melodic on Ubuntu 18.04 with gazebo9 and Xlaunch. I have been able to launch an empty workspace of gazebo but for some reason when I run rosrun rviz rviz, I get this error message:

QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
qt.qpa.screen: QXcbConnection: Could not connect to display
Could not connect to any X display.

I have roscore running with no errors, so I dont believe its that which is causing the problem This is the full script:

Gazebo

root@DESKTOP-GFT05HU:/mnt/c/Users/Frank# export GAZEBO_IP=127.0.0.1
root@DESKTOP-GFT05HU:/mnt/c/Users/Frank# export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0
root@DESKTOP-GFT05HU:/mnt/c/Users/Frank# export LIBGL_ALWAYS_INDIRECT=0
root@DESKTOP-GFT05HU:/mnt/c/Users/Frank# gazebo      
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function 
snd_func_card_driver returned error: No such file or 
directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4528:(_snd_config_evaluate) function 
snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4528:(_snd_config_evaluate) function 
snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM default
AL lib: (EE) ALCplaybackAlsa_open: Could not open playback device 'default': No such file or directory    
[Err] [REST.cc:205] Error in REST request

libcurl: (51) SSL: no alternative certificate subject name matches target host name 'api.ignitionfuel.org'

Rviz:

root@DESKTOP-GFT05HU:/mnt/c/Users/Frank# rosrun rviz rviz
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
qt.qpa.screen: QXcbConnection: Could not connect to display
Could not connect to any X display.
ChocoFudge
  • 21
  • 3

2 Answers2

0

Since WSL runs on top of the windows hypervisor you should treat the terminal like it has no direct knowledge of your display. To get this to work you need to do 2 things.

  1. You need to download a windows X Server client. I personally use XMing.

  2. Set your environment variable DISPLAY. Such as export DISPLAY=localhost:0.0

Edit: After doing some digging this issue is caused by how libGL interacts with the specific x server you're running. You have two options to fix this:

  1. You run XMing instead of of XLaunch

  2. If you want to keep using XLaunch under the "Additional Parameters for VcXsrv" add -nowgl

BTables
  • 4,413
  • 2
  • 11
  • 30
  • I already have X server client called Xlaunch thus why gazebo opens in an empty environment but i had the same error come up when doing what you suggested – ChocoFudge Oct 06 '21 at 15:35
  • @ChocoFudge so you're saying that you can open at least some gui through WSL? What version of WSL are you running? – BTables Oct 06 '21 at 16:53
  • I am running version 2 of WSL. its bizzare how gazebo runs with its GUI but rviz throws an error – ChocoFudge Oct 07 '21 at 11:47
  • @ChocoFudge After doing some digging I've been able to reproduce an error with XLaunch, see my edit. I'd also recommend using `XMing` as a starting point. – BTables Oct 07 '21 at 13:48
0

For me the solution was as simple as updating my WSL2 (Run Linux GUI apps on the Windows Subsystem for Linux)