如何在Ubuntu 24.04操作系统上成功地安装ROS2版本?
时间: 2024-11-09 09:25:45 浏览: 31
在Ubuntu 24.04上安装ROS2(Robot Operating System)需要几个步骤。以下是安装的基本流程:
1. 更新系统:
```sh
sudo apt update && sudo apt upgrade
```
2. 添加ROS2的官方存储库:
```sh
sudo sh -c 'echo "deb [arch=amd64] https://download.ros2.org/ubuntu focal main" > /etc/apt/sources.list.d/ros2-focal.list'
```
3. 安装密钥:
```sh
wget https://download.ros2.org/key.asc -O - | sudo apt-key add -
```
4. 验证存储库:
```sh
sudo apt verify ros2-focal.list
```
5. 添加软件源并更新包列表:
```sh
sudo apt update
```
6. 安装ROS2(例如安装`foxy`版本):
```sh
sudo apt install ros-foxy-desktop
```
7. 设置环境变量(例如,添加到~/.bashrc文件):
```sh
echo "source /opt/ros/foxy/setup.bash" >> ~/.bashrc
source ~/.bashrc
```
8. 初始化工作空间(如果尚未创建):
```sh
roslaunch --help
```
如果提示初始化,可以运行:
```sh
ros2 workspaces create my_workspace
cd my_workspace
ros2 src
9. 现在你可以开始安装所需的包了,比如创建一个节点 `ros2 package create my_node`
阅读全文