ubuntu18.04 安装ros

Ubuntu18.04 ros 安装

参照(https://blog.csdn.net/weixin_44023934/article/details/121242176)vs(http://www.autolabor.com.cn/book/ROSTutorials/chapter1/12-roskai-fa-gong-ju-an-zhuang/124-an-zhuang-ros.html)

  1. 首先打开“软件和更新”对话框,打开后"restricted", "universe," 和 "multiverse."前是打上勾

  1. 安装国内清华的安装源:

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

2. 设置key

sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654

3.更新 apt

sudo apt update

4. 安装所需类型的 ROS(Desktop-Full、Desktop、ROS-Base )

sudo apt install ros-melodic-desktop-full

5. 配置环境变量

echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc

source ~/.bashrc

6.安装构建依赖

sudo apt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essential

7. 初始化rosdep

sudo rosdep init

rosdep update

问题:

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.

解决:

  1. .首先将下面仓库的内容clone到本地

git clone GitHub - ros/rosdistro: This repo maintains a lists of repositories for each ROS distribution

2.

2.1将下载包名字rosdistro-master改称rosdistro

2.2.下载后,记录rosdistro存放地址,例如/home/张三/rosdistro

你自己的改成/home/你的用户名/rosdistro,将下载的文件移植到系统文件/etc/ros内,统一路径:

sudo cp -r /home/张三/rosdistro /etc/ros/ rosdistro

3. 修改/usr/lib/python2.7/dist-packages/rosdep2/rep3.py文件

cd /usr/lib/python2.7/dist-packages/rosdep2

sudo gedit rep3.py

将原来文件中的 DEFAULT_INDEX_URL = ‘https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml’ 替换成 DEFAULT_INDEX_URL = 'file:///etc/ros/rosdistro/index-v4.yaml'

4.配置20-default.list文件

查看/etc/ros/rosdep/sources.list.d路径已经有20-default.list文件

(之前已经运行过sudo rosdep init的原因),就直接跳过4.1步奏,运行4.2步奏,

4.1、创建文件夹sources.list.d,并生成20-default.list 文件

 sudo mkdir -p /etc/ros/rosdep/sources.list.d 

生成20-default.list

cd /etc/ros/rosdep/sources.list.d 

sudo touch 20-default.list

到这里已经生成/etc/ros/rosdep/sources.list.d/20-default.list文件

4.2、打开20-default.list文件,将里面内容修改为下面的代码

sudo gedit /etc/ros/rosdep/sources.list.d/20-default.list

内容改成:

# os-specific listings first

yaml file:///etc/ros/rosdistro/rosdep/osx-homebrew.yaml osx

# generic

yaml file:///etc/ros/rosdistro/rosdep/base.yaml

yaml file:///etc/ros/rosdistro/rosdep/python.yaml

yaml file:///etc/ros/rosdistro/rosdep/ruby.yaml

gbpdistro file:///etc/ros/rosdistro/releases/fuerte.yaml fuerte

# newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead

注意的是yaml file://表示固定格式/etc/ros..表示文件目录,所以是yaml file:///

4.3.更改20-defaultlist.list 指向路径

进入python2.7依赖里查找路径

cd /usr/lib/python2.7/dist-packages/

查找20-defaultlist.list链接

find . -type f | xargs grep "https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-defaultlist.list "  

查找到./rosdep2/ sources.list.py中DEFAULT_SOURCES_LIST_URL=’ https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-defaultlist.list ’

进入文件更改路径;

sudo gedit ./rosdep2/ sources.list.py

用以下链接替换DEFAULT_SOURCES_LIST_URL=‘。。。。。。。。。。。。’的链接

file:///etc/ros/rosdistro/rosdep/sources.list.d/20-defaultlist.list

5.重新执行:

sudo rosdep init

rosdep update

Ubuntu20.04 参照:

http://www.autolabor.com.cn/book/ROSTutorials/chapter1/12-roskai-fa-gong-ju-an-zhuang/124-an-zhuang-ros.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值