在安装ROS的时候,安装完后需要测试一下ros,测试成功会显示并控制小乌龟,会用到Qt。具体如下

安装ROS成功后,在终端可以运行一个简单的示例程序.
在Terminal中运行以下命令:
$ roscore
新开一个terminal,运行以下命令,打开小乌龟窗口:
$ rosrun turtlesim turtlesim_node
新开一个terminal,运行以下命令,打开乌龟控制窗口,可使用方向键控制乌龟运动:
$ rosrun turtlesim turtle_teleop_key
选中控制窗口(一定是选中终端),按方向键,可看到小乌龟窗口中乌龟在运动。

但是,打开小乌龟窗口的时候报错:

This application failed to start because it could not find or load the Qt platform plugin “xcb”

Reinstalling the application may fix this problem.

Aborted (core dumped)

如下所示

ubuntu 16.04 Qt error: it could not find or load the Qt platform plugin "xcb"_bash

首先看看自己电脑 里有没有这个文件
locate libqxcb.so

我电脑是有的,然后开始Google,我试了网上不少方法都不行。

最后解决
1、打开.bashrc 文件
sudo gedit ~/.bashrc

\2、添加环境变量
export QT_PLUGIN_PATH=/home/cxl/Qt5.5.1/5.5/gcc_64/plugins
其中,读者需要根据自己的安装路径修改,我的是
/home/cxl/Qt5.5.1/5.5/gcc_64/plugins

3、最后,刷新生效(很重要!)
source ~/.bashrc