Ubuntu16.04下如何安装ROS以及出现的问题(最新)

Ubuntu16.04下如何安装ROS以及出现的问题

最近在网上找项目学习,发现在编译老是编译不通过经过查找发现时自己的没有安装ROS才出现的问题,害得自己一直在找代码错误。
下面就正式讲解如何安装ROS:

1.配置 Ubuntu 软件仓库

找到software&updates,在Ubuntu software中勾选restricted"、“universe” 和 "multiverse"这三种安装模式,如图所示:
Ubuntu16.04下如何安装ROS以及出现的问题(最新)_第1张图片(可以改变自己的镜像,改成最近的)

2.添加 sources.list

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

注:强烈建议使用国内或者新加波的镜像源,这样能够大大提高安装下载速度。
添加中科大源:

sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.ustc.edu.cn/ros/ubuntu/  main" > /etc/apt/sources.list.d/ros-latest.list'

http://wiki.ros.org/ROS/Installation/UbuntuMirrors

http://www.mobibrw.com/2018/10000

修改系统默认的镜像源:sudo gedit /etc/apt/sources.list
可以拷贝一份原件,以备用。

# deb cdrom:[Ubuntu 16.04.4 LTS _Xenial Xerus_ - Release amd64 (20180228)]/ xenial main restricted

deb http://mirrors.ustc.edu.cn/ubuntu/ xenial main restricted universe multiverse

deb http://mirrors.ustc.edu.cn/ubuntu/ xenial-security main restricted universe multiverse

deb http://mirrors.ustc.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse

deb http://mirrors.ustc.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse

deb http://mirrors.ustc.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse

deb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial main restricted universe multiverse

deb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial-security main restricted universe multiverse

deb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse

deb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse

deb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
deb http://ros.exbot.net/rospackage/ros/ubuntu/ xenial main

3.添加 keys

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

4.安装

sudo apt-get update

在ROS中,有很多不同的库和工具。我们提供了四种默认的配置来帮助你开始。你也可以单独安装ROS包。

桌面完整版: (推荐) : 包含ROS、rqt、rviz、机器人通用库、2D/3D 模拟器、导航以及2D/3D感知

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

桌面版安装: 包含ROS、rqt、rviz以及通用机器人函数库。

 sudo apt-get install ros-kinetic-desktop

基础版安装: (简版) 包含ROS核心软件包、构建工具以及通信相关的程序库,无GUI工具。

 sudo apt-get install ros-kinetic-ros-base

单个软件包安装: 你也可以安装某个指定的ROS软件包(使用软件包名称替换掉下面的PACKAGE):

sudo apt-get install ros-kinetic-PACKAGE

例如:

sudo apt-get install ros-kinetic-slam-gmapping

检测是否安装成功ros:

apt-cache search ros-kinetic

5.初始化 rosdep

sudo rosdep init
rosdep update

6.环境配置

如果每次打开一个新的终端时ROS环境变量都能够自动配置好(即添加到bash会话中),那将会方便很多:

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

到这基本上ros核心工具都已经安装完成,要是想要更加详细的更具参考官网所给出的步骤。ROS安装官网

出现的问题:

1.sudo apt-get update出现:

W: Failed to fetch http://ros.exbot.net/rospackage/ros/ubuntu/dists/xenial/InRelease Could not resolve ‘ros.exbot.net’
W: Some index files failed to download. They have been ignored, or old ones used instead.

没去管他

直接继续下面。。

2.E: Malformed entry 1 in list file /etc/apt/sources.list.d/ros-latest.list (Component)

解决:sudo rm /etc/apt/sources.list.d/ros-latest.list

2.sudo rosdep init时报错

  ERROR: default sources list file already exists:
	/etc/ros/rosdep/sources.list.d/20-default.list
Please delete if you wish to re-initialize

解决方法
使用(重新开终端):

sudo rm /etc/ros/rosdep/sources.list.d/20-default.list

之后在执行,报错:、

sugar@sugar-ckq:~$ sudo rosdep init
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.

解决1:

sudo cp /home/ckq/Desktop/20-default.list /etc/ros/rosdep/sources.list.d

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

解决方法2:

sudo c_rehash /etc/ssl/certs
sudo -E rosdep init
rosdep update
sugar@sugar-ckq:~$ sudo c_rehash /etc/ssl/certs
Doing /etc/ssl/certs
WARNING: Skipping duplicate certificate ca-certificates.crt
WARNING: Skipping duplicate certificate ca-certificates.crt
sugar@sugar-ckq:~$ sudo -E rosdep init
Wrote /etc/ros/rosdep/sources.list.d/20-default.list
Recommended: please run

	rosdep update

(如出现上述一样的问题可以在重新开终端进行rosdep update)

如果还是出现:


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](http://jump.bdimg.com/safecheck/index?url=rN3wPs8te/pX/RXZrrwmgz1HhLKFfuYdBR6elVnGSRMPTZwDs+V1Iw2DN2GIDg0c0lXFaWYCi6F5eugIuTik7Xf24HznH1heOw2gAEfI/e4pyVgDjNm3SaoaxT39lV2h1C6ZRqu3Ohsi0ZhQy1cgW5DaxsU0VVq099hJLALtyPraHkhVQYEleySdzQDlWLfuyu4YXs62n7WWp87t6F1nMhvv0JflI+P2dj2oeHoEzTI=)]:
<urlopen error _ssl.c:495: The handshake operation timed out> ([https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml](http://jump.bdimg.com/safecheck/index?url=rN3wPs8te/pX/RXZrrwmgz1HhLKFfuYdBR6elVnGSRMPTZwDs+V1Iw2DN2GIDg0c0lXFaWYCi6F5eugIuTik7Xf24HznH1heOw2gAEfI/e4pyVgDjNm3SaoaxT39lV2h1C6ZRqu3Ohsi0ZhQy1cgW5DaxsU0VVq099hJLALtyPraHkhVQYEleySdzQDlWLfuyu4YXs62n7WWp87t6F1nMhvv0JflI+P2dj2oeHoEzTI=))
Hit [https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml](http://jump.bdimg.com/safecheck/index?url=rN3wPs8te/pX/RXZrrwmgz1HhLKFfuYdBR6elVnGSRMPTZwDs+V1Iw2DN2GIDg0c0lXFaWYCi6F5eugIuTik7Xf24HznH1heOw2gAEfI/e64EpZhV/nSSfaMCRlMqNMjqsw5JFtciolkdT5HNLb22Z8xZQwNWZn8DhrNz7QOmul3vNSiiiuylvEgZ+MKQ61lxfjiJ1xO6k1T0sjgIIm+zjA8Zu4mdgY0)
ERROR: error loading sources list:
The read operation timed out

尝试:
sudo apt-get update
sudo apt-get install python-rosdep

还是不行!!!!
解决方法:

sudo gedit /etc/resolv.conf

改成下面两句:

nameserver 8.8.8.8 #google域名服务器

nameserver 8.8.4.4 #google域名服务器

参考出处

最终完成:

sugar@sugar-ckq:~$ 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/sugar/.ros/rosdep/sources.cache

出现这个错误时:
sudo rosdep init
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.
直接拷贝/20-default.list文件试试!!!

查看自己是否安装成功可以创建一个ROS空间:
官网教程创建一个ROS空间

希望有所帮助!!!

参看文献:
https://blog.csdn.net/luvalluo/article/details/78745677
https://blog.csdn.net/qq_21310131/article/details/81065772
https://blog.csdn.net/yueyueniaolzp/article/details/85070093
https://www.cnblogs.com/qiangzi0221/p/7707128.html
https://blog.csdn.net/tancm/article/details/83420719

你可能感兴趣的:(Ubuntu安装软件及问题)