[ROS学习](1) Ubuntu18.04 下的ROS安装

[ROS学习](1) Ubuntu18.04 下的ROS安装

文章目录

  • [ROS学习](1) Ubuntu18.04 下的ROS安装
    • 更换软件源
    • 安装ROS
    • 构建项目的workspace
    • 【参考】:

更换软件源

  1. 备份原文件

     sudo cp /etc/apt/sources.list /etc/apt/sources.list.bcakup
    
  2. 打开文件,添加源,或替换掉原来所有内容
    使用 vim 编辑器(可将 vim 替换为 gedit 编辑器进行编辑)

    sudo vi /etc/apt/sources.list
    
    # 阿里云源
    deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
    # 测试版源
    deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
    # 源码
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
    # 测试版源
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
    
  3. 更新软件列表

    sudo apt-get update
    
  4. 更新软件(可选)

    sudo apt-get upgrade
    

安装ROS

ROS官网安装教程

  1. 设置软件源

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

    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 -
    
  3. 更新软件源

    sudo apt update
    
  4. 安装

    共有四个版本,建议安装full版本

    desktop-full:

    sudo apt install ros-melodic-desktop-full
    

    desktop:(普通版本)

    sudo apt install ros-melodic-desktop
    

    ROS-Base:(基础版)

    sudo apt install ros-melodic-ros-base
    

    Individual Package:(独立包安装)(PACKAGE : 要安装的功能包名)

    sudo apt install ros-melodic-PACKAGE
    

    列举可用的功能包:

    apt search ros-melodic
    
  5. 配置环境

    echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrcsource ~/.bashrc
    
  6. 构建依赖包

    sudo apt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essential
    

    安装 rosdep

    sudo apt install python-rosdep
    

    初始化及更新 rosdep

    sudo rosdep initrosdep update
    

    解决rosdep initrosdep update 访问超时的问题

    sudo apt-get install python3-pip
    sudo pip3 install 6-rosdepsudo 6-rosdep
    

构建项目的workspace

  1. 创建工作空间文件夹
    于确定的目录下打开终端
    创建新的文件夹 ros_work_space

    mkdir ros_work_space
    

    进入该目录下

    cd ros_work_space/
    

    创建 src 目录

    mkdir src
    

    进入 src 目录下

    cd src/
    

    使用ros指令生成 CMakeLists.txt

    catkin_init_workspace
    
  2. 编译工作空间
    返回 src 目录下

    cd ..
    

    输入指令对该工作空间进行编译

    catkin_make
    
  3. 设置环境变量
    输入指令以设置环境变量

    source devel/setup.bash
    

    输入指令以查看设置的环境变量

    echo $ROS_PACKAGE_PATH
    

    在修改完环境变量之后重启终端窗口才可以生效

【参考】:

  • 【ROS安装小技巧】rosdep update time out 报错问题的解决方案

你可能感兴趣的:(ROS开发,ubuntu,linux)