当前位置: 首页 > article >正文

在 Docker 中启动 ROS2 里的 rivz2 和 rqt 出现错误的解决方法

1. 出现错误:

  运行 ros2 run rivz2 rivz2 ,报错如下 :

No protocol specified
qt.qpa.xcb: could not connect to display :1
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

 排查问题 :执行 export QT_DEBUG_PLUGINS=1 后再运行 ros2 run rivz2 rivz2

# export QT_DEBUG_PLUGINS=1
# ros2 run rviz2 rviz2
---------------------------------------------------------------------
QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms" ...
QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqeglfs.so"
Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqeglfs.so, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "eglfs"
        ]
    },
    "archreq": 0,
    "className": "QEglFSIntegrationPlugin",
    "debug": false,
    "version": 331520
}


Got keys from plugin meta data ("eglfs")
QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqlinuxfb.so"
Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqlinuxfb.so, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "linuxfb"
        ]
    },
    "archreq": 0,
    "className": "QLinuxFbIntegrationPlugin",
    "debug": false,
    "version": 331520
}


Got keys from plugin meta data ("linuxfb")
QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqminimal.so"
Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqminimal.so, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "minimal"
        ]
    },
    "archreq": 0,
    "className": "QMinimalIntegrationPlugin",
    "debug": false,
    "version": 331520
}


Got keys from plugin meta data ("minimal")
QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqminimalegl.so"
Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqminimalegl.so, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "minimalegl"
        ]
    },
    "archreq": 0,
    "className": "QMinimalEglIntegrationPlugin",
    "debug": false,
    "version": 331520
}


Got keys from plugin meta data ("minimalegl")
QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqoffscreen.so"
Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqoffscreen.so, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "offscreen"
        ]
    },
    "archreq": 0,
    "className": "QOffscreenIntegrationPlugin",
    "debug": false,
    "version": 331520
}


Got keys from plugin meta data ("offscreen")
QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqvnc.so"
Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqvnc.so, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "vnc"
        ]
    },
    "archreq": 0,
    "className": "QVncIntegrationPlugin",
    "debug": false,
    "version": 331520
}


Got keys from plugin meta data ("vnc")
QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqxcb.so"
Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqxcb.so, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "xcb"
        ]
    },
    "archreq": 0,
    "className": "QXcbIntegrationPlugin",
    "debug": false,
    "version": 331520
}


Got keys from plugin meta data ("xcb")
QFactoryLoader::QFactoryLoader() checking directory path "/opt/ros/humble/lib/rviz2/platforms" ...
loaded library "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqxcb.so"
No protocol specified
qt.qpa.xcb: could not connect to display :1
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
进入 Docker 终端,输入 echo $DISPLAY 查看输出的值 是否与错误中的 display 后面的值一致。
如果一致,则表示不是 DISPLAY 的问题。

 2. 解决方法:

在本地终端 输入命令 :“sudo xhost +” 回车输入密码。
再到 docker 终端运行 ros2 run rivz2 rivz2

输出内容如下:

Got keys from plugin meta data ("xcb_glx")
QFactoryLoader::QFactoryLoader() checking directory path "/opt/ros/humble/lib/rviz2/xcbglintegrations" ...
loaded library "/usr/lib/x86_64-linux-gnu/qt5/plugins/xcbglintegrations/libqxcb-glx-integration.so"
QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/x86_64-linux-gnu/qt5/plugins/accessible" ...
QFactoryLoader::QFactoryLoader() checking directory path "/opt/ros/humble/lib/rviz2/accessible" ...
[INFO] [1707198676.391043318] [rviz2]: Stereo is NOT SUPPORTED
[INFO] [1707198676.391141640] [rviz2]: OpenGl version: 4.6 (GLSL 4.6)
[INFO] [1707198676.447671021] [rviz2]: Stereo is NOT SUPPORTED
QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/x86_64-linux-gnu/qt5/plugins/accessiblebridge" ...
QFactoryLoader::QFactoryLoader() checking directory path "/opt/ros/humble/lib/rviz2/accessiblebridge" ...
QLibraryPrivate::unload succeeded on "/usr/lib/x86_64-linux-gnu/qt5/plugins/xcbglintegrations/libqxcb-glx-integration.so" 
QLibraryPrivate::unload succeeded on "/usr/lib/x86_64-linux-gnu/qt5/plugins/imageformats/libqgif.so" 
QLibraryPrivate::unload succeeded on "/usr/lib/x86_64-linux-gnu/qt5/plugins/imageformats/libqico.so" 
QLibraryPrivate::unload succeeded on "/usr/lib/x86_64-linux-gnu/qt5/plugins/imageformats/libqjpeg.so" 
QLibraryPrivate::unload succeeded on "/usr/lib/x86_64-linux-gnu/qt5/plugins/imageformats/libqsvg.so" 
QLibraryPrivate::unload succeeded on "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforminputcontexts/libcomposeplatforminputcontextplugin.so" 
QLibraryPrivate::unload succeeded on "/usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqxcb.so" 
QLibraryPrivate::unload succeeded on "Xcursor" (faked)

 rivz2 的界面终于显示出来了。

xhost命令的基本用法 :
*****************************************************
xhost命令的基本用法非常简单,只需要在终端中输入以下命令:xhost +

执行这个命令后,就会允许所有主机访问当前X服务器。
如果想要限制访问的主机,可以使用以下命令 :xhost -hostname
hostname 是要限制访问的主机名或IP地址。


xhost 命令的注意事项 :
*****************************************************
在使用 xhost 命令时,需要注意以下几点 :
1. xhost 命令只能在图形界面下使用,如果在终端中使用会提示错误。
2. 在执行 xhost 命令时,需要以 root 用户身份执行。
3. 在允许所有主机访问当前系统的 X 服务器时,需要特别注意安全问题。

 再启动 rqt 也正常了,如下图所示 :

 


http://www.kler.cn/a/234459.html

相关文章:

  • AI写作(四)预训练语言模型:开启 AI 写作新时代(4/10)
  • go reflect 反射
  • C指针创建三维数组
  • 问:MySQL主从同步的机制梳理?
  • luckfox-pico-max学习记录
  • 树-好难-疑难_GPT
  • 《Django+React前后端分离项目开发实战:爱计划》 01 项目整体概述
  • DP读书:《openEuler操作系统》(九)从IPC到网卡到卡驱动程序
  • 【FPGA开发】Modelsim和Vivado的使用
  • mysql底层结构
  • [C# WPF] DataGrid选中行或选中单元格的背景和字体颜色修改
  • 简单介绍算法的基本概念
  • LeetCode Python -8.字符串转整数
  • golang 集成sentry:PostgreSQL
  • 4核8g服务器能支持多少人访问?- 腾讯云
  • 【Rust】——猜数游戏
  • python打印等边三角形
  • 【0257】关于pg内核shared cache invalidation messages (概念篇)
  • 你好,C++(11)如何用string数据类型表示一串文字?根据初始值自动推断数据类型的auto关键字(C++ 11)
  • [C#]winform制作仪表盘好用的表盘控件和使用方法
  • 私有化部署一个自己的网盘
  • 【超高效!保护隐私的新方法】针对图像到图像(l2l)生成模型遗忘学习:超高效且不需要重新训练就能从生成模型中移除特定数据
  • 2024 年 5 款适用于免费 iPhone 数据恢复的工具软件
  • 【从Python基础到深度学习】1. Python PyCharm安装及激活
  • AR人脸106240点位检测解决方案
  • 《CSS 简易速速上手小册》第1章:CSS 基础入门(2024 最新版)