前言
ROS (Robot Operating System) 是主流的机器人开发框架之一。
截止目前(2020.10),已经推出了ros-humble版本,ROS2相比ROS1有很大的不同,安装方法也有一些差异。具体的关于ROS的介绍请自行搜索,资料非常多。
Wayland是一款全新的Display Server,和X Window平级。所以网上的对X11的GUI支持并不适用于基于Wayland的桌面。目前,本人并没有发现网上有关于如何在wayland桌面下开启GUI支持的中文资料(可能是本人搜索能力欠佳),所以本文介绍如何快速安装ROS2 (ros-humble) 并开启GUI (wayland)支持。
环境
注意:本文只适用于基于wayland的桌面(如plasma-wayland),基于X11的桌面请转到其它教程
本人的环境:
操作系统: Kali GNU/Linux 2022.3
内核: Linux 6.0.1-surface x86_64
Docker:Docker version 20.10.20, build 9fdeb9c
KDE Plasma Version: 5.26.0
KDE Frameworks Version: 5.98.0
Qt Version: 5.15.4
Graphics Platform: Wayland
Docker请自行安装,本文不介绍。
安装ROS2
本教程只介绍使用Docker安装ROS2,其它可用方法请转到其它教程。
拉取image(有无-full关系不大):
sudo docker pull osrf/ros:humble-desktop-full
创建container(这步尤其注意):
docker run -it --name ros-humble \
-v SLAM-vol:/root/SLAM \
-e XDG_RUNTIME_DIR=/tmp \
-e WAYLAND_DISPLAY=$WAYLAND_DISPLAY \
-v $XDG_RUNTIME_DIR/$WAYLAND_DISPLAY:/tmp/$WAYLAND_DISPLAY \
-e QT_QPA_PLATFORM=wayland \
osrf/ros:humble-desktop-full
打开container:
docker start ros-humble
进入container:
docker exec -it ros-humble bash
(可选)为了方便,我们可以把source /ros_entrypoint.sh
加入~/.bashrc
中
然后验证安装,输入ros2
会出现:
ros-humble安装成功。
启用GUI
如果我们直接输入:
ros2 run turtlesim turtlesim_node
会出现类似这样的输出:
qt.qpa.plugin: Could not find the Qt platform plugin “wayland” in “”
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
网上很多教程可能会说要改各种环境变量,其实并不是!
这说明没有安装qtwayland
,那么安装qtwayland
:
apt install qtwayland5
然后就可以顺利启动小乌龟了:
ros2 run turtlesim turtlesim_node