关于本地源安装
ros1和ros2采取清华镜像以后,rosdep update经常出现失败,终极解决办法是把update中需要访问的资源下载到本地,再访问。
参考https://zhuanlan.zhihu.com/p/365183222
为了防止文章链接失联,这里针对要点再罗列一下
git clone https://github.com/ros/rosdistro.git
把rosdistro clone到本地如/home/yourname/- 修改文件
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
- 修改文件
cd /usr/lib/python3/dist-packages/rosdep2/`
sudo gedit gbpdistro_support.py
替换
FUERTE_GBPDISTRO_URL = 'file:///home/yourname/rosdistro/' \ 'releases/fuerte.yaml'
- 修改文件
cd /usr/lib/python3/dist-packages/rosdep2/
sudo gedit rep3.py
替换
FUERTE_GBPDISTRO_URL = 'file:///home/yourname/rosdistro/' \ 'releases/fuerte.yaml'
- 修改文件
cd /usr/lib/python3/dist-packages/rosdistro/
sudo gedit __init__.py
替换
DEFAULT_INDEX_URL = 'file:///home/yourname/rosdistro/index-v4.yaml'
- 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
source /opt/ros/noetic/setup.bash
rosdep update
printenv | grep -i ROS
打开一个新的terminal
source /opt/ros/foxy/setup.bash
rosdep update
printenv | grep -i ROS