1. 任务描述
在ubuntu18系统中,使用
bloom-generate rosdebian --os-name ubuntu --ros-distro melodic
fakeroot debian/rules binary
打包生成deb文件。
2.问题描述
运行
bloom-generate rosdebian --os-name ubuntu --ros-distro melodic
时,报错:
==> Generating debs for ubuntu:bionic for package(s) ['robot_localization']
Could not resolve rosdep key 'message_runtime'
Try to resolve the problem with rosdep and then continue.
Continue [Y/n]?
3.解决方法
参考链接1:ros bloom-generate打包报 Could not resolve rosdep key ‘rclcpp‘ 类似错误
参考链接2:彻底解决ROS安装中 rosdep 的问题
综合上面两个链接的方案,解决方法如下:
- 安装pip3
sudo apt-get install python3-pip
- 安装 python 包 6-rosdep。此包暂未找到出处,有看到说来自b站六部工坊,但我没有搜到原始视频或文字资料。但不管怎样,它是能用的。
sudo pip3 install 6-rosdep
- 调用 6-rosdep
sudo 6-rosdep
- 执行 ROS 初始化
sudo rosdep init
- 在执行 ROS 更新时,附上版本号 melodic
rosdep update --rosdistro=melodic
- 打包和生成 deb,没有再出现问题
bloom-generate rosdebian --os-name ubuntu --ros-distro melodic
fakeroot debian/rules binary
4.问题原因分析
根据解决方法反推成因,猜测问题成因如下。
ROS melodic 版本已经停止维护了,所以在执行rosdep update
时默认会跳过该版本,这一点可以在执行rosdep update
时的输出中看到。为了让rosdep update
含有 melodic 版本,可以指定版本号,也就是 rosdep update --rosdistro=melodic
。解决本问题本来到这里就足够了,但由于国内网络原因,rosdep update
通常会执行失败,所以需要先解决rosdep update
的问题。
为了解决rosdep update
因网络问题运行失败的问题,鱼香ROS制作了rosdepc
(链接)。rosdepc
很好用,能一键式完成 ROS 的初始化和更新。
但在本问题的解决中,因为需要给rosdep update
附上参数--rosdistro=melodic
,所以rosdepc
难以发挥作用:rosdepc update --rosdistro=melodic
无法运行,执行rosdepc init
之后rosdep update --rosdistro=melodic
仍会提示“请先运行rosdep init
”。
因此,最终我找到了 6-rosdep 包来进行 ROS 的初始化和更新。