网上有在/etc/hosts中添加ip地址的方法,使用了不成功,具体做法如下,仅供参考:
a.打开查询ip的网址:
https://site.ip138.com
b.输入:
raw.githubusercontent.com
c.执行sudo vi /etc/hosts
将获取到的ip添加到该文件下即可
采用了一下方法顺利解决了
1. sudo rosdep init失败问题
1.1 在本地创建rosdep init会生成的文件
sudo mkdir -p /etc/ros/rosdep/sources.list.d
cd /etc/ros/rosdep/sources.list.d
sudo vim 20-default.list
1.2 将一下内容复制到20-default.list中
# os-specific listings first
yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml osx
# generic
yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml
yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml
yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml
gbpdistro https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml fuerte
# newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead
2. rosdep update问题
超时的原因主要是从国外的服务器下载东西,因此可以采用github添加代理的方式来解决。
2.1 修改sources_list.py
sudo vim /usr/lib/python3/dist-packages/rosdep2/sources_list.py
找到303行添加
url="https://ghproxy.com/"+url
最后如图:
2.2 修改 __ init__.py
sudo vim /usr/lib/python3/dist-packages/rosdistro/__init__.py
找到68行, 在原网址上添加“https://ghproxy.com/”
DEFAULT_INDEX_URL = 'https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml'
最后结果如图:
2.3 修改 gbpdistro_support.py
sudo vim /usr/lib/python3/dist-packages/rosdep2/gbpdistro_support.py
找到34行,修改FUERTE_GBPDISTRO_URL 的地址, 在原网址上添加“https://ghproxy.com/”
FUERTE_GBPDISTRO_URL = 'https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/' \
'master/releases/fuerte.yaml'
结果如下图:
2.4 修改sources_list.py
sudo vim /usr/lib/python3/dist-packages/rosdep2/sources_list.py
找到64行,修改DEFAULT_SOURCES_LIST_URL, 在原网址上添加“https://ghproxy.com/”
DEFAULT_SOURCES_LIST_URL = 'https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list'
最后结果如下图:
2.5 修改rep3.py
sudo vim /usr/lib/python3/dist-packages/rosdep2/rep3.py
找到36行,修改REP3_TARGETS_URL,在原网址上添加“https://ghproxy.com/”
REP3_TARGETS_URL = 'https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/releases/targets.yaml'
最后结果如下图:
2.6 修改github.py
sudo vim /usr/lib/python3/dist-packages/rosdistro/manifest_provider/github.py
找到68行,在原网址上添加“https://ghproxy.com/”
url = 'https://ghproxy.com/https://raw.githubusercontent.com/%s/%s/package.xml' % (path, release_tag)
最后结果如下图:
找到119行, 在原网址上添加“https://ghproxy.com/”
for package_xml_path in package_xml_paths:
url = 'https://ghproxy.com/https://raw.githubusercontent.com/%s/%s/%s' % \
(path, cache.ref(), package_xml_path + '/package.xml' if package_xml_path else 'package.xml')
最后结果如下图:
2.7 修改
sudo vim /usr/lib/python3/dist-packages/rosdep2/gbpdistro_support.py
找到202行, 在原网址上添加“https://ghproxy.com/”
gbpdistro_url = "https://ghproxy.com/" + gbpdistro_url
最后结果如下图:
3. 验证
执行
rosdep update
即可