Hi my new friend!

Ubuntu18.04安装ros melodic

  • Home
  • Ubuntu18.04安装ros melodic
Scroll down

Ubuntu18.04安装ros melodic

目前认为比较稳定的安装方案,无需翻墙。 ——BITFSD

换源(系统源)

  • 意义:Ubuntu默认源的服务器在国外,由于相关法律法规的限制,大陆对国外服务器的访问速率极慢,因此需要采用国内的镜像源进行替代。经过多次尝试,我们推荐使用中科大源

    1
    sudo gedit /etc/apt/sources.list

    这一句指令会要求输入密码,Linux系统的保密措施使得键盘的输入不会在终端里显示

    gedit是一个文本软件,相当于Windows系统的记事本

    将以下内容复制进刚才打开的文本框里,删除文本框里原有的一大堆东西

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    deb https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
    deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
    deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
    deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
    deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
    deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
    deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
    deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
    deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
    deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
  • 完成上述步骤后,在终端内输入:

    1
    2
    sudo apt-get update
    sudo apt-get upgrade
  • 再次执行例如sudo apt-get install等命令时发现下载速率有了极大提升

安装ros

  • 以下内容可参考ros官网

  • 选择下载源(ros源),我们仍然推荐使用中科大源

    1
    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'
  • 设置密匙

    1
    2
    sudo apt install curl # if you haven't already installed curl
    curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -
  • 更新源

    1
    sudo apt-get update
  • 安装ros-desktop

    1
    sudo apt-get install ros-melodic-desktop-full

    这一步结束后并不代表ros安装完成

  • 设置环境变量

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

    .bashrc文件中保存的环境变量在每次开启终端的时候会自动加载入新终端内,若要手动刷新,可使用source ~/.bashrc命令,~符号代表主目录

    若使用主题,比如zsh主题(可以美化终端),则运行

    1
    2
    echo "source /opt/ros/melodic/setup.zsh" >> ~/.zshrc
    source ~/.zshrc
  • 准备依赖包

    1
    sudo apt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essential
  • 初始化rosdep

    1
    2
    3
    sudo apt install python-rosdep
    sudo rosdep init
    rosdep update

    不出意外在运行前两个命令后,第三个命令会运行失败,终端报错显示超时,这是因为rosdep update命令会请求远程服务器,而这个服务器位于国外,所以,我们对默认的地址进行修改,采用国内的镜像进行替代

  • 以下内容参考ROS rosdep init/update百分百解决 (qq.com)

  1. 修改20-default.list

    1
    2
    cd /etc/ros/rosdep/sources.list.d
    sudo gedit 20-default.list

    将内容替换为:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    # os-specific listings first rosdep update
    yaml https://gitee.com/wybros/rosdistro/raw/master/rosdep/osx-homebrew.yaml osx

    # generic
    yaml https://gitee.com/wybros/rosdistro/raw/master/rosdep/base.yaml
    yaml https://gitee.com/wybros/rosdistro/raw/master/rosdep/python.yaml
    yaml https://gitee.com/wybros/rosdistro/raw/master/rosdep/ruby.yaml
    gbpdistro https://gitee.com/wybros/rosdistro/raw/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. 修改gbpdistro_support.py

    1
    2
    cd /usr/lib/python2.7/dist-packages/rosdep2/
    sudo gedit gbpdistro_support.py

    将里面所有的 raw.githubusercontent.com/ros/rosdistro/master
    替换成gitee.com/wybros/rosdistro/raw/master

  3. 修改rep3.py

    1
    2
    cd /usr/lib/python2.7/dist-packages/rosdep2/
    sudo gedit rep3.py

    将里面所有的 raw.githubusercontent.com/ros/rosdistro/master
    替换成gitee.com/wybros/rosdistro/raw/master

  4. 修改sources_list.py

    1
    2
    cd /usr/lib/python2.7/dist-packages/rosdep2/
    sudo gedit sources_list.py

    将里面所有的 raw.githubusercontent.com/ros/rosdistro/master
    替换成gitee.com/wybros/rosdistro/raw/master

  5. 修改__init__.py

    1
    2
    cd /usr/lib/python2.7/dist-packages/rosdistro/
    sudo gedit __init__.py

    将里面所有的 raw.githubusercontent.com/ros/rosdistro/master
    替换成gitee.com/wybros/rosdistro/raw/master

  • 最后再次执行rosdep update,等待片刻即可安装成功

验证

  • 新建终端,输入roscore,无报错

我是学生,给我钱

其他文章
目录导航 置顶
  1. 1. Ubuntu18.04安装ros melodic
    1. 1.1. 换源(系统源)
    2. 1.2. 安装ros
    3. 1.3. 验证
请输入关键词进行搜索