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

 

转载于:https://www.cnblogs.com/chxuyuan/p/11340653.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值