如何在Ubuntu22.04中安装ROS2-Humble

如何在Ubuntu22.04中安装ROS2-Humble

1、首先先确认自己的Ubuntu版本

bash 复制代码
vm@vm:~$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 22.04.5 LTS
Release:	22.04
Codename:	jammy

2、设置语言环境

bash 复制代码
locale  # 检查是否支持 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  # 验证设置是否成果

3、设置软件源

启动Ubuntu universe存储库

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

将ROS 2 apt存储库添加到系统,用apt授权我们的GPG密钥

bash 复制代码
sudo apt update && sudo apt install curl gnupg lsb-release -y
## 使用国内镜像(更快更稳定,推荐)
sudo curl -sSL https://mirrors.tuna.tsinghua.edu.cn/rosdistro/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 $(source /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null

4、安装Humble

首先更新apt存储库缓存:

bash 复制代码
sudo apt update

然后升级已安装的软件(ROS2软件包建立在经常更新的Ubuntu系统上,在安装新软件包之前请确保您的系统是最新的):

bash 复制代码
sudo apt upgrade

安装桌面版ROS2(建议),包含:ROS、RViz、示例与教程,安装命令如下,如果需要安装其他版本,将下面命令中的humble替换对应的版本号:

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

安装colcon构建工具

bash 复制代码
sudo apt install python3-colcon-common-extensions

5、加载ROS2环境

永久加载(推荐,一劳永逸)

bash 复制代码
## 将初始化命令添加到您的 ~/.bashrc文件中,这样每次打开终端都会自动设置好 ROS 2 环境。
echo "source /opt/ros/humble/setup.bash" >> ~/.bashrc
## 然后,让更改立即生效:
source ~/.bashrc

6、安装cartographer进行SLAM(额外的)

bash 复制代码
sudo apt install ros-humble-cartographer ros-humble-cartographer-ros
相关推荐
向日的葵0063 小时前
langchain的Tools教程(三)
python·langchain·tools
言乐64 小时前
Python实现可运行解密游戏游戏框架
python·游戏·小程序·游戏程序·关卡设计
YUS云生5 小时前
Python学习笔记·第31天:FastAPI入门——路由、路径参数、查询参数与请求体
笔记·python·学习
旖-旎5 小时前
《LeetCode647 回文子串 || LeetCode 5 最长回文子串》
c++·算法·leetcode·动态规划·哈希算法
智写-AI5 小时前
真实有效的免费降英文AI工具服务商
人工智能·python
Darkwanderor5 小时前
对Linux的进程控制的研究
linux·运维·c++
yuhuofei20215 小时前
【Python入门】了解掌握Python中函数的基本使用
python
云泽8086 小时前
从零吃透 C++ 异常:抛出捕获、栈展开、异常重抛与编码规范详解
开发语言·c++·代码规范
REDcker6 小时前
libdatachannel 快速入门
c++·webrtc·datachannel