ROS2报错缺少“diagnostic_updater“,CMake did not find diagnostic_updater. 解决思路

问题描述:

今天在安装激光雷达的功能包的时候,在使用colcon build编译时,出现了如下错误

CMake Error at CMakeLists.txt:17 (find_package):
  By not providing "Finddiagnostic_updater.cmake" in CMAKE_MODULE_PATH this
  project has asked CMake to find a package configuration file provided by
  "diagnostic_updater", but CMake did not find one.

  Could not find a package configuration file provided by
  "diagnostic_updater" with any of the following names:

    diagnostic_updaterConfig.cmake
    diagnostic_updater-config.cmake

  Add the installation prefix of "diagnostic_updater" to CMAKE_PREFIX_PATH or
  set "diagnostic_updater_DIR" to a directory containing one of the above
  files.  If "diagnostic_updater" provides a separate development package or
  SDK, be sure it has been installed.

仔细查看错误信息其实就知道是缺少了diagnostic_updater这个包导致出现的错误,但是跟着网上的一些安装指令发现根本无法定位到包,如下所示
我找到的安装指令是

sudo apt-get install ros-kinetic-diagnostics

但是直接出现

E: Unable to locate package ros-kinetic-diagnostics

环境

Ubuntu22.04
ROS2 humble


原因分析及解决方法:

仔细分析了一下,其实是缺少了这个包,所以在思考之后,我明白了,我需要去下载适配于我的ros2 humble的diagnostic_updater的包,那么其实解决方法就很简单了,就是先寻找适配的包,然后下载即可

sudo apt-cache search diagnostics updater #在apt源里寻找同样名字的包

返回了

libdiagnostic-updater-dev - development files for diagnostic_updater (Robot OS)
libdiagnostic-updater0d - library for diagnostic_updater (Robot OS)
python3-diagnostic-updater - Python library diagnostic_updater (Robot OS)
ros-humble-diagnostic-updater - diagnostic_updater contains tools for easily updating diagnostics.
ros-rolling-diagnostic-updater - diagnostic_updater contains tools for easily updating diagnostics.

因此,ros-humble-diagnostic-updater这个包就是我们所需的包,所以使用apt下载指令就好啦

sudo apt install ros-humble-diagnostic-updater

猜你喜欢

转载自blog.csdn.net/scarecrow_sun/article/details/127869660
今日推荐