Ubuntu 22.04.2 LTS安装ROS Noetic遇损坏包问题求助
解决Ubuntu 22.04安装ROS Noetic时的依赖损坏问题
首先明确核心问题:ROS Noetic仅支持Ubuntu 20.04 LTS,Ubuntu 22.04对应的官方支持ROS版本是ROS Humble Hawksbill,这是你安装时出现大量依赖缺失、包损坏报错的根本原因。以下是两种处理方案:
方案一:安装适配Ubuntu22.04的ROS Humble(推荐)
1. 清理原有ROS残留
先卸载已安装的Noetic相关包并清理源:
sudo apt remove --purge ros-noetic-* sudo apt autoremove sudo apt clean sudo rm /etc/apt/sources.list.d/ros-latest.list
2. 安装ROS Humble
- 设置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 - 添加ROS2软件源:
sudo apt install software-properties-common sudo add-apt-repository universe sudo apt update && sudo apt install curl -y sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg 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 sudo apt install ros-humble-desktop-full - 配置环境变量:
echo "source /opt/ros/humble/setup.bash" >> ~/.bashrc source ~/.bashrc - 验证安装:
打开一个终端运行:
再新开一个终端运行:ros2 run demo_nodes_cpp talker
若能正常看到消息收发,说明安装成功。ros2 run demo_nodes_cpp listener
方案二:源码编译ROS Noetic(不推荐,兼容风险高)
如果一定要在Ubuntu22.04上安装Noetic,只能通过源码编译:
1. 安装编译依赖
sudo apt install python3-rosdep python3-rosinstall python3-rosinstall-generator python3-wstool build-essential sudo rosdep init rosdep update
2. 创建并初始化工作空间
mkdir -p ~/ros_noetic_ws/src cd ~/ros_noetic_ws/src rosinstall_generator desktop_full --rosdistro noetic --deps --tar > noetic-desktop-full.rosinstall wstool init -j8 ./noetic-desktop-full.rosinstall
3. 解决依赖并编译
rosdep install --from-paths src --ignore-src --rosdistro noetic -y cd ~/ros_noetic_ws catkin_make -DPYTHON_EXECUTABLE=/usr/bin/python3
4. 配置环境变量
echo "source ~/ros_noetic_ws/devel/setup.bash" >> ~/.bashrc source ~/.bashrc
注意:源码编译过程中可能会遇到大量版本兼容问题,需要逐个调试,不建议新手尝试。
内容的提问来源于stack exchange,提问作者贾鸿余
相关产品推荐
相关产品推荐

