树莓派buster安装ROS完整记录
我敢说这一教程全网找不到相同的。我今天在安装ROS时查了各方教程:官方Wiki,Google,CSDN都各查了不下10篇,终于综合各教程内容花了大半天下好了。
使用硬件及软件:
树莓派3B搭载Debian 10 (buster)操作系统。
ROS每一个版本都只能和特定的linux系统版本对应,buster系统对应版本为ROS Noetic
查看系统版本:
lsb_release -a
1 将软件源换为国内源
使用国内源可以加快下载速度,我这里使用清华源。
打开文件/etc/apt/sources.list进行修改,注释掉已有内容,添加以下几行:
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-update main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-backports main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster/updates main contrib non-free
同时系统源也要换一下,位置: /etc/apt/sources.list.d/raspi.list
注释点已有内容,添加如下内容:
deb http://mirrors.tuna.tsinghua.edu.cn/raspberrypi/ buster main ui
deb-src http://mirrors.tuna.tsinghua.edu.cn/raspberrypi/ buster main ui
2 获取ROS软件源及密钥
sudo sh -c ‘echo “deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main” > /etc/apt/sources.list.d/ros-latest.list’
sudo apt-key adv --keyserver ‘hkp://keyserver.ubuntu.com:80’ --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
3 更新软件源
sudo apt update
sudo apt upgrade
4 初始化rosdep
sudo rosdep init
rosdep update
这里第一条指令多半会出问题,是访问国外网站不稳定导致的。此时的思路时把rosdep init本来放在云端的程序下载到本地,然后在本地调用即可
具体步骤如下:
1 在github上下载rosdep库
git clone github.com/ros/rosdistro
2 修改文件rosdep/source.list.d/20-defaults.list
# os-specific listings first
yaml file:///home/xxx/rosdistro/rosdep/osx-homebrew.yaml osx
# generic
yaml file:///home/pi/rosdistro/rosdep/base.yaml
yaml file:///home/pi/rosdistro/rosdep/python.yaml
yaml file:///home/pi/rosdistro/rosdep/ruby.yaml
gbpdistro file:///home/pi/rosdistro/releases/fuerte.yaml fuerte
# newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead
这里把文件路径改为///home/用户名/rosdistro/…
3 修改/usr/lib/python2.7/dist-packages/rosdep2/sources_list.py文件,还是改路径
# default file to download with 'init' command in order to bootstrap
# rosdep
DEFAULT_SOURCES_LIST_URL = 'file:///home/pi/rosdistro/rosdep/sources.list.d/20-default.list'
# seconds to wait before aborting download of rosdep data
4 修改/usr/lib/python2.7/dist-packages/rosdep2/rep3.py文件:
# location of targets file for processing gbpdistro files
REP3_TARGETS_URL = 'file:///home/pi/rosdistro/releases/targets.yaml'
# seconds to wait before aborting download of gbpdistro data
还是修改路径,懒得截图了
5 修改/usr/lib/python2.7/dist-packages/rosdistro/init.py的文件:
# index information
DEFAULT_INDEX_URL = 'file:///home/pi/rosdistro/index-v4.yaml'
def get_index_url():
此时rosdep init应该就可以成功
注意:如果在rosdep update时发现有路径被忽略(显示IGN而非HIT)就说明此时路径有误,需要重新修改。修改完后要删掉rosdep init时生成的文件,然后重新init,否则修改依然无效
备注:
据说有一个鱼香ROS大佬开发的自动配置rosdep程序,这个程序我没有亲自使,但可以附上链接
wget http://fishros.com/install -O fishros && . fishros
我试过该程序里的一键安装ROS,结果不但安装失败,还把我本来的软件源删了
5 下载ROS noetic
我找的所有网上教程都说直接apt install ros-noetic-desktop即可,但在我这里始终显示找不到软件包。以下方法亲测可以解决我的问题:
sudo apt install aptitude
然后使用aptitude下载ros-desktop,而不是ros-noetic-desktop。
sudo aptitude install ros-desktop
这一步中多半会弹出依赖问题,此时aptitude的好处就是会自动创建一个解决方案,如果直接用apt就需要手动解决依赖问题。对于解决方案选yes,如果运行完该方案后还无法安装,就对当前方案选no,aptitude会自动生成下一个方案。这样一个一个试后我在第三次就成功了。
6 测试ROS
roscore
roscore能显示应该就差不多成功了,我这个linux系统没有装图形界面,小海龟模拟程序跑不了
参考文章:
https://blog.csdn.net/weixin_45315065/article/details/113420784
https://blog.csdn.net/weixin_44457994/article/details/123343885