Ubuntu18.04 安装ROS Melodic(官方版)

此次是在虚拟机下,刚装好的Ubuntu18.04纯净系统进行ROS安装,使用ubuntu-18.04.4-desktop-amd64.iso进行安装,安装中文版本,使用默认的分区方案并开启LVM支持。

新增避免科学方法的补充,参见https://blog.csdn.net/nyszx/article/details/124232154

官方安装教程地址melodic/Installation/Ubuntu - ROS Wiki

打开页面按教程一步步走:

步骤1:配置系统源,改为中科大源

特别注意需要开启系统更新:

 否则会出现

下列软件包有未满足的依赖关系:
 ros-melodic-desktop-full : 依赖: ros-melodic-desktop 但是它将不会被安装
                            依赖: ros-melodic-perception 但是它将不会被安装
                            依赖: ros-melodic-simulators 但是它将不会被安装
                            依赖: ros-melodic-urdf-sim-tutorial 但是它将不会被安装
E: 无法修正错误,因为您要求某些软件包保持现状,就是它们破坏了软件包间的依赖关系。

步骤2:添加ROS源,这里点击页面的镜像链接,在镜像页面选择亚洲的中科大:

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'

步骤3:安装curl工具,新系统没有此工具,需要单独安装:

sudo apt install curl

步骤4:下载密钥

curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -

特别注意,这里会遇到个问题,raw.githubusercontent.com相关的网页是无法访问的,必须进行科学方法才能成功,否则会出现如下错误

gpg: 找不到有效的 OpenPGP 数据

步骤5:进行更新

sudo apt update

步骤6:安装ROS全功能版

sudo apt install ros-melodic-desktop-full

步骤7:添加环境变量

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

此时已经安装好了ROS,直接输入roscore就已经可以正常启动ROS了。为了开发ROS还需要一些软件包,因此还需要安装写其他工具和包,继续进行。

步骤8:安装ROS相关的Python工具

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

步骤9:初始化ROS包列表

sudo rosdep init

特别注意,这里也会访问raw.githubusercontent.com,必须进行科学方法才能成功,否则会出现如下错误

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.

也可以手动创建初始化列表:

创建/etc/ros/rosdep/sources.list.d目录,创建20-default.list文件

sudo mkdir -p /etc/ros/rosdep/sources.list.d
cd /etc/ros/rosdep/sources.list.d
sudo touch 20-default.list

写入以下内容:

# os-specific listings first
yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml osx

# generic
yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml
yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml
yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml
gbpdistro https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml fuerte

# newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead

步骤10:更新ROS包

rosdep update

特别注意,这里也会访问raw.githubusercontent.com,必须进行科学方法才能成功,否则会出现如下错误

reading in sources list data from /etc/ros/rosdep/sources.list.d
ERROR: unable to process source [https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml]:
	<urlopen error [Errno 0] Error> (https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml)
ERROR: unable to process source [https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml]:
	No status line received - the server has closed the connection (https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml)
ERROR: unable to process source [https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml]:
	<urlopen error ('_ssl.c:711: The handshake operation timed out',)> (https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml)
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml
ERROR: unable to process source [https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml]:
	Failed to download target platform data for gbpdistro:
	No status line received - the server has closed the connection
Query rosdistro index https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml
...

正常完成后显示如下内容:

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"
Skip end-of-life distro "crystal"
Skip end-of-life distro "dashing"
Skip end-of-life distro "eloquent"
Add distro "foxy"
Add distro "galactic"
Skip end-of-life distro "groovy"
Skip end-of-life distro "hydro"
Skip end-of-life distro "indigo"
Skip end-of-life distro "jade"
Skip end-of-life distro "kinetic"
Skip end-of-life distro "lunar"
Add distro "melodic"
Add distro "noetic"
Add distro "rolling"
updated cache in /home/user/.ros/rosdep/sources.cache

至此就可以进行ROS开发了。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值