Ubuntu24.04安装ROS Jazzy
相比其他常规安装方式主要解决安装过程中出现的E: 无法修正错误因为您要求某些软件包保持现状就是它们破坏了软件包间的依赖关系问题其他博客或者AI给出的方案都是使用aptitude进行解决感觉不喜欢这种方式其实换成清华源就解决了。直接开始1、安装基础工具sudo apt install curl gnupg lsb-release gedit -y2、启用 Universe 源sudo add-apt-repository universe sudo apt update3、添加 ROS2 官方 GPG keysudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key \ -o /usr/share/keyrings/ros-archive-keyring.gpg4、添加 ROS2 软件源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上述基础工作完成后就可以sudo apt update更新安装了但是不出意外意外就出现了E: 无法修正错误因为您要求某些软件包保持现状就是它们破坏了软件包间的依赖关系5、修改为清华源安装在 Ubuntu 24.04 之前Ubuntu 的软件源配置文件使用传统的 One-Line-Style路径为/etc/apt/sources.list从 Ubuntu 24.04 开始Ubuntu 的软件源配置文件变更为 DEB822 格式路径为/etc/apt/sources.list.d/ubuntu.sources。首先将原始的软件源备份cp /etc/apt/sources.list.d/ubuntu.sources ~/Desktop然后进入清华源Ubuntu软件仓库https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/选择DEB822 格式 Ubuntu 24.04 LTS,把绿色方框中的内容替换原ubuntu.sources的内容Types: deb URIs: https://mirrors.tuna.tsinghua.edu.cn/ubuntu Suites: noble noble-updates noble-backports Components: main restricted universe multiverse Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg # 默认注释了源码镜像以提高 apt update 速度如有需要可自行取消注释 # Types: deb-src # URIs: https://mirrors.tuna.tsinghua.edu.cn/ubuntu # Suites: noble noble-updates noble-backports # Components: main restricted universe multiverse # Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg # 以下安全更新软件源包含了官方源与镜像站配置如有需要可自行修改注释切换 Types: deb URIs: http://security.ubuntu.com/ubuntu/ Suites: noble-security Components: main restricted universe multiverse Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg首先打开编辑/etc/apt/sources.list.d/ubuntu.sources文件sudo gedit /etc/apt/sources.list.d/ubuntu.sources将清华源内容替换原文件中的内容替换完成后更新source /etc/apt/sources.list.d/ubuntu.sources sudo apt update6、安装ROS Jazzy根据自己需要如果是全部安装包括所有开发工具和图形界面使用安装指令sudo apt install ros-jazzy-desktop-full -y如果是安装适合大多数桌面开发的简化桌面版本使用安装指令sudo apt install ros-jazzy-desktop -y如果只是安装只包含核心功能、适合基础开发的版本使用安装指令sudo apt install ros-jazzy-ros-base -y上述指令三选一即可安装完成之后添加环境变量echo source /opt/ros/jazzy/setup.bash ~/.bashrc source ~/.bashrc7、安装开发工具并初始化安装ROS开发工具包sudo apt install ros-dev-tools -y安装自动补全功能包sudo apt install python3-argcomplete -y安装colcon构建工具和python3-pipsudo apt install python3-pip python3-colcon-common-extensions -y安装并初始化rosdepsudo apt install python3-rosdep -y sudo rosdep init rosdep update8、验证首先打开一个终端运行ros2 run demo_nodes_cpp talker然后打开另外一个终端运行ros2 run demo_nodes_py listener恭喜已经成功在你的电脑里面安装了ROS2 Jazzy