本文将详细介绍在已安装 ROS2 humble 的 Ubuntu22.04 系统下,安装 ROS1 Noetic 并实现二者共存的具体步骤。
1. 更新系统
sudo apt update && sudo apt upgrade -y
2. 安装依赖
sudo apt install -y git build-essential cmake python3-pip python3-rosdep python3-rosinstall python3-rosinstall-generator python3-wstool libboost-all-dev
3. 创建 ROS1 工作空间
mkdir -p ~/ros_catkin_ws
cd ~/ros_catkin_ws
4. 下载 ROS1 源码
rosinstall_generator desktop --rosdistro noetic --deps --tar > noetic-desktop.rosinstall
wstool init src noetic-desktop.rosinstall
wstool update -t src
第二行代码安装卡顿后,另开端口运行第三行代码会补充安装。
5. 解决依赖问题
部分依赖在 Ubuntu22.04 环境下存在冲突,需要手动调整。进入下面指定目录,打开 package.xml 文件,删除 <run_depend>hddtemp</run_depend> 这一行,以解决冲突问题:
cd ~/ros_catkin_ws/src/diagnostics/diagnostic_common_diagnostics
6. 解决兼容问题
由于 ROS1 部分组件与 Ubuntu22.04 存在兼容性问题,需替换相关组件。先删除原有冲突组件,再从特定分支下载兼容版本:
cd ~/ros_catkin_ws/src
rm -r rosconsole urdf
git clone https://github.com/dreuter/rosconsole.git -b noetic-jammy
git clone https://github.com/dreuter/urdf.git -b set-cxx-version
7. 安装依赖
sudo pip install rosdepc
sudo rosdepc init
rosdepc update
cd ~/ros_catkin_ws
rosdepc install --from-paths src --ignore-src --rosdistro noetic -y
8. 设置 ROS1 环境变量
因为系统中已安装 ROS2,为避免环境变量冲突,在编译 ROS1 前需指定当前使用的 ROS 版本为 Noetic,在终端输入:
export ROS_DISTRO=noetic



