首先,ubuntu18.04對(duì)應(yīng)的ROS版本為melidic。
打開(kāi)"軟件與更新"對(duì)話框,把可從互聯(lián)網(wǎng)下載下的幾個(gè)框框都打勾。如圖:

更換安裝源
官方默認(rèn)安裝源不穩(wěn)定,常出現(xiàn)在安裝過(guò)程中網(wǎng)絡(luò)超時(shí)等報(bào)錯(cuò),現(xiàn)使用清華的安裝源:
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 sh -c '. /etc/lsb-release && echo "deb http://mirrors.ustc.edu.cn/ros/ubuntu/ `lsb_release -cs` main" > /etc/apt/sources.list.d/ros-latest.list'
輸入代碼后,按回車,輸入管理員密碼即可。
設(shè)置key
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
安裝ROS
首先要更新apt
sudo?apt?update
可以是apt或者是apt-get
需要等一會(huì)兒
然后安裝ROS,這里有很多類型,我們一般安裝常用的官方推薦版本Desktop-Full,它里面含有ROS, rqt, rviz, robot-generic libraries, 2D/3D simulators, navigation and 2D/3D perception.
sudo apt install ros-melodic-desktop-full
等待較長(zhǎng)時(shí)間
環(huán)境變量設(shè)置
配置環(huán)境變量,為了在任意終端中使用ROS
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
安裝構(gòu)建依賴
sudo apt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essential
sudo apt install python-rosdep
安裝依賴成功界面:

初始化rosdep
sudo rosdep init
rosdep update
初始化rosdep成功界面:

注意:這里建議把ubuntu改下載源為阿里云,不然容易出現(xiàn)錯(cuò)誤:
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.
原因是這個(gè)github資源被屏蔽了。
測(cè)試ROS
利用ROS中內(nèi)置的烏龜小程序測(cè)試ROS
首先開(kāi)啟三個(gè)終端:
終端一中輸入:
roscore
啟動(dòng)ros內(nèi)核,如圖:

終端二中輸入:
rosrun?turtlesim?turtlesim_node
此時(shí)出現(xiàn)烏龜小程序圖形化界面


終端三中輸入:
rosrun?turtlesim?turtle_teleop_key
這個(gè)命令用于啟動(dòng)鍵盤控制,可以使用鍵盤控制小烏龜前后左右運(yùn)動(dòng)。如圖:

注意:控制小烏龜運(yùn)動(dòng)時(shí),要將鼠標(biāo)游標(biāo)放在第三個(gè)鍵盤控制終端中。文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-424052.html
至此,成功安裝成功ROS,并測(cè)試完成。文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-424052.html
到了這里,關(guān)于ubuntu18.04安裝ROS講解的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!