1.添加源
1.1 USTC源
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.ustc.edu.cn/ros/ubuntu/ $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/ros-latest.list'
如執行有問題,則:
sudo sh -c 'echo "deb http://mirrors.ustc.edu.cn/ros/ubuntu/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
1.2 TUNA源
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'
注:配合https://www.cnblogs.com/letisl/p/11814384.html所提到的更換Ubuntu系統源,安裝速度非國外源可比。
2.添加私鑰
wget https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -O - | sudo apt-key add -
如不能添加,則:
sudo apt-key adv --keyserver hkp://pool.sks-keyservers.net --recv-key 0xB01FA116
3.更新軟件列表
sudo apt-get update
注意:一般無需使用sudo apt-get upgrade這個命令,會把本地已安裝的軟件,與剛下載的軟件列表里對應軟件進行對比,如果發現已安裝的軟件版本太低,就會提示你更新。而sudo apt-get update這個命令,只是訪問源列表里的每個網址讀取軟件列表,然后保存在本地電腦。
3.1 GPG 錯誤
W: GPG 錯誤:http://mirrors.ustc.edu.cn/ros/ubuntu xenial InRelease: 由於沒有公鑰,無法驗證下列簽名: NO_PUBKEY F42ED6FBAB17C654
錯誤原因:
可能是缺少公鑰,也可能是公鑰過期。
解決方法:
既然是沒有公鑰,自然是添加公鑰。
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F42ED6FBAB17C654
3.2 404 Not Found錯誤
W: 倉庫 “http://ppa.launchpad.net/tualatrix/ppa/ubuntu xenial Release” 沒有 Release 文件。 N: 無法認證來自該源的數據,所以使用它會帶來潛在風險。 N: 參見 apt-secure(8) 手冊以了解倉庫創建和用戶配置方面的細節。 W: 無法下載 http://ppa.launchpad.net/tualatrix/ppa/ubuntu/dists/xenial/main/binary-amd64/Packages 404 Not Found [IP: 91.189.95.83 80] W: 無法下載 http://ppa.launchpad.net/tualatrix/ppa/ubuntu/dists/xenial/main/binary-i386/Packages 404 Not Found [IP: 91.189.95.83 80] W: 無法下載 http://ppa.launchpad.net/tualatrix/ppa/ubuntu/dists/xenial/main/binary-all/Packages 404 Not Found [IP: 91.189.95.83 80] W: 無法下載 http://ppa.launchpad.net/tualatrix/ppa/ubuntu/dists/xenial/main/i18n/Translation-zh_CN 404 Not Found [IP: 91.189.95.83 80] W: 無法下載 http://ppa.launchpad.net/tualatrix/ppa/ubuntu/dists/xenial/main/i18n/Translation-zh 404 Not Found [IP: 91.189.95.83 80] W: 無法下載 http://ppa.launchpad.net/tualatrix/ppa/ubuntu/dists/xenial/main/i18n/Translation-en 404 Not Found [IP: 91.189.95.83 80] W: 無法下載 http://ppa.launchpad.net/tualatrix/ppa/ubuntu/dists/xenial/main/dep11/Components-amd64.yml 404 Not Found [IP: 91.189.95.83 80] W: 無法下載 http://ppa.launchpad.net/tualatrix/ppa/ubuntu/dists/xenial/main/dep11/icons-64x64.tar 404 Not Found [IP: 91.189.95.83 80] W: 部分索引文件下載失敗。如果忽略它們,那將轉而使用舊的索引文件。
錯誤原因:
首先說明此問題與ROS安裝無關。
原因可能是PPA源中此用戶刪除了這些文件,但又添加了此源。
解決方法:
打開/etc/apt/sources.list.d文件夾,刪除相關源文件。
4.安裝ROS
sudo apt-get install ros-kinetic-desktop-full
注意:
- 按需選用full或者是base,base沒有圖形化界面,適合安裝在機器人上;
- 按照Ubuntu版本選擇ROS版本,kinetic版本適合於Ubuntu 16.04,其他Ubuntu版本各有其相應的ROS版本,不建議混用。
- 安裝完成后,可以用下面的命令來查看可使用的包
apt-cache search ros-kinetic
5.初始化
sudo 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 Website may be down.
解決方案:
多試幾次!國內連接githubsercontent.com比較慢,容易失敗。
如果多次嘗試未果,可以嘗試如下方法:
下面提供我個人設置的文件:
- 原始20-default.list:https://hansteam.coding.net/p/rosdeap_mirror/d/rosdeap_mirror/git/raw/master/20-default.list
- 修改后的20-default.list文件:
#Rewrited by HAN_Letisl #For more information: https://www.cnblogs.com/letisl # os-specific listings first yaml https://hansteam.coding.net/p/rosdeap_mirror/d/rosdeap_mirror/git/raw/master/osx-homebrew.yaml osx # generic yaml https://hansteam.coding.net/p/rosdeap_mirror/d/rosdeap_mirror/git/raw/master/base.yaml yaml https://hansteam.coding.net/p/rosdeap_mirror/d/rosdeap_mirror/git/raw/master/python.yaml yaml https://hansteam.coding.net/p/rosdeap_mirror/d/rosdeap_mirror/git/raw/master/ruby.yaml gbpdistro https://hansteam.coding.net/p/rosdeap_mirror/d/rosdeap_mirror/git/raw/master/fuerte.yaml fuerte # newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead
注意:其Query rosdistro index https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml在20-default.list不顯式出現,因此未能將這個文件包括在其中,個人鏡像中有這個文件(https://hansteam.coding.net/p/rosdeap_mirror/d/rosdeap_mirror/git/raw/master/index-v4.yaml),需要使用的朋友可以自行設法使用。
備注:完全正確的結果圖,供參考。
另一種可行的解決方案,安裝XX工具,安裝proxychains代理終端。只要代理靠譜,此方法理論上100%可行。
6.環境配置
#echo “source /opt/ros/kinetic/setup.bash” >> ~/.bashrc 這個命令是錯誤的,勿用。引號是中文引號,與下一條對比。
echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc
source ~/.bashrc
可能出現問題:
“source:未找到命令
問題原因:
根據提示,打開/.bashrc文件:
”source /opt/ros/kinetic/setup.bash“
發現最后一行居然多了兩側的引號,而且是中文引號。
原因在於,上述命令中的引號問題。
7.安裝rosinstall
sudo apt-get install python-rosinstall python-rosinstall-generator python-wstool build-essential
8.測試是否安裝成功
roscore
如果顯示如下:
started core service [/rosout]
代表安裝成功。
9.安裝IDE
RoboWare Studio是ROS的一款IDE,但是它的功能又比較強大,使得開發更加快速、簡單。這款軟件適合菜鳥入門,因為很多配置都直接自動生成。
直接進入其中文官網,http://cn.roboware.me/#/home,下載deb包安裝即可。
9.1安裝包
事實上,中文官網似乎用了XX工具也不能打開。
提供個人下載鏈接:roboware-studio_1.1.0-1514335284_amd64.deb:https://hansteam.coding.net/s/ffc0144b-9c57-4173-974a-ba03986d2719
9.2預先安裝
安裝pyint用於支持Python調試功能:
sudo apt-get install python-pip
sudo python -m pip install pylint
備注:如果出現問題,可參照:
https://blog.csdn.net/zhuiqiuzhuoyue583/article/details/84536406
簡單講,可以:
- 執行sudo apt-get install python-pip
- sudo gedit /usr/bin/pip,修改為:
#!/usr/bin/python # GENERATED BY DEBIAN import sys # Run the main entry point, similarly to how setuptools does it, but because # we didn't install the actual entry point from setup.py, don't use the # pkg_resources API. from pip import __main__ if __name__ == '__main__': sys.exit(__main__._main()) #modify when install roboware @hans,2019.11.8 #from pip import main #if __name__ == '__main__': # sys.exit(main())
- pip install --upgrade pip
- sudo pip install --ignore-installed enum34
- sudo python -m pip install pylint
安裝clang-format獲得更好的代碼閱讀體驗,自動格式化整理代碼:
sudo apt-get install clang-format-3.8
9.3正式安裝
sudo dpkg -i roboware-studio_1.1.0-1514335284_amd64.deb
安裝完畢后:
roboware-studio
輸入以上命令,即可打開該IDE使用。
也可以使用最新版:roboware-studio_1.2.0-1524709819_amd64.deb,RoboWare_Studio_Manual_1.2.0_CHS.pdf。