Ubuntu18安装ROS melodic

在不同电脑上安装了很多次ros,有在执行rosdep init报错的,有在执行rosdep update报错的,前者报错的可能是源的问题或者是密钥不是最新的,后者报错是从github上下载失败,可能是网络或源的问题,有些博主只是更换源或者换手机热点就解决了问题,但是我今天安装最简版ros的时候所有方法都试过了还是没能update成功,最后借鉴了一个博主的离线安装解决了问题。

一个rosdep init报错解决方案:本文之后,世上再无rosdep更新失败问题!如果有....小鱼就... - 知乎

一个rosdep update报错解决方案(离线安装):ubuntu18.04安装ros Melodic(实测可用)_熙铭在学习的博客-CSDN博客

建议:如果是第一次安装ros,尽量参考官网的教程来安装,因为网上很多源的连接可能不是最新的,如果按照官网安装不成功再找其他资源。大家根据自己的内核版本来选择安装方案:我本次安装的内核是arm架构的,不过安装方式都是大同小异的。

Installation - ROS Wiki

 软件源:

官网:

$ sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'

中科大:(有些人说速度快,有些人说不建议用)

$ 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'

清华的:

$ sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu/ $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/ros-latest.list'

我本次使用的官网的。

密钥:

新密钥:

$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F42ED6FBAB17C654

旧密钥:

$ sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116

之前使用过旧密钥更新,会有问题,还是要换成新的密钥,这部分需要关注,因为现在网上还有很多资源是旧的。

本次需要安装的是最简版的ros  melodic,简称“最小系统”,官网上面有很多个版本,一般建议安装桌面完整版(ros-melodic-desktop-full),这个是最详细的版本。可以根据自己需求进行安装,如果要安装kenitic,可查看官网相关的版本。

安装ros:

$ sudo apt-get update
$ sudo apt-get install ros-melodic-ros-base

初始化:

$ sudo apt install python-rosdep
$ sudo rosdep init
$ rosdep update

要先安装rosdep,不然在rosdep init时会报错。

我在rosdep update这一步时一直报错,更换源、换网络、换手机热点都不行,查看了此博文进行了离线安装:ubuntu18.04安装ros Melodic(实测可用)_熙铭在学习的博客-CSDN博客

先写在前面:

第一步:

$ git clone https://github.com/ros/rosdistro.git 这一步可能会克隆不成功,直接到官网:https://github.com/ros/rosdistro  下载压缩包,然后解压到/home/username目录下即可。注意username 为你自己的用户名,解压后的名字是啥后面需要修改的文字就是啥,也可以将解压后的名字重命名成下面的名字。

第二步:如果前面是在线安装的,直到rosdep update这一步才报错的话,先查看sources.list.d这个文件是否已经存在并且里面是有东西的,如果已经存在就不需要再重新创建此文件,直接进行下面的步骤即可。需要注意的是修改的文件路径一定要与自己存放的路径一致,不然还会报错。

1. 下载文件到本地  (假设你的用户名为 username)
# 假设你的用户名为 username 
cd ~
git clone https://github.com/ros/rosdistro.git
# 此时主文件夹目录下出现rosdistro文件夹,路径为/home/username/rosdistro
2. 创建20-default.list文件 
# 手动创建脚本所需的文件
sudo mkdir -p /etc/ros/rosdep/sources.list.d
cd /etc/ros/rosdep/sources.list.d
sudo gedit 20-default.list
# 输入以下内容并保存: 注意 username 改为你自己的用户名

# os-specific listings first
yaml file:///home/username/rosdistro/rosdep/osx-homebrew.yaml osx

# generic
yaml file:///home/username/rosdistro/rosdep/base.yaml
yaml file:///home/username/rosdistro/rosdep/python.yaml
yaml file:///home/username/rosdistro/rosdep/ruby.yaml
gbpdistro file:///home/username/rosdistro/releases/fuerte.yaml fuerte

# newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead
3. 修改脚本URL为本地路径 (注意 username 改为你自己的用户名)
cd /usr/lib/python2.7/dist-packages/rosdep2/
sudo gedit gbpdistro_support.py
# 将 FUERTE_GBPDISTRO_URL 后面路径改为如下,并保存
FUERTE_GBPDISTRO_URL = 'file:///home/username/rosdistro/releases/fuerte.yaml'
cd /usr/lib/python2.7/dist-packages/rosdep2/
sudo gedit rep3.py
# 将 REP3_TARGETS_URL 后面路径改为如下,并保存
REP3_TARGETS_URL = 'file:///home/username/rosdistro/releases/targets.yaml'
cd /usr/lib/python2.7/dist-packages/rosdistro/
sudo gedit __init__.py
# 将 DEFAULT_INDEX_URL 后面路径改为如下,并保存
DEFAULT_INDEX_URL = 'file:///home/username/rosdistro/index-v4.yaml'
4. 启动更新命令
rosdep update
# 输出如下:
reading in sources list data from /etc/ros/rosdep/sources.list.d
Hit file:///home/silencht/rosdistro/rosdep/osx-homebrew.yaml
Hit file:///home/silencht/rosdistro/rosdep/base.yaml
Hit file:///home/silencht/rosdistro/rosdep/python.yaml
Hit file:///home/silencht/rosdistro/rosdep/ruby.yaml
Hit file:///home/silencht/rosdistro/releases/fuerte.yaml
Query rosdistro index file:///home/silencht/rosdistro/index-v4.yaml
Skip end-of-life distro "ardent"
Skip end-of-life distro "bouncy"
Skip end-of-life distro "crystal"
Skip end-of-life distro "dashing"
Skip end-of-life distro "eloquent"
Add distro "foxy"
Add distro "galactic"
Skip end-of-life distro "groovy"
Skip end-of-life distro "hydro"
Skip end-of-life distro "indigo"
Skip end-of-life distro "jade"
Skip end-of-life distro "kinetic"
Skip end-of-life distro "lunar"
Add distro "melodic"
Add distro "noetic"
Add distro "rolling"
updated cache in /home/silencht/.ros/rosdep/sources.cache

离线更新成功。

安装rosinstall:

$ sudo apt-get install python-rosinstall

添加环境配置文件:

$ source /opt/ros/melodic/setup.bash

至此,ros melodic最简版安装并配置成功,由于是最简版,所以没办法查看小海龟,直接运行$ roscore查看是否安装成功。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值