Ubuntu 22.04 中安装 ROS2 Humble
1.4.1前置配置
语言环境支持 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
启用 Universe 仓库:
sudo apt install software-properties-common
sudo add-apt-repository universe
1.4.2安装 ROS2 软件源
解决 DNS 污染问题(国内用户必做):
查询域名 IP:访问 IPAddress,搜索 raw.githubusercontent.com,获取 IP(如 185.199.108.133)
修改 hosts 文件:
sudo vi /etc/hosts
添加一行:
185.199.108.133 raw.githubusercontent.com
添加 ROS2 仓库:
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key
-o /usr/share/keyrings/ros-archive-keyring.gpg
echo “deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg]
http://packages.ros.org/ros2/ubuntu jammy main” | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null
1.4.3安装 ROS2
更新并安装桌面版:
sudo apt update
su