Ubuntu20.04安装ROS2 Foxy

参考
官方安装
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

添加密钥和源

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://mirrors.aliyun.com/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-latest.list
sudo apt update
sudo apt autoremove
sudo apt upgrade

你可能感兴趣的:(Ubuntu20.04安装ROS2 Foxy)