设为首页 加入收藏

TOP

踩坑之旅:配置 ROS 环境(二)
2023-07-23 13:32:53 】 浏览:56
Tags:配置 ROS 环境
list 的页面找不到了。真实情况其实是这个地址的域名因为众所周知的原因被污染了,并不是页面已经下架。

我是这么处理的,在网上搜一下关键词 域名查IP 找到可以查域名对应 IP 的网站,然后根据查到的 IP 来修改 主机名静态查询表 文件。如果网站告诉你 禁止查询该域名,那就再换一个网站再查,多大点事!

我这里页面返回的结果是

物理地址 IP地址 数字地址
美国加利福尼亚旧金山 185.199.108.133 3116854405
美国加利福尼亚旧金山 185.199.111.133 3116855173
美国加利福尼亚旧金山 185.199.110.133 3116854917
美国加利福尼亚旧金山 185.199.109.133 3116854661
打开 /etc/hosts 文件,这个就是 主机名静态查询表
sudo gedit /etc/hosts

对应上边查到的 IP 地址,把下面的内容拷贝追加到 /etc/hosts 的尾部并保存

185.199.108.133 raw.githubusercontent.com
185.199.111.133 raw.githubusercontent.com
185.199.110.133 raw.githubusercontent.com
185.199.109.133 raw.githubusercontent.com

然后,再试一次

~$ sudo rosdep init
Wrote /etc/ros/rosdep/sources.list.d/20-default.list
Recommended: please run

	rosdep update

成功通过这一关,接着执行更新一下

~$ rosdep update
reading in sources list data from /etc/ros/rosdep/sources.list.d
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml
ERROR: error loading sources list:
	('The read operation timed out',)

可惜又访问失败了,这会儿报的是读操作超时。重试了好几回,没办法了,看来要动用大招~

上面说白了就是读 github 网站的资源不稳定,那么我们就找一个 github 的代理资源吧。刚好我这认识一个 https://ghproxy.com/ 支持对 github 资源代理加速,速度非常好,目前是的。

下面是应用加速代理

打开文件,这里注意一下 ROS Melodic 用的是 python2

sudo gedit /usr/lib/python2.7/dist-packages/rosdep2/sources_list.py

找到函数 download_rosdep_data,把变量 url 赋值成

url = "https://ghproxy.com/" + url

修改后效果

def download_rosdep_data(url):
    """
    :raises: :exc:`DownloadFailure` If data cannot be
        retrieved (e.g. 404, bad YAML format, server down).
    """
    try:
        # http/https URLs need custom requests to specify the user-agent, since some repositories reject
        # requests from the default user-agent.
	    url = "https://ghproxy.com/" + url
        if url.startswith("http://") or url.startswith("https://"):
            url_request = request.Request(url, headers={'User-Agent': 'rosdep/{version}'.format(version=__version__)})
        else:
            url_request = url
        f = urlopen(url_request, timeout=DOWNLOAD_TIMEOUT)
        text = f.read()
        f.close()
        data = yaml.safe_load(text)
        if type(data) != dict:
            raise DownloadFailure('rosdep data from [%s] is not a YAML dictionary' % (url))
        return data
    except (URLError, httplib.HTTPException) as e:
        raise DownloadFailure(str(e) + ' (%s)' % url)
    except yaml.YAMLError as e:
        raise DownloadFailure(str(e))

打开下面的几个文件,在所有找到的 https://raw.githubusercontent.com 字符串前添加上 https://ghproxy.com/ 保存即可。

/usr/lib/python2.7/dist-packages/rosdistro/__init__.py
/usr/lib/python2.7/dist-packages/rosdep2/gbpdistro_support.py
/usr/lib/python2.7/dist-packages/rosdep2/sources_list.py
/usr/lib/python2.7/dist-packages/rosdep2/rep3.py
/usr/lib/python2.7/dist-packages/rosdistro/manifest_provider/github.py

不过,对于文件 /usr/lib/python2.7/dist-packages/rosdep2/gbpdistro_support.py 里函数 download_gbpdistro_as_rosdep_data 的输入参数 gbpdistro_url 在应用前也需要补上加速地址

def download_gbpdistro_as_rosdep_data(gbpdistro_url, targets_url=None):
    """
    Download gbpdistro file from web and convert format to rosdep distro data.

    DEPRECATED: see REP137. This function will output
                (at least) one deprecation warning

    :param gbpdistro_url: url of gbpdistro file, ``str``
    :param target_url: override URL of platform targets file
    :raises: :exc:`
首页 上一页 1 2 3 下一页 尾页 2/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇 zabbix监控详解 下一篇Ubuntu 18.04替换默认软件源

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目