在 Ubuntu 系统上安装 ROS2-Humble
时间: 2024-09-23 20:04:17 浏览: 49
ubuntu18.04安装ROS
要在Ubuntu系统上安装ROS2 Humble(Robot Operating System),你需要遵循以下步骤:
1. **更新系统**:
```bash
sudo apt update && sudo apt upgrade
```
2. **添加ROS2官方源**:
如果尚未加入,需要添加ROS2的官方apt源,可以在终端运行:
```
curl -fsSL https://download.releases_ros.org/ros2.key | gpg --dearmor > /usr/share/keyrings/ros-archive-keyring.gpg
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] https://download.releases_ros.org/distributions/humble main" | sudo tee /etc/apt/sources.list.d/ros2-humble.list
```
3. **安装依赖**:
```bash
sudo apt install -y software-properties-common ros-toolchain-focal
```
4. **安装ROS2**:
```bash
sudo apt install -y ros-focal-ros-core
```
5. **安装特定包**(例如,如果你需要安装`ros2-geometry`):
```bash
sudo apt install -y ros-focal-geometry
```
6. **初始化工作空间**(如果你计划在一个单独的工作空间内工作):
```bash
mkdir -p ~/catkin_ws/src
cd ~/catkin_ws
catkin init
```
7. **将ROS2包复制到工作空间**:
```bash
git clone <repository_url> src/<package_name>
```
8. **构建和安装**:
```bash
cd ~/catkin_ws
colcon build --symlink-install
```
9. **验证安装**:
可以通过运行命令 `ros2 run <package_name> <command>` 来测试新安装的包。
阅读全文