目录
文章目录
前言
1.设置软件源
2.设置密钥
3.安装
4.配置环境变量
5.配置编译依赖
5.1初始化rosdep
总结
前言
最近几次在Ubuntu上安装ROS,每次都会遇到不少坑要到网上找各位大神的文章。因此,特此将安装经验整理汇总了一下,以备后面需要的时候查阅。
1.设置软件源
国外的源更新软件时会比较慢,因此这里选择使用清华的软件源。
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu/'lsb_release -cs' main" > /etc/apt/source.list.d/ros-latest.list'
2.设置密钥
如果未安装curl,需要先安装此工具。
sudo apt install curl
设置密钥
curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -
此处常会遇到raw.githubusercontent.com无法访问的问题,解决方案如下:
首先,访问raw.githubusercontent.com网络查询raw.Githubusercontent.com的DNS。
其次,编辑/etc/hosts文件,将查找到的DNS及对应的URL地址添加到文件中,如图所示:
3.安装
首先,更新软件源为最新版本。
sudo apt update
其次,安装推荐的Desktop-Full Install版本。
sudo apt install ros-melodic-desktop-full
4.配置环境变量
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
5.配置编译依赖
sudo apt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essential
5.1初始化rosdep
sudo apt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essential
5.1初始化rosdep
首先,安装rosdep。
sudo apt install python-rosdep
其次,初始化并更新rosdep。
sudo rosdep init rosdep update
如果rosdep初始化或更新超时,需要修改如下文件内容。
修改/usr/lib/python2.7/dist-packages/rosdep2/sources_list.py:
变量DEFAULT_SOURCES_LIST_URL = 'https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list';
函数download_rosdep_data中的url_request = request.Request("https://ghproxy.com/" + url, headers={'User-Agent': 'rosdep/{version}'.format(version=__version__)})
修改/usr/lib/python2.7/dist-packages/rosdistro/__init__.py:
变量DEFAULT_INDEX_URL = 'https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml'
总结
以上简单的记录了在Ubuntu 18.04环境下安装ROS Melodic的安装步骤和安装过程中会遇到的一些常见的问题及其解决方案,希望能有所帮助。



