如果sudo rosdep init
和 rosdep update
没有执行成功,有些ROS功能会无法执行,比如rqt_tf_tree
会报错:1
2the rosdep view is empty: call 'sudo rosdep init' and 'rosdep update'
[WARN] wait_for_service(/rqt_gui_py_node_26204/tf2_frames): failed to contact, will keep trying
这两个老大难其实都是网络的问题,sudo rosdep init
的目的是为了在/etc目录下新建/ros/rosdep/sources.list.d/20-default.list
文件。
小鱼基于rosdep源码制作了rosdepc,专门服务国内ROS用户,使用pip3 和 rosdepc 可以彻底消灭这个问题1
2
3
4
5sudo apt-get install python3-pip
sudo pip3 install rosdepc
sudo rosdepc init
rosdepc update
rosdep update
根据20-default.list
文件中的网址链接去下载相应的文件,最终在/etc/ros/rosdep
下放5个文件,分别是base.yaml,gentoo.yaml,osx-homebrew.yaml,python.yaml,ruby.yaml. 但又做了一些配置,所以不是下载文件能解决的。
以下步骤先从网上下载rosdistro
文件夹,放到/etc/ros
执行sudo rosdep init
后报错
1 | ERROR: cannot download default sources list from: |
从网上直接下载这个文件,然后放到/etc/ros/rosdep/sources.list.d
,再修改如下:1
2
3
4
5
6
7
8
9
10
11# os-specific listings first
yaml file:///etc/ros/rosdistro/rosdep/osx-homebrew.yaml osx
# generic
yaml file:///etc/ros/rosdistro/rosdep/base.yaml
yaml file:///etc/ros/rosdistro/rosdep/python.yaml
yaml file:///etc/ros/rosdistro/rosdep/ruby.yaml
gbpdistro file:///etc/ros/rosdistro/releases/fuerte.yaml fuerte
# newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead
rosdep update 报错
kinetic 要修改python2.7的路径, melodic和noetic要修改python3 ,当然另一种方法是从其他电脑拷贝已经生成的文件。
kinetic 的修改1
2reading in sources list data from /etc/ros/rosdep/sources.list.d
ERROR: unable to process source
对下面三个文件做修改1
2
3
4
5
6
7
8
9
10/usr/lib/python2.7/dist-packages/rosdep2/gbpdistro_support.py
修改: FUERTE_GBPDISTRO_URL = 'file:///etc/ros/rosdistro/releases/fuerte.yaml'
/usr/lib/python2.7/dist-packages/rosdep2/rep3.py
修改: REP3_TARGETS_URL = 'file:///etc/ros/rosdistro/releases/targets.yaml'
/usr/lib/python2.7/dist-packages/rosdistro/__init__.py
修改: DEFAULT_INDEX_URL = 'file:///etc/ros/rosdistro/index-v4.yaml'
启动新终端,再次执行rosdep update
melodic和noetic 的修改:clone代码仓https://github.com/ros/rosdistro
到本地,并更改其文件rosdep/sources.list.d/20-default.list
,将其url改成本地文件路径,内容类似如下:1
2
3
4
5
6
7
8# os-specific listings first
yaml file:///home/baby/rosdistro/rosdep/osx-homebrew.yaml osx
# generic
yaml file:///home/baby/rosdistro/rosdep/base.yaml
yaml file:///home/baby/rosdistro/rosdep/python.yaml
yaml file:///home/baby/rosdistro/rosdep/ruby.yaml
gbpdistro file:///home/baby/rosdistro/releases/fuerte.yaml fuerte
由于rosdep使用python3,可直接该动源码。我们需要改动三个文件:
/usr/lib/python3/dist-packages/rosdep2/sources_list.py
,修改DEFAULT_SOURCES_LIST_URL = 'file:///home/baby/rosdistro/rosdep/sources.list.d/20-default.list'
/usr/lib/python3/dist-packages/rosdep2/rep3.py
,修改REP3_TARGETS_URL = 'file:///home/baby/rosdistro/releases/targets.yaml'
/usr/lib/python3/dist-packages/rosdep2/gbpdistro_support.py
,修改FUERTE_GBPDISTRO_URL = 'file:///home/baby/rosdistro/releases/fuerte.yaml'
/usr/lib/python3/dist-packages/rosdistro/__init__.py
,修改DEFAULT_INDEX_URL = 'file:///home/baby/rosdistro/index-v4.yaml'
完成后先把/etc/ros/rosdep/sources.list.d/20-default.list
删除,再执行sudo rosdep init
与rosdep update
就可以成功了。