前言
上周开始,我在 Arch
上安装 ROS
,装了一周才搞定,记录一下碰到的问题。
官方推荐使用 Ubuntu
来安装 ROS
,但是我比较喜欢 Arch
所以就尝试在 Arch
上安装, Arch
上安装 ROS
的资料还是比较少的,官网的教程并不是那么准确,有误导性,所以写下此文,希望能帮助有缘人。
配置仓库
由于官方自带的仓库没有 ROS
的包,所以需要配置一下仓库地址,只需要在 /etc/pacman.conf
中加入如下配置
1
2
|
[oscloud]
Server = http://repo.oscloud.info/
|
配置代理
安装之前配置一下代理,不然非常慢,而且可能还容易失败,很多人止步于安装环境,非常可惜
1
2
3
4
|
export http_proxy=socks5://127.0.0.1:1080
export https_proxy=socks5://127.0.0.1:1080
git config --global http.proxy 'socks5://127.0.0.1:1080'
git config --global https.proxy 'socks5://127.0.0.1:1080'
|
导入 GPG key
配置好仓库后,我们还要配置一下 GPG
,这样下载的时候才能通过验证
1
2
3
|
sudo pacman-key --recv-keys CB222E7EBC11D682AAC8B317A4A0D73114FDE6FC
sudo pacman-key --finger CB222E7EBC11D682AAC8B317A4A0D73114FDE6FC
sudo pacman-key --lsign-key CB222E7EBC11D682AAC8B317A4A0D73114FDE6FC
|
安装
配置好仓库后,就可以通过如下命令来安装 ROS
了
1
2
|
sudo pacman -Syy
yay -S ros-melodic-desktop-full
|
初始化 rosdep
安装好之后,我们还需要初始化 rosdep
,这个可以方便的安装系统的依赖,和系统的一些核心组件
1
2
|
sudo rosdep init
rosdep update
|
设置ROS环境
根据的你 SHELL
选择,如果你不知道是什么可以通过 echo $SHELL
来查看,由于我用的是 zsh
所以选择下面的第二个
bash
1
2
|
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
|
zsh
1
2
|
echo "source /opt/ros/melodic/setup.zsh" >> ~/.zshrc
source ~/.zshrc
|
检查是否安装成功
最后我们通过 roscore
来检查是否安装成功
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
➜ ~ roscore
... logging to /home/test/.ros/log/cebd27dc-ce7d-11ea-b37c-001c42662094/roslaunch-test-42399.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.
started roslaunch server http://test:44305/
ros_comm version 1.14.3
SUMMARY
========
PARAMETERS
* /rosdistro: melodic
* /rosversion: 1.14.3
NODES
auto-starting new master
process[master]: started with pid [42407]
ROS_MASTER_URI=http://test:11311/
setting /run_id to cebd27dc-ce7d-11ea-b37c-001c42662094
process[rosout-1]: started with pid [42417]
started core service [/rosout]
|
看到如上所示,带版本号就表示安装成功了。
碰到的错误
错误一
error: ros-melodic-urdf-tutorial: signature from "Oscar Roesler (Username: bionade 24) <o.roesler@oscloud.info>" is invalid
解决办法很简单,在 /etc/pacman.conf
中,为 [oscloud]
添加一行 SigLevel = Never
,改完后如下所示
1
2
3
|
[oscloud]
SigLevel = Never
Server = http://repo.oscloud.info/
|
错误二
执行 sudo rosdep init
出现如下错误
1
2
3
4
|
➜ ~ sudo rosdep init
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.
|
解决办法需要编辑 /etc/hosts
,添加如下配置
1
|
151.101.84.133 raw.githubusercontent.com
|
错误三
执行 rosdep update
报如下错误
1
2
3
4
5
6
7
8
9
10
11
12
|
➜ ~ rosdep update
reading in sources list data from /etc/ros/rosdep/sources.list.d
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml
ERROR: unable to process source [https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml]:
Failed to download target platform data for gbpdistro:
<urlopen error _ssl.c:1091: The handshake operation timed out>
Query rosdistro index https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml
ERROR: error loading sources list:
The read operation timed out
|
多试几次,就行了,我试了不下50次。
错误四
用阿里或者清华的源常常卡在下面这两种情况
1
2
3
|
error: target not found: ros-melodic-catkin
error: target not found: ros-melodic-cmake-modules
error: target not found: ros-melodic-ros-environme
|
或者
1
|
fatal error: opencv2/xfeatures2d/cuda.hpp: No such file or directory
|
死活过不去这里,时间就是浪费在这里了。
总结
在Arch上安装ROS,是我没有想到会这么麻烦和困难,基本上足足折腾了一星期。只要下班回家,我就折腾,虚拟机都安装了10个左右,终于成功了。
其中花的时间最多的是在 yay -S ros-melodic-desktop-full
,这里卡了6.5天,这里过了后面的基本就比较顺利了。一开始我用的是阿里的源,试了几次不行后我用换清华的,实在不行,我也是抱着侥幸试一下 oscloud
,没想到成功了。
安装ROS不论是在 Ubuntu
还是 Arch
上都不是一件容易的事。网络问题也是非常让人头疼的。希望这篇文章能帮到大家。
参考