• ROS-Noetic安装与环境搭建-Ubuntu20


    1.设置安装源

    官方默认安装源:

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

    或来自国内清华的安装源

    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'
    
    • 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.设置key

    sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
    
    • 1

    3.安装

    更新软件源

    sudo apt update
    
    • 1

    安装ROS,注意这里的ROS版本需要和Ubuntu版本对应

    UbuntuROS
    14.04indigo
    16.04kinetic
    18.04melodic
    20.04noetic

    所以我们安装noetic版本

    sudo apt-get install ros-noetic-desktop-full
    
    • 1

    这个过程耗时较长,而且会出现失败的风险,可以多次重复调用该命令,直至成功

    4.配置环境变量

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

    因为我装了zsh的终端,所以这个指令应该改为如下指令,但是默认终端是bash,所以没必要修改

    echo "source /opt/ros/noetic/setup.zsh" >> ~/.zshrc
    source ~/.zshrc
    
    • 1
    • 2

    5.卸载

    如果需要卸载ROS可以调用如下命令:

    sudo apt-get remove ros-noetic-*
    
    • 1

    6.安装后构建依赖

    在 noetic 最初发布时,和其他历史版本稍有差异的是:没有安装构建依赖这一步骤。随着 noetic 不断完善,官方补齐了这一操作。

    首先安装依赖工具

    sudo apt-get install python3-rosdep python3-rosinstall python3-rosinstall-generator python3-wstool build-essential
    
    • 1

    初始化rosdep

    sudo rosdep init
    rosdep update
    
    • 1
    • 2

    如果没有意外的话出现意外了,rosdep初始化无法成功,因为有几个文件下载不下来,这是因为国内墙和DNS污染的原因,即使我科学上网了,也下载不下来,就很离谱,这里只提供一个解决方案,就是将需要下载的文件下载到本地后替换。

    7.解决rosdep问题

    下载文件

    cd ~
    git clone https://github.com/ros/rosdistro.git
    
    # 那么这个文件就被下载到了你的用户目录下
    # 也就是 /home/[xxx]/rosdistro
    # 这里的[xxx]也就是你的用户名
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    修改文件

    cd /home/[xxx]/rosdistro/rosdep/sources.list.d/
    sudo gedit 20-default.list 
    
    • 1
    • 2

    将这个文件的内容替换如下,注意[xxx]是你的用户名,不要直接写[xxx]

    # os-specific listings first
    yaml file:///home/[xxx]/rosdistro/rosdep/osx-homebrew.yaml osx
    
    # generic
    yaml file:///home/[xxx]/rosdistro/rosdep/base.yaml
    yaml file:///home/[xxx]/rosdistro/rosdep/python.yaml
    yaml file:///home/[xxx]/rosdistro/rosdep/ruby.yaml
    gbpdistro file:///home/[xxx]/rosdistro/releases/fuerte.yaml fuerte
    
    # newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10

    除了上面这个文件之外还有四个文件需要修改,这四个文件中的 raw.githubusercontent.com/ros/ 都需要被替换为 file:///home/[xxx]/

    # 1 
    sudo gedit /usr/lib/python3/dist-packages/rosdistro/__init__.py
    
    • 1
    • 2
    # 2 
    sudo gedit /usr/lib/python3/dist-packages/rosdep2/gbpdistro_support.py
    
    • 1
    • 2
    # 3 
    sudo gedit /usr/lib/python3/dist-packages/rosdep2/sources_list.py
    
    • 1
    • 2
    # 4
    sudo gedit /usr/lib/python3/dist-packages/rosdep2/rep3.py
    
    • 1
    • 2

    最后直接update

    rosdep update
    
    • 1

    就可以正常实现 rosdep 的初始化与更新了。

  • 相关阅读:
    RISC-V架构学习——C语言内嵌汇编总结
    ROS 中自定义消息需要配置的文件信息
    kubeadm搭建k8s高可用集群(keepalived+nginx+3master)
    Vue学习:Vue中的数据代理
    简述防抖与节流,必懂(含完整模拟实例)
    喜讯|宏时数据获得CMMI3级认证!欢迎了解自研统一运维监控平台!
    CSS动画-transition/animation
    Kubernetes实战(五)-pod之间网络请求实战
    如何从base64中获取图像的宽度、高度、Uint8ClampedArray
    数据结构与算法之堆: Leetcode 313. 超级丑数 (Typescript版)
  • 原文地址:https://blog.csdn.net/weixin_43903639/article/details/126168051