近期跟着古月居老师正在学习《Ros入门21讲》以及Ros的基本应用等相关内容,作为步入Ros领域的第一步,Ros系统的安装步骤特别是安装时遇到的各类问题也曾经令许多入门者头大,本篇文章是本人亲自尝试,利用最简单的步骤安装Ubuntu18.04+Ros Melodic,希望对各位有所帮助
如果忽略这步,Ros相关软件包安装下载时需要很长时间,更换为国内软件源后会大大加快软件下载以及update的速度。
首先,修改源文件,输入命令:
sudo gedit /etc/apt/sources.list
打开后把配置文件内容修改如下:
# deb cdrom:[Ubuntu 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420.1)]/ xenial main restricted
deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties
deb http://archive.canonical.com/ubuntu xenial partner
deb-src http://archive.canonical.com/ubuntu xenial partner
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic main universe restricted multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main universe restricted multiverse #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main universe restricted multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main universe restricted multiverse #Added by software-properties
deb http://security.ubuntu.com/ubuntu/ bionic-security main universe restricted multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main universe restricted multiverse #Added by software-properties
修改完成后保存退出即可开始Ros的正式安装。
输入以下命令:
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/ $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/ros-latest.list'
输入以下命令:
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
首先,更新系统软件:
sudo apt update
然后正式安装,为了避免之后出现缺少软件包的问题,在这里直接下载完整版Ros-Melodic软件包
sudo apt install ros-melodic-desktop-full
此步会耗时较长,需要耐心等待,如果一边结束后显示有某些软件包漏掉未下载或下载失败,再次运行该命令即可,可能是因为下载某些软件包时网络问题。
运行命令:
sudo rosdep init
rosdep update
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
sudo apt install python-rosinstall python-rosinstall-generator python-wstool build-essential
roscore
rosrun turtlesim turtlesim_node
rosrun turtlesim turtle_teleop_key
此时你就可以用方向键控制海龟移动,也表示本次Ros的安装圆满成功~
问题描述:
下列软件包有未满足的依赖关系:
ros-kinetic-desktop-full : 依赖: ros-kinetic-desktop 但是它将不会被安装
依赖: ros-kinetic-perception 但是它将不会被安装
依赖: ros-kinetic-simulators 但是它将不会被安装
E: 无法修正错误,因为您要求某些软件包保持现状,就是它们破坏了软件包间的依赖关系。
根据第一步的第一点,将ubuntu软件设置部分的前5向选中即可,因为Ubuntu系统在下载软件包的过程中一般情况下会根据软件包的依赖关系将与其依赖的各类软件包都一起安装下来,如果以上的选项未选中,就会组织系统自动下载软件包的依赖项,即显示破坏了软件依赖关系。
参考博客: https://www.cnblogs.com/sinferwu/p/12726833.html
在/usr/lib/python2.7/dist-packages/rosdep2/sources_list.py中顶部直接插入两行代码取消SSL验证
输入命令打开配置文件:
sudo gedit /usr/lib/python2.7/dist-packages/rosdep2/sources_list.py
打开后在合适位置添加以下代码:
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
sudo rosdep init
至此,Ros全部的安装步骤以及经常会遇到的几大问题的解决办法已经介绍完毕,希望大家都能够顺利安装,成功迈入Ros的大门!