Search code examples
linuxubunturosros2

Running ROS2 turtlesim on Ubuntu 22.04: "qt.qpa.xcb: could not connect to display"


I'm trying to use ROS2 Humble on Ubuntu 22.04.3 on Windows 11, and when I try running ros2 run turtlesim turtlesim_node, I get the following message:

qt.qpa.xcb: could not connect to display
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, xcb.

[ros2run]: Aborted

Screenshot of console output

Is there a package I'm missing? I've been following this document to install the necessary packages, and I tried Googling this issue but nothing is helping.


Solution

  • EDIT1:
    Now WLS2 supports GUI natively using WSLg (no extra installation needed)

    ORIGINAL:
    If you're running Ubuntu on Windows I assume you're using WSL2. The problem is that WSL2 (or Docker) doesn't have desktop/GUI so by default you can't run any graphical applications. For that you need some kind of X server (or special setup for Docker).

    Here's link for WSL2 GUI to put you on track, Running ROS inside Windows 10 with GUI support (WSL)

    I liked to use the X server built in MobaXTerm.

    And a link to Using GUIs with Docker

    Alternatively you can use VM or even better if you have disk space and motivation make dual boot and run ROS on Ubuntu natively