设置编码

1
sudo apt update && sudo apt install locales
1
sudo locale-gen en_US en_US.UTF-8
1
sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
1
export LANG=en_US.UTF-8

添加源

1
sudo apt update && sudo apt install curl gnupg lsb-release 
1
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg 
1
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(source /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null

如遇报错“Failed to connect to raw.githubusercontent.com”,可参考https://www.guyuehome.com/37844

安装ROS2

1
sudo apt update
1
sudo apt upgrade

引用: