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-*
相关推荐
__Witheart__10 分钟前
RK 3588 Ubuntu SDK 编译 Linux Header(标头)
linux·ubuntu·rockchip
__Witheart__28 分钟前
RK 3588 Ubuntu SDK 编译流程
ubuntu·rockchip
Moshow郑锴12 小时前
Ubuntu 26.04 中文输入法 : fcitx5+Rime中州韵引擎
linux·运维·ubuntu
Moshow郑锴15 小时前
Ubuntu 26.04 更换阿里云源镜像
linux·运维·ubuntu
梦想的颜色19 小时前
从零入门:Docker在Ubuntu上的安装、使用与主流镜像仓库实战(Java/Go/MySQL/PostgreSQL/MongoDB/Nginx
java·ubuntu·docker
行智科技20 小时前
FAST-LIVO2 源码精读(二):环境搭建与编译避坑
算法·ubuntu·自动驾驶·slam
Qres82121 小时前
docker & WSL & Ubuntu安装记录
ubuntu·docker·容器·wsl
暂未成功人士!1 天前
点云处理的关键技术流程和常用算法
ros·pcl·点云处理·点云去噪滤波
祭曦念1 天前
【共创季稿事节】鸿蒙原生 ArkTS 布局:NavRouter + NavDestination 导航布局实战
ubuntu·华为·harmonyos
黑白园1 天前
【环境搭建】虚拟机及Ubuntu安装所需的电脑硬件资源
linux·ubuntu