不一樣的ROS版本所需的ubuntu版本不一樣,每一版ROS都有其對應版本的Ubuntu,切記不可隨便安裝,聽說國際上ROS系統支持最廣的系統分別爲indigo、kinetic。具體可看ros官網http://wiki.ros.org/melodic/Installation/Ubuntunode
如下是到2018年各個版本ROS對應ubuntu版本對照表:python
ROS版本git |
Ubuntu版本github |
ROS Melodic Moreniaubuntu |
Ubuntu 18.04(Bionic)/Ubuntu 17.04 Artfulruby |
Ubuntu 17.04 (Zesty)/Ubuntu 16.10 Yakkety, Ubuntu LTS 16.04 Xenialionic |
|
ROS Kinetic Kame測試 |
Ubuntu 16.04 (Xenial) / Ubuntu 15.10 (Wily)ui |
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上的安裝配置與測試已完成。