幾年沒手工安裝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,執(zhí)行到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)
...
根本原因是執(zhí)行這些步驟時需要連到raw.githubusercontent.com這個已經(jīng)被墻掉的網(wǎng)站下載一些文件,網(wǎng)上推薦的解決辦法一般是去修改/etc/resolve.conf或者/etc/hosts增加谷歌的服務(wù)器ip地址或githubusercontent.com的ip地址,點(diǎn)擊這個網(wǎng)址raw.githubusercontent.com獲取githubusercontent.com的ip地址:
?把這些地址加入到/etc/hosts里發(fā)現(xiàn),每個地址訪問一次后就被阻住,要過好一陣才能再訪問,所以安裝不能順利進(jìn)行下去。
被逼著去翻看了一下ros源碼和網(wǎng)上信息,其實(shí)解決比較簡單,對于ros.asc(我下載后上傳到了這里)下載不了,可以從國內(nèi)鏡像網(wǎng)站上下載這個文件到本地,然后執(zhí)行:
sudo apt-key add ros.asc
對于rosdep init和rosdep update報錯思路就是把從githubusercontent.com上下載文件改成從國內(nèi)的鏡像網(wǎng)站下載即可,
執(zhí)行下面的命令即完成了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
后來看到網(wǎng)上有人單獨(dú)做了個工具rosdepc來替代rosdep,可以執(zhí)行下面的命令安裝:
sudo apt-get install python3-pip
sudo pip install rosdepc
然后執(zhí)行rosdepc init和rosdepc update
但是因?yàn)镺S環(huán)境支持的字符集的不同,執(zhí)行過程中可能會報下面的錯誤:
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)文章來源:http://www.zghlxwxcb.cn/news/detail-571926.html
原因是這個rosdepc工具的/usr/local/lib/python3.6/dist-packages/rosdepc/rosdepc.py這個文件里寫了大量的用于提示的中文字符以及@等ascii碼字符集不支持的字符,把里面的包含的中文和特殊格式符都刪掉即可,這些信息其實(shí)沒啥用,刪干凈了再執(zhí)行rosdepc init即可,可以看到rosdepc.py這個文件里的核心語句其實(shí)就是我上面寫的那幾句命令,所以完全不用安裝這個工具包,直接執(zhí)行這兩句命令更簡捷:文章來源地址http://www.zghlxwxcb.cn/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
到了這里,關(guān)于如何解決ROS安裝過程中rosdep init和rosdep update報錯誤的問題的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!