Ubuntu16.04+ROS Kinetict rosdep init 和 rosdep update出错解决方法

手把手教你解决,刚刚解决,趁着热乎记录以下
copy了两位大神的解决方法
解决安装ROS时出现的sudo rosdep init错误问题
Ubuntu16.04安装ROS Kinetic 时,sudo rosdep init 及 rosdep update 报错问题的解决

sudo rosdep init
[sudo] password for chn: 
ERROR: cannot download default sources list from:
https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list
Website may be down.

rosdep init 出错

干脆把 rosdep init 的内容下载下来

chn@ubuntu:~$ git clone https://github.com/ros/rosdistro.git
The program 'git' is currently not installed. You can install it by typing:
sudo apt install git

我这里git 不成功是因为没有安装git,没有出错可以不理

chn@ubuntu:~$ sudo apt-get install git

然后再git成功

chn@ubuntu:~$ git clone https://github.com/ros/rosdistro.git
Cloning into 'rosdistro'...
remote: Enumerating objects: 165803, done.
remote: Counting objects: 100% (225/225), done.
remote: Compressing objects: 100% (111/111), done.
remote: Total 165803 (delta 112), reused 143 (delta 63), pack-reused 165578
Receiving objects: 100% (165803/165803), 101.12 MiB | 1.37 MiB/s, done.
Resolving deltas: 100% (99752/99752), done.
Checking connectivity... done.

然后手工创建原本由 rosdep init创建的东西

sudo mkdir -p /etc/ros/rosdep/sources.list.d

我这里会报错因为权限不够创建不了,所以加一个sudo,也可以直接mkdir

然后把git的rosdistro 克隆一份到20-default.list

chn@ubuntu:~$ cd rosdistro
chn@ubuntu:~/rosdistro$ sudo cp rosdep/sources.list.d/20-default.list /etc/ros/rosdep/sources.list.d/

如果在这里克隆的这个20-default.list不成功的话不用理也行,直接看后面,因为我在这里好像出了点错,也是 干脆自己建了一个
如果不出错的话下面的三行指令不要输入,输入也没事,反正就是重新建立一个而已。

chn@ubuntu:~$ cd /etc/ros/rosdep/sources.list.d
chn@ubuntu:/etc/ros/rosdep/sources.list.d$ sudo rm -rf 20-default.list
chn@ubuntu:/etc/ros/rosdep/sources.list.d$ sudo gedit 20-default.list

没有改过的20-default.list里面的内容应该长下面这样,上面的第二行代码rm -rf是删除的意思,上面的第三行意思是新建 sudo gedit 一个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

找到下载的rosdistro的绝对路径,我 这里是直接下载到home的
我的下载的绝对路径是/home/chn/rosdistro
可以验证一下

chn@ubuntu:~$ cd /home/chn/rosdistro
chn@ubuntu:~/rosdistro$ 

你的路径应该是/home/用户名/rosdistro
用户名看你自己的命令行是什么@ubuntu就是什么

chn@ubuntu:~$ cd /etc/ros/rosdep/sources.list.d
chn@ubuntu:/etc/ros/rosdep/sources.list.d$ sudo gedit 20-default.list

然后改,将这里面的https://raw.githubusercontent.com/ros/rosdistro/master 全部改成 file:///home/用户名/rosdistro
意思是网址打不开了,直接把文件下载下来,然后指向文件所在的位置,这里的 /home/用户名/rosdistro 就是rosdistro的绝对路径

记得下面所有的 /home/chn/rosdistro 中的chn换成你自己的用户名

改之前的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

我自己的改后的长这样

# os-specific listings first
yaml file:///home/chn/rosdistro/rosdep/osx-homebrew.yaml osx

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

# newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead

然后还要改几个文件
第一个第36行

chn@ubuntu:~$ sudo gedit /usr/lib/python2.7/dist-packages/rosdep2/gbpdistro_support.py

把36 37 行注释掉,然后改成

#FUERTE_GBPDISTRO_URL = 'https://raw.githubusercontent.com/ros/rosdistro/' \
#   'master/releases/fuerte.yaml'
FUERTE_GBPDISTRO_URL = 'file:///home/chn/rosdistro/releases/fuerte.yaml'

第二个文件39行,同样的道理

chn@ubuntu:~$ sudo gedit /usr/lib/python2.7/dist-packages/rosdep2/rep3.py

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

REP3_TARGETS_URL = 'file:///home/chn/rosdistro/releases/targets.yaml'

第三个文件68行

chn@ubuntu:~$ sudo gedit /usr/lib/python2.7/dist-packages/rosdistro/__init__.py


DEFAULT_INDEX_URL = 'file:///home/chn/rosdistro/index-v4.yaml'

rosdep update成功

chn@ubuntu:~$ rosdep update
reading in sources list data from /etc/ros/rosdep/sources.list.d
Hit file:///home/chn/rosdistro/rosdep/osx-homebrew.yaml
Hit file:///home/chn/rosdistro/rosdep/base.yaml
Hit file:///home/chn/rosdistro/rosdep/python.yaml
Hit file:///home/chn/rosdistro/rosdep/ruby.yaml
Hit file:///home/chn/rosdistro/releases/fuerte.yaml
Query rosdistro index file:///home/chn/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"
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/chn/.ros/rosdep/sources.cache

更新环境变量

chn@ubuntu:~$ echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc
chn@ubuntu:~$ source ~/.bashrc

打开roscore试试是否安装成功

chn@ubuntu:~$ roscore
... logging to /home/chn/.ros/log/fc33a248-5808-11ec-99aa-000c291769e8/roslaunch-ubuntu-35141.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://ubuntu:44131/
ros_comm version 1.12.17


SUMMARY
========

PARAMETERS
 * /rosdistro: kinetic
 * /rosversion: 1.12.17

NODES

auto-starting new master
process[master]: started with pid [35152]
ROS_MASTER_URI=http://ubuntu:11311/

setting /run_id to fc33a248-5808-11ec-99aa-000c291769e8
process[rosout-1]: started with pid [35165]
started core service [/rosout]

关闭:ctrl+c关闭ros
想要查看该路径下有啥子目录的话 用

ls
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值