环境:VMware
系统:Ubuntu18.04
电脑里原本装的是20.04,按教程折腾了好几个小时也没装上,所以在虚拟机里又下了Ubuntu 18.04的系统,很顺利就装起来了……
第一步:更改镜像源
Sotfware Updater -- Ubuntu Software
前四项勾选 ,Download from 选择国内镜像源,此处选择了清华的镜像源。
第二步:设置sources.list
sources.list是Ubuntu系统保存软件源地址的文件,位于/etc/apt目录下,在这一步中我们需要将ROS的软件源地址添加到该文件中,确保后续安装可以正确找到ROS相关软件的下载地址。
可以直接添加ros源也可以添加国内的镜像源:
直接添加
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
国内镜像(清华的,也可以添加别的http://wiki.ros.org/ROS/Installation/UbuntuMirrors):
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu/ `lsb_release -cs` main" > /etc/apt/sources.list.d/ros-latest.list'
可通过命令行查看当前的sources.list
sudo vi /etc/apt/sources.list
退出:
esc-> :wq
第三步:添加秘钥
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
第四步:安装
sudo apt-get update
我直接安装了桌面完整版
sudo apt install ros-melodic-desktop-full
工具包依赖
sudo apt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essential
初始化
sudo rosdep init
rosdep update
上述过程中出现了一点问题,/etc/ros/rosdep/sources.list.d/20-default.list的文件似乎有点问题,解决方法是将原文件删除,然后再新建一个同名文件,将正确内容复制进去
sudo rm -f /etc/ros/rosdep/sources.list.d/20-default.list
udo gedit /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
# new
然后在执行
rosdep update
第五步:配置全局环境变量
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
检验安装结果:
roscore
出现下面代码表示安装成功