系統Ubuntu 18.04
ROS版本 Melodic
1. 更改ROS源
在清華TUNA的開源庫中選擇ROS
2. 按照教程開始進行操作
http://wiki.ros.org/melodic/Installation/Ubuntu
1.1不需要進行,apt源選擇國內的鏡像源,在/etc/apt/sources.list中修改成清華apt源即可
1.2 點擊Mirror鏈接,選擇國內鏡像
選擇USTC或者清華的都可以
1.3-1.6按照指導進行即可,在1.6第一步安裝完依賴條件后,進行初始化操作
sudo apt install python-rosdep
然后進行sudo rosdep init
此時出現錯誤需要自行修改,詳見:
在/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
yaml file:///etc/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
yaml file:///etc/ros/rosdistro/master/rosdep/base.yaml
yaml file:///etc/ros/rosdistro/master/rosdep/python.yaml
yaml file:///etc/ros/rosdistro/master/rosdep/ruby.yaml
gbpdistro file:///etc/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
此時再進入/usr/lib/python2.7/dist-packages/rosdistro/__init__.py,將下載網站鏈接修改為內部路徑
#DEFAULT_INDEX_URL = 'https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml'
DEFAULT_INDEX_URL = 'file:///etc/ros/rosdistro/master/index-v4.yaml'
需要的文件從下面雲盤中直接下載,解壓到/etc/ros目錄下。需要超級權限。
鏈接: https://pan.baidu.com/s/19OCXIUgZ1RNHV33noc1auw
提取碼: tnn9
保存在/etc/ros/ 路徑下(用sudo cp -r ~/rosdistro /etc/ros/)
Ubuntu中的cp命令(https://blog.csdn.net/jiangyongy/article/details/78902966)
最后執行rosdep update,完成更新升級
3. 設置環境變量
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
將ros的啟動文件添加到bash中,激活bash
4. ROS安裝完成后運行小烏龜程序
$roscore
新開一個terminal,打開小烏龜窗口
$rosrun turtlesim turtlesim_node
新開一個terminal,打開小烏龜控制窗口,用方向鍵控制小烏龜運動
$rosrun turtlesim turtle_teleop_key
選中控制窗口按方向鍵即可看到小烏龜窗口中小烏龜運動
再新開一個terminal,顯示ROS圖形化GUI,顯示節點關系
$rosrun rqt_graph rqt_graph
如果正常運行,說明ROS安裝成功
5. 其他參考
https://zhuanlan.zhihu.com/p/149707893