具体安装过程不在这里赘述,主要参考以下几篇文章:
我的安装如下:为了尽量避坑,所以开始安装前,先看了几个帖子,结果还是避免不了。
安装过程:
1. 添加ROS软件源
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.ustc.edu.cn/ros/ubuntu/ $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/ros-latest.list'
(PS:这里贴出的是我使用有效的源,这里我也换了一个源,如果后面遇到了无法下载ros的问题,大概率是源的问题,可以从网上找换一个)
2. 添加密钥
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
3. 更新软件源
sudo apt update
4. 开始安装ROS
sudo apt install ros-noetic-desktop-full
(如果报错,可能是网络连接问题,可以重新尝试,或者更新软件源,或者换一个ROS软件源,也就是从1重新开始)
安装过程是无尽的等待。。。
进程progres比较慢,板卡发热比较严重,所以拿了小风扇降温
额外提示:
由于昨天进度太慢,所以我暂停了今天重新安装ROS,连接手机热点,发现没连接上,SSH登录一直失败,利用ifconfig
查看才发现是热点Ip竟然变了,这个是我之前所不知道的知识点,小伙伴们也可以注意一下!
终于下载完毕,利用sudo apt install ros-noetic-desktop-full
检查一下是否是最新版本
可以看到没有问题
**5.初始化rosdep **
sudo rosdep init
报错:```sudo: rosdep: command not found````
尝试着输入以下命令
sudo apt install python-rosdep2
或者:
sudo apt install python3-rosdep2```
接着重新初始化,报错:```ERROR: cannot download default sources list from:
https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list
Website may be down.
输入以下命令:
sudo gedit /etc/hosts
然后在打开的hosts文件中添加如下的内容,然后保存退出
185.199.109.133 raw.githubusercontent.com
但是这里就报错了:
sudo: gedit: command not found
输入以下命令安装gedit即可
sudo apt-get install gedit
安装好后还是报错了,关于display的,昨天查看图片也遇到了这个问题,今天也遇到了,一直没能解决。。。
Unable to init server: Could not connect: Connection refused
(gedit:156417): Gtk-WARNING **: 16:34:48.785: cannot open display:
```
![](https://img-blog.csdnimg.cn/img_convert/a24c996cd353204572223e1690da4386.png)
这里只能尝试换一种方式。。。,使用`vim`编译命令`sudo vim /etc/hosts`(注意加sudo,不然保存不了)
接着又报错
```c
ERROR: default sources list file already exists:
/etc/ros/rosdep/sources.list.d/20-default.list
Please delete if you wish to re-initialize
```
使用命令:
```c
sudo rm /etc/ros/rosdep/sources.list.d/20-default.list
```
重新执行命令`sudo rosdep init`又报错:
```c
Wrote /etc/ros/rosdep/sources.list.d/20-default.list
Recommended: please run
rosdep update
```
这里是失误,刚发现其实已经成功,出现红色框内容就是成功可以进入下一步
![](https://img-blog.csdnimg.cn/img_convert/aa666a30c37e74a070ab89ac74cb55d7.png)
**6.设置环境变量 **
```c
echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc
```
**7.安装rosinstall **
```c
sudo apt install python3-rosinstall python3-rosinstall-generator python3-wstool
```
# 2.测试——小乌龟运动测试
测试遇到问题,如果环境没有安装好,推荐看 [详细介绍如何在ubuntu20.04中安装ROS系统,超快完成安装(最新版教程)](https://blog.csdn.net/qq_44339029/article/details/120579608?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522165833314416782395394860%2522%252C%2522scm%2522%253A%252220140713.130102334..%2522%257D&request_id=165833314416782395394860&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~baidu_landing_v2~default-4-120579608-null-null.185^v2^tag_show&utm_term=ubuntu20.04%20%E5%AE%89%E8%A3%85ROS&spm=1018.2226.3001.4450),问题罗列很全面。
当安装完ROS无法确认知否成功,进行一个案例测试
1. 终端中使用命令:
```roscore```
2. 再打开一个新的终端,并使用命令:
`rosrun turtlesim turtlesim_node
`
3. 再次打开一个新的终端,并使用命令:启用启动turtlesim的键盘控制节点```
rosrun turtlesim turtle_teleop_key
```
但是报错了,
```
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.
```
------------
```
这里问题好像是:以服务器作为远程解释器,本地pycharm或vscode调试时出现如下错误:出现这种问题并不是Qt安装有问题也不是pycharm配置有问题,而是qt找不到图形输出端口,这和IDE不能直接回传图形界面相关,比如一份代码中添加cv.imshow()后报上述错误。
```
解决办法:借助远程ssh连接工具以windows和pycharm为例,安装远程ssh软件MobaXterm(或其他支持图形回传的远程软件)输入,具体参考如下帖子
[远程调试 qt.qpa.xcb: could not connect to display, echo DISPLAY为空[已解决]](https://blog.csdn.net/qq_38851184/article/details/124448708?spm=1001.2101.3001.6650.3&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-3-124448708-blog-120640384.pc_relevant_multi_platform_whitelistv1&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-3-124448708-blog-120640384.pc_relevant_multi_platform_whitelistv1&utm_relevant_index=5)
安装```apt-get install xorg```报错。无法下载安装,是因为权限问题,参考下篇文章有用:
[E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied](https://blog.csdn.net/mao_hui_fei/article/details/107081870)
------------
在执行结束
```
apt-get install xorg
xclock
```
不用按上面参考帖子在编译器上做环境的配置,重启板子,连接服务器,命令操作依然可以在VScode 上进行,但记得打开软件MobaXterm ,小乌龟就可以显示
4. 把鼠标放在第三个终端界面上,能够键盘上的上下左右进行控制小海龟的移动,轨迹如下(运动小乌龟在MobaXterm 显示)
![](https://img-blog.csdnimg.cn/img_convert/1c386c26e1ae7a724361f70206acc919.png)
不过小乌龟的逻辑是实现的了
不过运动很慢,不知道是通信问题,还是板子性能处理问题
1. 终端中使用命令:
```
roscore
```
2. 再打开一个新的终端,并使用命令:
```
rosrun turtlesim turtlesim_node
```
3. 再次打开一个新的终端,并使用命令:启用启动turtlesim的键盘控制节点```
rosrun turtlesim turtle_teleop_key
```
# 参考资料:
1. [详细介绍如何在ubuntu20.04中安装ROS系统,超快完成安装(最新版教程)](https://blog.csdn.net/qq_44339029/article/details/120579608?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522165833314416782395394860%2522%252C%2522scm%2522%253A%252220140713.130102334..%2522%257D&request_id=165833314416782395394860&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~baidu_landing_v2~default-4-120579608-null-null.185^v2^tag_show&utm_term=ubuntu20.04%20%E5%AE%89%E8%A3%85ROS&spm=1018.2226.3001.4450)
2. [Ubuntu20.04安装ros教程(实测有用)](https://blog.csdn.net/qq_39607707/article/details/123604334?spm=1001.2101.3001.6661.1&utm_medium=distribute.pc_relevant_t0.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-1-123604334-blog-124513527.pc_relevant_aa&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-1-123604334-blog-124513527.pc_relevant_aa&utm_relevant_index=1)
3. [旭日3SDB,安装原版ros](https://blog.csdn.net/weixin_41332204/article/details/125477582?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522165833011616782425153238%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&request_id=165833011616782425153238&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~first_rank_ecpm_v1~rank_v31_ecpm-1-125477582-null-null.142^v33^experiment_2_v1,185^v2^tag_show&utm_term=%E6%97%AD%E6%97%A5X3%E8%B7%91ROS&spm=1018.2226.3001.4187)
1. [远程调试 qt.qpa.xcb: could not connect to display, echo DISPLAY为空](https://blog.csdn.net/qq_38851184/article/details/124448708?spm=1001.2101.3001.6650.3&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-3-124448708-blog-120640384.pc_relevant_multi_platform_whitelistv1&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-3-124448708-blog-120640384.pc_relevant_multi_platform_whitelistv1&utm_relevant_index=5)
1. [E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied](https://blog.csdn.net/mao_hui_fei/article/details/107081870)