ubuntu18.04.02安裝ROS melodic


  不同的ROS版本所需的ubuntu版本不同,每一版ROS都有其對應版本的Ubuntu,切記不可隨便安裝,據說國際上ROS系統支持最廣的系統分別為indigo、kinetic。具體可看ros官網http://wiki.ros.org/melodic/Installation/Ubuntu

  以下是到2018年各個版本ROS對應ubuntu版本對照表:

ROS版本

Ubuntu版本

ROS Melodic Morenia

Ubuntu 18.04Bionic/Ubuntu 17.04 Artful

ROS Lunar Loggerhead

 Ubuntu 17.04 (Zesty)/Ubuntu 16.10 Yakkety, Ubuntu LTS 16.04 Xenial

ROS Kinetic Kame

Ubuntu 16.04 (Xenial) / Ubuntu 15.10 (Wily)

ROS Jade Turtle

Ubuntu 15.04 (Wily) / Ubuntu LTS 14.04 (Trusty)

ROS Indigo Igloo

Ubuntu 14.04 (Trusty)

ROS Hydro Medusa

Ubuntu 12.04 LTS (Precise)

ROS Groovy Galapagos

Ubuntu 12.04

我這里選擇的是Melodic版本,具體安裝步驟如下:

1. 設置軟件源

 1 sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list' 

2.設置密鑰

sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116

3.更新源地址

sudo apt-get update

我這里在更新源時報錯如下:

W: GPG error: http://packages.ros.org/ros/ubuntu bionic InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY F42ED6FBAB17C654
E: The repository 'http://packages.ros.org/ros/ubuntu bionic InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

解決方法:

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F42ED6FBAB17C654

然后再次更新源地址,問題解決。

sudo apt-get update

PS:在運行上述命令之后,終端會輸出一些相應的信息,注意看有沒有錯誤和告警信息,如果全是獲取和命中就說明沒有問題。

4:安裝ros,在這里可以選擇完整版,也可以選擇只安裝一部分,具體的命令在官網教程中可以找到。我這里選擇的是安裝所有,這個過程會比較長

sudo apt-get install ros-melodic-desktop-full

5:初始化rosdep

sudo rosdep init

執行完成如下圖提示進行更新

Wrote /etc/ros/rosdep/sources.list.d/20-default.list
Recommended: please run

    rosdep update

6:按照提示進行update

rosdep update

執行完成如下:

reading in sources list data from /etc/ros/rosdep/sources.list.d
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml
Query rosdistro index https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml
Skip end-of-life distro "ardent"
Skip end-of-life distro "bouncy"
Add distro "crystal"
Add distro "dashing"
Add distro "eloquent"
Skip end-of-life distro "groovy"
Skip end-of-life distro "hydro"
Skip end-of-life distro "indigo"
Skip end-of-life distro "jade"
Add distro "kinetic"
Skip end-of-life distro "lunar"
Add distro "melodic"
Add distro "noetic"
updated cache in /home/XXXX/.ros/rosdep/sources.cache

7:設置環境變量

echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc

到這里ros的安裝已經完成,但是我們還需要再安裝一些ros依賴的包

8:安裝依賴包

sudo apt install python-rosinstall python-rosinstall-generator python-wstool build-essential

至此ROS的安裝已經完成,為了驗證安裝是否成功,我們需要測試一下,步驟如下:

9:ros小海龜測試,在終端執行如下命令

roscore
執行成功出現如下信息:
... logging to /home/XXXX/.ros/log/c539a1ea-bcd1-11e9-a4b0-000c29d43c08/roslaunch-ubuntu-30082.log Checking log directory for disk usage. This may take awhile. Press Ctrl-C to interrupt Done checking log file disk usage. Usage is <1GB. started roslaunch server http://ubuntu:32889/ ros_comm version 1.14.3 SUMMARY ======== PARAMETERS * /rosdistro: melodic * /rosversion: 1.14.3 NODES auto-starting new master process[master]: started with pid [30092] ROS_MASTER_URI=http://ubuntu:11311/ setting /run_id to c539a1ea-bcd1-11e9-a4b0-000c29d43c08 process[rosout-1]: started with pid [30103] started core service [/rosout]

 PS:按Ctr+C可退出終端

此時我們再另外打開一個終端,然后執行如下命令

rosrun turtlesim turtlesim_node
執行成功出現如下信息:
[ INFO] [1565594556.608022579]: Starting turtlesim with node name /turtlesim [ INFO] [1565594556.613793689]: Spawning turtle [turtle1] at x=[5.544445], y=[5.544445], theta=[0.000000]

此時會出現一個新的窗口,此時的小烏龜是禁止不動的,如下圖

此時我們再打開一個終端,執行如下代碼:

rosrun turtlesim turtle_teleop_key

執行成功出現如下

Reading from keyboard
---------------------------
Use arrow keys to move the turtle.

以上內容的大概意思是我們可以用鍵盤控制小烏龜進行移動,我們在這個終端按鍵盤上的“上、下、左、右”鍵,此時發現小烏龜也在移動,如下圖:

至此,ros在ubuntu 18.04.02上的安裝配置與測試已完成。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM