0
点赞
收藏
分享

微信扫一扫

ROS开发环境搭建及raw.githubusercontent.com链接超时问题处理

时光已翩然轻擦 2022-02-20 阅读 145

文章目录

1. 版本选择

ROS 虽然叫机器人操作系统,但它是寄生在 LINUX 操作系统之下的,更应该叫开发框架或工具集。不同的ROS版本支持不同的Ubuntu系统。我使用的是Ubuntu 20.04 + ROS 1.0 Noetic。

Ubuntu与ROS版本对应关系:

UbuntuROS 1.0ROS 2.0
16.04 LTSKinetic LTSArdent
18.04 LTSMelodic LTSDashing LTS
20.04 LTSNoetic LTSFoxy LTS

2. 安装步骤

2.1. 配置软件源

配置Ubuntu软件仓允许restricted、 universe、multiverse。仓地址可选择清华源。
image.png

2.2. 配置ROS软件源及设置秘钥
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'

curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc \
 | sudo apt-key add -
  • raw.githubusercontent.com经常超时,可以多次尝试
  • 如果想用其他镜像源可查询http://wiki.ros.org/ROS/Installation/UbuntuMirrors
2.3 安装
  1. sudo apt update 更新软件源index
  2. sudo apt install ros-noetic-desktop-full 安装ROS

3. 设置环境变量

  1. 执行source /opt/ros/noetic/setup.bash 将ROS的可执行文件加入环境变量中
  2. 可以将该命令加入到.bashrc中,这样每次shell启动都会执行source
echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc
source ~/.bashrc

4. 安装构建工具所需依赖

到此步ROS的核心包已经安装完成。管理ROS的工作空间的工具还需要安装一些依赖:
sudo apt install python3-rosdep python3-rosinstall python3-rosinstall-generator python3-wstool build-essential

4.1 安装及初始化rosdep

rosdep是更简便管理包依赖的工具,需要安装及初始化。

sudo apt install python3-rosdep
sudo rosdep init
rosdep update

5.处理raw.githubusercontent.com链接超时问题

在rosdep update过程中,raw.githubusercontent.com这个网站经常超时,大概率会导致文件下载不下来。网上给出的方案经常是改大超时时间,设置其host ip。但这种情况不一定可行,看个人运气。如果还是不行,可以手工下载代码仓,并更改rosdep的源码解决。

  1. clone代码仓https://github.com/ros/rosdistro到本地,并更改其文件rosdep/sources.list.d/20-default.list,将其url改成本地文件路径,内容类似如下:
# os-specific listings first
yaml file:///home/baby/rosdistro/rosdep/osx-homebrew.yaml osx

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

# newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead
  1. 更改rosdep源码
    由于rosdep使用python,可直接该动源码。我们需要改动三个文件:
文件更改内容
/usr/lib/python3/dist-packages/rosdep2/sources_list.pyDEFAULT_SOURCES_LIST_URL = ‘file:///home/baby/rosdistro/rosdep/sources.list.d/20-default.list’
/usr/lib/python3/dist-packages/rosdep2/rep3.pyREP3_TARGETS_URL = ‘file:///home/baby/rosdistro/releases/targets.yaml’
/usr/lib/python3/dist-packages/rosdep2/gbpdistro_support.pyFUERTE_GBPDISTRO_URL = ‘file:///home/baby/rosdistro/releases/fuerte.yaml’
/usr/lib/python3/dist-packages/rosdistro/init.pyDEFAULT_INDEX_URL = ‘file:///home/baby/rosdistro/index-v4.yaml’

完成后先把/etc/ros/rosdep/sources.list.d/20-default.list删除,再执行init与update就可以成功了。
image.png

举报

相关推荐

0 条评论