ubuntu18.04.02安装ROS melodic

  不一样的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.04Bionic/Ubuntu 17.04 Artfulruby

ROS Lunar Loggerheadbash

 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上的安装配置与测试已完成。

相关文章
相关标签/搜索