Ubuntu22.04 + ROS2 Humble的环境配置

Ubuntu22.04 + ROS2 Humble的环境配置

文章目录

    • [Ubuntu22.04 + ROS2 Humble的环境配置](#Ubuntu22.04 + ROS2 Humble的环境配置)

参考官方网站ROS2-Installation

ROS2的各种版本及维护计划,可以参考ROS2-List of Distributions

(1) Set locale

首先检查UTF-8的支持情况

bash 复制代码
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

(2) Setup Sources

然后添加apt源,

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

同时添加GPG-key

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

然后将下列仓库添加到源列表中

bash 复制代码
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null

(3)安装ROS2

首先进行upgrade确保是最新的环境,

bash 复制代码
sudo apt update
bash 复制代码
sudo apt upgrade

然后,选择是否部分安装,这边建议安装desktop版本,这就包含一些常用工具的安装比如RViz, Gazebo等,这里就保留官方的解释:

Desktop Install (Recommended): ROS, RViz, demos, tutorials.

bash 复制代码
sudo apt install ros-humble-desktop

ROS-Base Install (Bare Bones): Communication libraries, message packages, command line tools. No GUI tools.

bash 复制代码
sudo apt install ros-humble-ros-base

Development tools: Compilers and other tools to build ROS packages

bash 复制代码
sudo apt install ros-dev-tools

经过漫长的等待,终于安装成功了。然后添加环境变量,这样就避免了每次都手动source

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

(4)检查是否成功安装

启动那个经典的turtle_sim海龟模拟器,

bash 复制代码
ros2 run turtlesim turtlesim_node

然后新建另一个终端,

bash 复制代码
ros2 run turtlesim turtle_teleop_key

在这个终端里就能够用键盘的方向键来控制海龟的移动了。

相关推荐
朔北之忘 Clancy1 天前
2025 CSP-J 第二轮真题解析
c++·青少年编程·题解·noip·csp·信奥赛·noi
longlongzihan1 天前
LeetCode 17电话号码的字母组合:回溯算法(DFS)详解
c++·算法·leetcode·深度优先
yolo_guo1 天前
调试mysql延迟与libevent回调实际发送回复时机问题
c++·mysql·libevent
今晚打老虎1 天前
c++之提高A(前缀和)(第三课)
数据结构·c++·算法
by209991 天前
从结构体到对象:正式学习C++类的骨架、封装与this指针
c++·经验分享·学习
2601_962218611 天前
C语言中三种库的编译和使用方法
开发语言·c++
jimy11 天前
派生类重写基类虚函数(二):override的作用
开发语言·c++
ebiobiz1 天前
基于 GD32 Embedded Builder (GEB) 与 Nimmake 的 MCU 工程搭建指南
c++·python·单片机·嵌入式硬件·mcu
hetao17338371 天前
2026-09-29 hetao1733837 的刷题记录
c++·算法
:mnong1 天前
几何内核“四大金刚“:ACIS、Parasolid、CGM、Open CASCADE 核心特征深度解析
c++·cad·cax