參考
官方安裝
Ubuntu 20.04 ROS2 Foxy安裝
這里使用國(guó)內(nèi)的軟件源馁启。
使用阿里云Ubuntu源
cd /etc/apt/
sudo cp sources.list sources.list.bak
將文件內(nèi)容替換為下面
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
設(shè)置語(yǔ)言環(huán)境
確保當(dāng)前系統(tǒng)支持UTF-8編碼而咆,如果通過(guò)locale
查看到已經(jīng)支持可以跳過(guò)参淹。
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
測(cè)試
source /opt/ros/foxy/setup.bash
ros2 run demo_nodes_cpp talker
結(jié)果:
卸載
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