美文网首页
Ubuntu20.04安装ROS2 Foxy

Ubuntu20.04安装ROS2 Foxy

作者: Danny_a44d | 来源:发表于2022-08-22 19:14 被阅读0次

    参考
    官方安装
    Ubuntu 20.04 ROS2 Foxy安装
    这里使用国内的软件源。

    使用阿里云Ubuntu源

    cd /etc/apt/
    sudo cp sources.list sources.list.bak
    

    将文件内容替换为下面

    deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
    
    deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
    
    deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
    
    deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
    
    deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
    

    设置语言环境

    确保当前系统支持UTF-8编码,如果通过locale查看到已经支持可以跳过。

    locale  # check for UTF-8
    
    sudo apt update && sudo apt install locales
    sudo locale-gen en_US en_US.UTF-8
    sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
    export LANG=en_US.UTF-8
    
    locale  # verify settings
    

    设置源

    首先确认Ubuntu Universe repository已启用

    apt-cache policy | grep universe
    

    应该在输出结果中可以看到类似如下输出:

    500 http://us.archive.ubuntu.com/ubuntu focal/universe amd64 Packages
        release v=20.04,o=Ubuntu,a=focal,n=focal,l=Ubuntu,c=universe,b=amd64
    

    如果没有,可以通过下面的命令设置:

    sudo apt install software-properties-common
    sudo add-apt-repository universe
    

    添加密钥和源

    sudo apt update && sudo apt install curl gnupg2 lsb-release
    curl http://repo.ros2.org/repos.key | sudo apt-key add -
    sudo sh -c 'echo "deb http://packages.ros.org/ros2/ubuntu `lsb_release -cs` main" > /etc/apt/sources.list.d/ros2-latest.list'
    

    安装ROS2 Foxy

    sudo apt update
    sudo apt upgrade
    sudo apt install ros-foxy-desktop
    

    测试

    source /opt/ros/foxy/setup.bash
    ros2 run demo_nodes_cpp talker
    

    结果:


    卸载

    sudo apt remove ~nros-foxy-* && sudo apt autoremove
    

    完整移除

    sudo rm /etc/apt/sources.list.d/ros2.list
    sudo apt update
    sudo apt autoremove
    sudo apt upgrade
    

    相关文章

      网友评论

          本文标题:Ubuntu20.04安装ROS2 Foxy

          本文链接:https://www.haomeiwen.com/subject/ewbggrtx.html