rosdep update 本地化


你是否在安装ros 和实际应用过程中执行 rosdep update 一直无法成功,提示链接 https://raw.github 相关的链接无法成功。
现在有两种方式处理,一种是直接修改远程对应的链接位置,是可以命令行过程中可以连接上;
另外一种就是将链接调整为本地化操作

1.远程链接化

参考fishros的操作

 wget http://fishros.com/install -O fishros && . fishros
  [3]:一键安装:rosdep(小鱼的rosdepc,又快又好用)

参考 tool_config_rosdep.py

# -*- coding: utf-8 -*-
from .base import BaseTool
from .base import PrintUtils,CmdTask,FileUtils,AptUtils,ChooseTask
from .base import osversion
from .base import run_tool_file

class Tool(BaseTool):
    def __init__(self):
        self.type = BaseTool.TYPE_CONFIG
        self.name = "模板工程"
        self.autor = '小鱼'

    def install_rosdepc(self):
        CmdTask("sudo apt install python3-pip -y", 0).run()
        CmdTask("sudo pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple rosdepc", 0).run()
        CmdTask("sudo rosdepc init", 0).run()
        CmdTask("sudo rosdepc fix-permissions", 0).run()
        PrintUtils.print_info('已为您安装好rosdepc,请使用:\nrosdepc update \n进行测试更新,最后欢迎关注微信公众号《鱼香ROS》')


    def run(self):
        #正式的运行
        self.install_rosdepc()

执行更新成功

rosdepc update
reading in sources list data from /etc/ros/rosdep/sources.list.d
Warning: running 'rosdep update' as root is not recommended.
  You should run 'sudo rosdep fix-permissions' and invoke 'rosdep update' again without sudo.
Hit https://mirrors.tuna.tsinghua.edu.cn/github-raw/ros/rosdistro/master/rosdep/osx-homebrew.yaml
Hit https://mirrors.tuna.tsinghua.edu.cn/github-raw/ros/rosdistro/master/rosdep/base.yaml
Hit https://mirrors.tuna.tsinghua.edu.cn/github-raw/ros/rosdistro/master/rosdep/python.yaml
Hit https://mirrors.tuna.tsinghua.edu.cn/github-raw/ros/rosdistro/master/rosdep/ruby.yaml
Query rosdistro index https://mirrors.tuna.tsinghua.edu.cn/rosdistro/index-v4.yaml
Skip end-of-life distro "ardent"
Skip end-of-life distro "bouncy"
Skip end-of-life distro "crystal"
Skip end-of-life distro "dashing"
Skip end-of-life distro "eloquent"
Skip end-of-life distro "foxy"
Skip end-of-life distro "galactic"
Skip end-of-life distro "groovy"
Add distro "humble"
Skip end-of-life distro "hydro"
Skip end-of-life distro "indigo"
Add distro "iron"
Skip end-of-life distro "jade"
Skip end-of-life distro "kinetic"
Skip end-of-life distro "lunar"
Skip end-of-life distro "melodic"
Add distro "noetic"
Add distro "rolling"
updated cache in /root/.ros/rosdep/sources.cache

但是还是在源码安装ros(ubuntu22.04 + noetic),使用其它的dep工具执行中还是有问题

/opt/ros/noetic_ws$ rosinstall_generator desktop --rosdistro noetic --deps --tar > noetic-desktop.rosinstall
Traceback (most recent call last):
  File "/usr/lib/python3.10/urllib/request.py", line 1348, in do_open
    h.request(req.get_method(), req.selector, req.data, headers,
  File "/usr/lib/python3.10/http/client.py", line 1283, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.10/http/client.py", line 1329, in _send_request

2. 本地rosdep链接化

参考原博客:ROS与gazebo中常见问题【持续更新中】rosdep update time out及失败解决方案

2.1 indigo kinetic melodic 对应 python2 的处理

  1. clone rosdistro 到本地
mkdir -p ~/.ros/rosdep
cd ~/.ros/rosdep
git clone https://github.com/ros/rosdistro

修改本地repo内链接
cat rosdep/sources.list.d/20-default.list

yaml file:///home/robot/.ros/rosdep/rosdistro/rosdep/osx-homebrew.yaml osx

# generic
yaml file:///home/kint/.ros/rosdep/rosdistro/rosdep/base.yaml
yaml file:///home/kint/.ros/rosdep/rosdistro/rosdep/python.yaml
yaml file:///home/kint/.ros/rosdep/rosdistro/rosdep/ruby.yaml
gbpdistro file:///kint/robot/.ros/rosdep/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. 修改 20-default.list 连接为本地下载的rosdistro 里面的对应文件
    将文件中的网址https://raw.githubusercontent.com/ros/rosdistro/master修改为下载目录file:///home/xxx/rosdistro
    sudo vim /etc/ros/rosdep/sources.list.d/20-default.list

yaml file:///home/kint/.ros/rosdep/rosdistro/rosdep/osx-homebrew.yaml osx

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

#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
  1. 修改sources_list.py文件
sudo gedit /usr/lib/python2.7/dist-packages/rosdep2/sources_list.py

#DEFAULT_SOURCES_LIST_URL = 'https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list'
DEFAULT_SOURCES_LIST_URL = 'file:///etc/ros/rosdep/sources.list.d/20-default.list'
  1. 修改rep3.py
sudo gedit /usr/lib/python2.7/dist-packages/rosdep2/rep3.py

REP3_TARGETS_URL = 'file:///home/kint/.ros/rosdep/rosdistro/releases/targets.yaml'
#REP3_TARGETS_URL = 'https://raw.githubusercontent.com/ros/rosdistro/master/releases/targets.yaml'
  1. . 修改_init_.py文件
sudo gedit /usr/lib/python2.7/dist-packages/rosdistro/__init__.py

DEFAULT_INDEX_URL = 'file:///home/kint/.ros/rosdep/rosdistro/index-v4.yaml'
#DEFAULT_INDEX_URL = 'https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml'
  1. 重新更新
sudo rosdep init
       如果20-default.list 已经存在,可以先删除,再执行一遍sudo rosdep init
rosdep update

---------正确更新的log

 kint@kint:~/.ros/rosdep$ rosdep update
reading in sources list data from /etc/ros/rosdep/sources.list.d
Hit file:///home/kint/.ros/rosdep/rosdistro/rosdep/osx-homebrew.yaml
Hit file:///home/kint/.ros/rosdep/rosdistro/rosdep/base.yaml
Hit file:///home/kint/.ros/rosdep/rosdistro/rosdep/python.yaml
Hit file:///home/kint/.ros/rosdep/rosdistro/rosdep/ruby.yaml
Hit file:///home/kint/.ros/rosdep/rosdistro/releases/fuerte.yaml
Query rosdistro index file:///home/kint/.ros/rosdep/rosdistro/index-v4.yaml
Skip end-of-life distro "ardent"
Skip end-of-life distro "bouncy"
Skip end-of-life distro "crystal"
Skip end-of-life distro "dashing"
Skip end-of-life distro "eloquent"
Add distro "foxy"
Add distro "galactic"
Skip end-of-life distro "groovy"
Add distro "humble"
Skip end-of-life distro "hydro"
Skip end-of-life distro "indigo"
Skip end-of-life distro "jade"
Skip end-of-life distro "kinetic"
Skip end-of-life distro "lunar"
Add distro "melodic"
Add distro "noetic"
Add distro "rolling"
updated cache in /home/kint/.ros/rosdep/sources.cache
-----------------

2.2 noetic对应 python2 的处理

ubuntu 22.04对应python3相关的

下载rosdep到本地

mkdir -p  ~/.ros/rosdep
cd  ~/.ros/rosdep
git clone git@github.com:ros/rosdistro.git 

修改repo内链接

robot@robot:~/.ros/rosdep/rosdistro$ git status 
	modified:   rosdep/sources.list.d/20-default.list

robot@robot:~/.ros/rosdep/rosdistro$ git diff 
diff --git a/rosdep/sources.list.d/20-default.list b/rosdep/sources.list.d/20-default.list
index fb6744c4d..d232d62af 100644
--- a/rosdep/sources.list.d/20-default.list
+++ b/rosdep/sources.list.d/20-default.list
@@ -1,10 +1,10 @@
-# os-specific listings first
-yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml osx
+ 
+yaml file:///home/robot/.ros/rosdep/rosdistro/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
+yaml file:///home/robot/.ros/rosdep/rosdistro/rosdep/base.yaml
+yaml file:///home/robot/.ros/rosdep/rosdistro/rosdep/python.yaml
+yaml file:///home/robot/.ros/rosdep/rosdistro/rosdep/ruby.yaml
+gbpdistro file:///home/robot/.ros/rosdep/rosdistro/releases/fuerte.yaml fuerte
+ 
+# newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead
\ No newline at end of file

cat rosdep/sources.list.d/20-default.list

yaml file:///home/robot/.ros/rosdep/rosdistro/rosdep/osx-homebrew.yaml osx

# generic
yaml file:///home/robot/.ros/rosdep/rosdistro/rosdep/base.yaml
yaml file:///home/robot/.ros/rosdep/rosdistro/rosdep/python.yaml
yaml file:///home/robot/.ros/rosdep/rosdistro/rosdep/ruby.yaml
gbpdistro file:///home/robot/.ros/rosdep/rosdistro/releases/fuerte.yaml fuerte
 
# newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead

修改链接为本地
sudo gedit /etc/ros/rosdep/sources.list.d/20-default.list

yaml file:///home/robot/.ros/rosdep/rosdistro/rosdep/osx-homebrew.yaml osx

# generic
yaml file:///home/robot/.ros/rosdep/rosdistro/rosdep/base.yaml
yaml file:///home/robot/.ros/rosdep/rosdistro/rosdep/python.yaml
yaml file:///home/robot/.ros/rosdep/rosdistro/rosdep/ruby.yaml
gbpdistro file:///home/robot/.ros/rosdep/rosdistro/releases/fuerte.yaml fuerte
 
# newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead

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

#DEFAULT_SOURCES_LIST_URL = 'https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list'
DEFAULT_SOURCES_LIST_URL = 'file:///home/robot/.ros/rosdep/rosdistro/rosdep/sources.list.d/20-default.list'

sudo gedit /usr/lib/python3/dist-packages/rosdep2/rep3.py

#REP3_TARGETS_URL = 'https://raw.githubusercontent.com/ros/rosdistro/master/releases/targets.yaml'
REP3_TARGETS_URL = 'file:///home/robot/.ros/rosdep/rosdistro/releases/targets.yaml'

sudo gedit /usr/lib/python3/dist-packages/rosdistro/init.py

#DEFAULT_INDEX_URL = 'https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml'
DEFAULT_INDEX_URL = 'file:///home/robot/.ros/rosdep/rosdistro/index-v4.yaml'

命令更新

sudo rm /etc/ros/rosdep/sources.list.d/20-default.list 
sudo rosdep init
rosdep update

成功输出:

robot@robot:~$ rosdep update
reading in sources list data from /etc/ros/rosdep/sources.list.d
Hit file:///home/robot/.ros/rosdep/rosdistro/rosdep/osx-homebrew.yaml
Hit file:///home/robot/.ros/rosdep/rosdistro/rosdep/base.yaml
Hit file:///home/robot/.ros/rosdep/rosdistro/rosdep/python.yaml
Hit file:///home/robot/.ros/rosdep/rosdistro/rosdep/ruby.yaml
Hit file:///home/robot/.ros/rosdep/rosdistro/releases/fuerte.yaml
Query rosdistro index file:///home/robot/.ros/rosdep/rosdistro/index-v4.yaml
Skip end-of-life distro "ardent"
Skip end-of-life distro "bouncy"
Skip end-of-life distro "crystal"
Skip end-of-life distro "dashing"
Skip end-of-life distro "eloquent"
Skip end-of-life distro "foxy"
Skip end-of-life distro "galactic"
Skip end-of-life distro "groovy"
Add distro "humble"
Skip end-of-life distro "hydro"
Skip end-of-life distro "indigo"
Add distro "iron"
Skip end-of-life distro "jade"
Skip end-of-life distro "kinetic"
Skip end-of-life distro "lunar"
Skip end-of-life distro "melodic"
Add distro "noetic"
Add distro "rolling"
updated cache in /home/robot/.ros/rosdep/sources.cache

### 解决Ubuntu 20.04上`rosdep update`的问题 #### 修改配置文件以适应国内网络环境 对于在Ubuntu 20.04上遇到的`rosdep update`命令执行失败的情况,可以考虑通过编辑特定Python脚本来绕过国外服务器造成的连接障碍。具体操作如下: 针对`gbpdistro_support.py`文件,在路径`/usr/lib/python3/dist-packages/rosdep2/`下找到此文件并打开进行编辑[^5]。将默认指向GitHub仓库URL的部分更改为能够稳定访问的镜像源链接,例如Gitee上的对应资源位置。 ```python FUERTE_GBPDISTRO_URL = 'https://gitee.com/zhao-xuzuo/rosdistro/raw/master/releases/fuerte.yaml' ``` 上述更改使得ROS依赖项可以从国内托管平台获取,从而提高下载成功率和速度。 #### 手动初始化与更新rosdep数据库 另外一种有效的方式是分步处理`rosdep init`以及后续的`rosdep update`指令而不是一次性运行它们[^4]。这样做有助于定位可能存在的个别环节错误,并给予用户更多机会去修正潜在问题。 先单独执行`sudo rosdep init`完成初始化工作;之后再尝试`rosdep update`来同步最新的包列表信息。如果仍然存在超时现象,则可参照前述方法调整相关参数设置或者更换为其他可用的数据源地址。 #### 调整系统时间与时区设置 有时主机的时间不同步也会引发SSL证书验证失败等问题进而影响到HTTPS请求的成功率。因此确认本地计算机的时间准确无误同样重要。可以通过安装NTP服务自动校准时间戳,确保客户端与远程服务器之间保持一致。 ```bash sudo apt install ntp sudo timedatectl set-ntp true timedatectl status ``` 以上措施综合运用通常能较好地解决因网络条件不佳而导致的`rosdep update`困难状况。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值