ubuntu24.04安装布置ros

最近换电脑布置机器人环境,下了24.04,但是网上的都不太合适,于是自己试着布置好了,留作有需要的人一起看看。


前言

布置ros。


一、确认 ROS 发行版名称

  • ROS 1 和 ROS 2 的发行版名称是不同的。以下是一些常见的 ROS 发行版名称:

    • ROS 1:

      • noetic(适用于 Ubuntu 20.04)

    • ROS 2:

      • humble(适用于 Ubuntu 22.04)

      • iron(适用于 Ubuntu 22.04)

      • rolling(持续更新的开发版本)

二、检查你的 Ubuntu 版本

  • 运行以下命令检查你的 Ubuntu 版本:

  • lsb_release -a
  • 根据你的 Ubuntu 版本选择合适的 ROS 发行版:

    • Ubuntu 20.04:ROS 1 noetic 或 ROS 2 foxy

    • Ubuntu 22.04:ROS 2 humble 或 iron

    • Ubuntu 24.04:目前 ROS 尚未正式支持,但你可以尝试使用 rolling 版本。

三、安装正确的 ROS 发行版

如果你使用的是 Ubuntu 22.04,可以尝试安装 ROS 2 humble

sudo apt update
sudo apt install ros-humble-desktop

 如果你使用的是 Ubuntu 20.04,可以尝试安装 ROS 1 noetic

sudo apt update
sudo apt install ros-noetic-desktop

 四、对于Ubuntu24.04

如果你使用的是 Ubuntu 24.04(noble),ROS 尚未正式支持该版本。你可以尝试以下方法:

  1. 使用 Docker:安装 Docker:

sudo apt update
sudo apt install docker.io

拉取 ROS 2 Humble 的 Docker 镜像:

sudo docker pull osrf/ros:humble-desktop

运行 ROS 容器:

sudo docker run -it osrf/ros:humble-desktop

2.使用 rolling 版本

  • rolling 是 ROS 2 的持续更新版本,可能支持较新的 Ubuntu 发行版。

  • 添加 rolling 的源:

sudo sh -c 'echo "deb http://packages.ros.org/ros2/ubuntu $(lsb_release -cs) main" > /etc/apt/sources.list.d/ros2-latest.list'

 导入 GPG 密钥:

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654

 更新并安装:

sudo apt update
sudo apt install ros-rolling-desktop

 这里我直接安装的rolling版本

 刚开始还以为ros有问题后来发现ros命令可以实现

五、错误检查

安装完成之后检查ros:

 1.看版本

ros2 --version

我这里不能显示版本,可能是 这个命令不能用

2.检查 ros2 命令

  • 运行以下命令检查 ros2 命令是否可用:

which ros2
  • 如果输出类似 /opt/ros/rolling/bin/ros2,说明 ros2 命令已正确安装。

3检查环境变量

  • 确保你已经正确设置了 ROS 2 的环境变量。运行以下命令:

source /opt/ros/rolling/setup.bash

4. 重新安装 ROS 2

  • 如果上述步骤未能解决问题,可以尝试重新安装 ROS 2:

    1. 移除现有的 ROS 2 安装:

sudo apt remove ros-rolling-desktop
sudo apt autoremove

 2.重新安装 ROS 2:

sudo apt update
sudo apt install ros-rolling-desktop

5. 检查 Python 环境

  • ROS 2 依赖于 Python 3。确保你的系统上安装了正确版本的 Python 3:

python3 --version

 如果输出不是 Python 3.8 或更高版本,请安装或更新 Python 3:

sudo apt update
sudo apt install python3

6. 运行 ROS 2 示例

  • 如果 ros2 --version 仍然无法正常工作,可以尝试运行一个 ROS 2 示例来验证安装:

ros2 run demo_nodes_cpp talker
  • 如果示例能够正常运行,说明 ROS 2 已正确安装,只是 ros2 --version 命令存在问题。

 这里可以成功运行。

总结

Ubuntu24.04布置ros

### ROS 2 Installation Guide for Ubuntu 24.04 For installing ROS 2 on Ubuntu 24.04, the setup involves several key steps to ensure a smooth and successful installation process. #### System Preparation Before starting with ROS 2 installation, it is important that the system has all necessary dependencies installed. For instance, libraries such as `libprotobuf-dev`, `libprotoc-dev`, `protobuf-compiler`, and `libeigen3-dev` are essential components required by various packages within ROS 2 environments[^2]. #### Setting Up Sources To add the ROS 2 repository sources list, one should use commands similar to those used in previous versions of Ubuntu but tailored specifically for version 24.04. This typically includes adding an appropriate line pointing towards ROS package repositories into `/etc/apt/sources.list.d/ros2-latest.list`. #### Installing ROS 2 Packages Once the source lists have been updated appropriately, users can proceed with installing desired ROS 2 distributions via APT after updating their local cache: ```bash sudo apt update && sudo apt upgrade sudo apt install ros-jazzy-desktop ``` The command installs the desktop variant which comes bundled with tools like RViz and rqt_gui among others useful utilities for development purposes under this distribution named "Jazzy Jalisco"[^1]. #### Environment Setup After completing the installation step successfully, configuring environment variables becomes crucial so applications know where these newly added binaries reside without requiring full paths each time they're invoked during usage sessions or scripts execution phases. A common practice here would be sourcing setup files provided alongside installations at terminal startup through `.bashrc` file modifications or directly invoking them whenever needed using shell commands. ```bash source /opt/ros/jazzy/setup.bash echo 'source /opt/ros/jazzy/setup.bash' >> ~/.bashrc ``` This ensures every new session starts off correctly configured automatically upon login events happening either locally from terminals attached physically connected monitors/keyboard setups or remotely over SSH connections established between machines across networks securely authenticated beforehand properly. --related questions-- 1. What additional software might need configuration post-installation? 2. How does one verify whether ROS 2 was installed correctly following completion of instructions given above? 3. Are there any specific hardware requirements associated when setting up ROS 2 Jazzy Jalisco on Ubuntu 24.04? 4. Can you provide guidance on troubleshooting common issues encountered while performing this installation procedure? 5. Is it possible to customize what gets included during the ROS 2 installation beyond just selecting the Desktop variant mentioned earlier?
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值