Ubuntu22.04 安装 ROS2 Humble

ROS2 Documentation: Humble

Ubuntu 22.04 对应的 ROS 2 版本是 ROS 2 Humble Hawksbill (LTS)。

1.设置系统区域

确保区域设置支持UTF-8

bash 复制代码
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 查看编码信息。

2.添加 ROS 2 软件源

2.1.启用 Universe 软件源

bash 复制代码
sudo apt install software-properties-common
sudo add-apt-repository universe

2.2.添加 GPG 密钥和软件源

下载 ROS GPG Key

bash 复制代码
sudo apt install curl gnupg2
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key  -o /usr/share/keyrings/ros-archive-keyring.gpg

添加 ROS2 软件源,这里使用了清华镜像源

bash 复制代码
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] https://mirrors.tuna.tsinghua.edu.cn/ros2/ubuntu jammy main" | tee /etc/apt/sources.list.d/ros2.list > /dev/null

# 官方源(可选)
# 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

3.安装 ROS2 包

bash 复制代码
sudo apt update
sudo apt install ros-humble-desktop # 完整桌面版
# sudo apt install ros-humble-ros-base # 基本版,只包含核心组件,不含图形化工具

4.配置环境变量

为了让系统能够识别 ROS 2 的命令和功能,需要将 ROS 2 的环境变量添加到用户的 shell 配置文件中,对于 bash 用户,运行以下命令:

bash 复制代码
echo "source /opt/ros/humble/setup.bash" >> ~/.bashrc
source ~/.bashrc

输入以下命令验证 ROS 2,如果安装成功,会输出 2

bash 复制代码
echo $ROS_VERSION

5.卸载 ROS2

如果需要卸载ROS 2,运行以下命令:

bash 复制代码
sudo apt remove --purge ros-humble-*
相关推荐
biubiubiu07067 小时前
Ubuntu学习笔记
笔记·学习·ubuntu
Eternal-Student10 小时前
【ubuntu】在Linux系统上安装Microsoft Edge浏览器
linux·ubuntu·microsoft
肩上风骋14 小时前
ubuntu系统使用ifconfig查询网络IP的时候,只能查到本地回环地址,无其他网络接口IP
网络·ubuntu·只能查到本地回环地址
星际工程师15 小时前
Windows10安装配置wsl+Ubuntu20.04环境
ubuntu
奔跑吧 android17 小时前
【Docker】【2.docker 安装 ubuntu 桌面版】
ubuntu·docker·容器
人工智能的苟富贵21 小时前
Rust 异步编程实践:用 Tokio 实现一个迷你 HTTP 服务
ubuntu·http·rust
Tipriest_1 天前
自定义ROS topic 的常用消息格式及类型
ros·msg
爱尔兰的楠小楠1 天前
Windows上使用WSL2创建Ubuntu系统,实现无缝高效开发的体验
linux·windows·ubuntu
Fluency-111 天前
ubuntu中ssh连接root用户
linux·ubuntu·ssh
0wioiw01 天前
Ubuntu(③vsftpd)
linux·服务器·ubuntu