1.執行 sudo rosdep init 失敗
反復嘗試一下,一般情況下反復個幾次,init這步就可以成功。
如果還是不成功,說明無法s從網上下載文件,需要自己新建該文件。
sudo rosdep init 這個操作最主要的工作就是從https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list,下載文件20-default.list,並把它放到/etc/ros/rosdep/sources.list.d/這個目錄下。
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失敗
這步的操作失敗原因是從raw.githubusercontent.com/下載文件失敗,可以採用其他方式上網的大佬不會執行失敗。
既然無法直接從網上下載文件,可以把文件下載 到本地然後從本地獲取,
從下面雲盤中直接下載,解壓到/etc/ros目錄下。需要超級權限。
鏈接: https://pan.baidu.com/s/1iWZF0sKXFE_-iVN48OiHAA 提取碼: rtdf
修改20-default.list腳本文件,需要超級權限。可以跟前面的腳本內容做下對比。
1 # os-specific listings first 2 #yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml osx 3 yaml file:///etc/ros/rosdistro/master/rosdep/osx-homebrew.yaml osx 4 # generic 5 #yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml 6 #yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml 7 #yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml 8 #gbpdistro https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml fuerte 9 10 yaml file:///etc/ros/rosdistro/master/rosdep/base.yaml 11 yaml file:///etc/ros/rosdistro/master/rosdep/python.yaml 12 yaml file:///etc/ros/rosdistro/master/rosdep/ruby.yaml 13 gbpdistro file:///etc/ros/rosdistro/master/releases/fuerte.yaml fuerte 14 # newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead
退出保存后,執行rosdep update。
在更新過程中,還有部分配置信息會從raw.githubusercontent.com上下載,但是反復幾次,基本上就可以成功了。
如果還是無法成功,那麼需要執行下一步:
sudo 打開/usr/lib/python2.7/dist-packages/rosdistro/__init__.py這個文件,按照下面的代碼進行修改。
1 # index information 2 3 #DEFAULT_INDEX_URL = 'https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml' 4 DEFAULT_INDEX_URL = 'file:///etc/ros/rosdistro/master/index-v4.yaml'
保存后,執行rosdep update。如果一次不成功,再執行個一兩次,應該就可以成功,出現下面的打印
1 reading in sources list data from /etc/ros/rosdep/sources.list.d 2 Hit file:///etc/ros/rosdistro/master/rosdep/osx-homebrew.yaml 3 Hit file:///etc/ros/rosdistro/master/rosdep/base.yaml 4 Hit file:///etc/ros/rosdistro/master/rosdep/python.yaml 5 Hit file:///etc/ros/rosdistro/master/rosdep/ruby.yaml 6 Hit file:///etc/ros/rosdistro/master/releases/fuerte.yaml 7 Query rosdistro index file:///etc/ros/rosdistro/master/index-v4.yaml 8 Skip end-of-life distro "ardent" 9 Skip end-of-life distro "bouncy" 10 Skip end-of-life distro "crystal" 11 Add distro "dashing" 12 Add distro "eloquent" 13 Add distro "foxy" 14 Skip end-of-life distro "groovy" 15 Skip end-of-life distro "hydro" 16 Skip end-of-life distro "indigo" 17 Skip end-of-life distro "jade" 18 Add distro "kinetic" 19 Skip end-of-life distro "lunar" 20 Add distro "melodic" 21 Add distro "noetic" 22 updated cache in /home/xxxx/.ros/rosdep/sources.cache
參考博客:https://blog.csdn.net/super_sean/article/details/105433250
ros官網安裝教程:http://wiki.ros.org/cn/kinetic/Installation/Ubuntu