ros版本的相互切换

关于本地源安装

ros1和ros2采取清华镜像以后,rosdep update经常出现失败,终极解决办法是把update中需要访问的资源下载到本地,再访问。
参考https://zhuanlan.zhihu.com/p/365183222
为了防止文章链接失联,这里针对要点再罗列一下

  1. git clone https://github.com/ros/rosdistro.git 把rosdistro clone到本地如/home/yourname/
  2. 修改文件
    cd /home/yourname/rosdistro/rosdep/sources.list.d/
    sudo gedit 20-default.list
    替换成以下内容
# os-specific listings first
yaml file:///home/yourname/rosdistro/rosdep/osx-homebrew.yaml osx

# generic
yaml file:///home/yourname/rosdistro/rosdep/base.yaml
yaml file:///home/yourname/rosdistro/rosdep/python.yaml
yaml file:///home/yourname/rosdistro/rosdep/ruby.yaml
gbpdistro file:///home/yourname/rosdistro/releases/fuerte.yaml fuerte
  1. 修改文件
cd /usr/lib/python3/dist-packages/rosdep2/`
sudo gedit gbpdistro_support.py

替换
FUERTE_GBPDISTRO_URL = 'file:///home/yourname/rosdistro/' \ 'releases/fuerte.yaml'

  1. 修改文件
cd /usr/lib/python3/dist-packages/rosdep2/
sudo gedit rep3.py

替换
FUERTE_GBPDISTRO_URL = 'file:///home/yourname/rosdistro/' \ 'releases/fuerte.yaml'

  1. 修改文件
cd /usr/lib/python3/dist-packages/rosdistro/
sudo gedit __init__.py

替换
DEFAULT_INDEX_URL = 'file:///home/yourname/rosdistro/index-v4.yaml'

  1. ros init的等价修改形式
    如果你已经使用了sudo rosdep init
cd /etc/ros/rosdep/sources.list.d
sudo gedit 20-default.list

如果提示文件不存在,创建这个文件之后再使用上面的命令行
sudo mkdir -p /etc/ros/rosdep/sources.list.d
将下面的内容复制到文件并且保存

#os-specific listings first
yaml file:///home/yourname/rosdistro/rosdep/osx-homebrew.yaml osx
#generic
yaml file:///home/yourname/rosdistro/rosdep/base.yaml
yaml file:///home/yourname/rosdistro/rosdep/python.yaml
yaml file:///home/yourname/rosdistro/rosdep/ruby.yaml
gbpdistro file:///home/yourname/rosdistro/releases/fuerte.yaml fuerte

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

切换

以ubuntu20为例,分别安装完ros noetic和foxy版本,打开一个terminal

  1. source /opt/ros/noetic/setup.bash
  2. rosdep update
  3. printenv | grep -i ROS

打开一个新的terminal

  1. source /opt/ros/foxy/setup.bash
  2. rosdep update
  3. printenv | grep -i ROS
  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值