几年没手工安装ros了,一般拉个安装好了cuda和ros等工具软件的docker image直接使用,以前安装过程中很顺利不会有什么报错,最近按照melodic/Installation/Ubuntu - ROS Wiki这里的步骤安装melodic
sudo apt install lsb-core
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu/ `lsb_release -cs` main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt install curl
curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | apt-key add -
sudo apt update
sudo apt install ros-melodic-desktop-full
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
sudo apt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essential
sudo rosdep init
rosdep update
或noetic/Installation/Ubuntu - ROS Wiki
sudo apt install lsb-core
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu/ `lsb_release -cs` main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt install curl
curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | apt-key add -
sudo apt update
sudo apt install ros-noetic-desktop-full
echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc
source ~/.bashrc
sudo apt install python3-rosdep python3-rosinstall python3-rosinstall-generator python3-wstool build-essential
sudo rosdep init
rosdep update
这里的步骤安装noetic,执行到curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | apt-key add -时
死掉,rosdep init和rosdep update时总是下面的报错:
ERROR: cannot download default sources list from:
https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list
ERROR: unable to process source [https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml]:
<urlopen error [Errno 111] Connection refused> (https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml)
ERROR: unable to process source [https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml]:
<urlopen error [Errno 111] Connection refused> (https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml)
...
根本原因是执行这些步骤时需要连到raw.githubusercontent.com这个已经被墙掉的网站下载一些文件,网上推荐的解决办法一般是去修改/etc/resolve.conf或者/etc/hosts增加谷歌的服务器ip地址或githubusercontent.com的ip地址,点击这个网址raw.githubusercontent.com获取githubusercontent.com的ip地址:
把这些地址加入到/etc/hosts里发现,每个地址访问一次后就被阻住,要过好一阵才能再访问,所以安装不能顺利进行下去。
被逼着去翻看了一下ros源码和网上信息,其实解决比较简单,对于ros.asc(我下载后上传到了这里)下载不了,可以从国内镜像网站上下载这个文件到本地,然后执行:
sudo apt-key add ros.asc
对于rosdep init和rosdep update报错思路就是把从githubusercontent.com上下载文件改成从国内的镜像网站下载即可,
执行下面的命令即完成了rosdep init 和rosdep update:
sudo apt-get install wget
sudo mkdir -p /etc/ros/rosdep/sources.list.d
wget https://mirrors.tuna.tsinghua.edu.cn/github-raw/ros/rosdistro/master/rosdep/sources.list.d/20-default.list -O /etc/ros/rosdep/sources.list.d/20-default.list
export ROSDISTRO_INDEX_URL=https://mirrors.tuna.tsinghua.edu.cn/rosdistro/index-v4.yaml && rosdep update
后来看到网上有人单独做了个工具rosdepc来替代rosdep,可以执行下面的命令安装:
sudo apt-get install python3-pip
sudo pip install rosdepc
然后执行rosdepc init和rosdepc update
但是因为OS环境支持的字符集的不同,执行过程中可能会报下面的错误:
Traceback (most recent call last):
File "/usr/local/bin/rosdepc", line 8, in <module>
sys.exit(main())
File "/usr/local/lib/python3.6/dist-packages/rosdepc/rosdepc.py", line 52, in main
print(hints['welcome'])
UnicodeEncodeError: 'ascii' codec can't encode characters in position 1-7: ordinal not in range(128)
Traceback (most recent call last):
File "/usr/local/bin/rosdepc", line 8, in <module>
sys.exit(main())
File "/usr/local/lib/python3.6/dist-packages/rosdepc/rosdepc.py", line 52, in main
print(hints['welcome'])
UnicodeEncodeError: 'ascii' codec can't encode character '\u201c' in position 145: ordinal not in range(128)文章来源:https://www.toymoban.com/news/detail-571926.html
原因是这个rosdepc工具的/usr/local/lib/python3.6/dist-packages/rosdepc/rosdepc.py这个文件里写了大量的用于提示的中文字符以及@等ascii码字符集不支持的字符,把里面的包含的中文和特殊格式符都删掉即可,这些信息其实没啥用,删干净了再执行rosdepc init即可,可以看到rosdepc.py这个文件里的核心语句其实就是我上面写的那几句命令,所以完全不用安装这个工具包,直接执行这两句命令更简捷:文章来源地址https://www.toymoban.com/news/detail-571926.html
wget https://mirrors.tuna.tsinghua.edu.cn/github-raw/ros/rosdistro/master/rosdep/sources.list.d/20-default.list -O /etc/ros/rosdep/sources.list.d/20-default.list
export ROSDISTRO_INDEX_URL=https://mirrors.tuna.tsinghua.edu.cn/rosdistro/index-v4.yaml && rosdep update
到了这里,关于如何解决ROS安装过程中rosdep init和rosdep update报错误的问题的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!