如何修复 ROS colcon build 错误:Could not find a package configuration file provided by "hardware_interface"

问题

在使用 colcon build 构建 ROS2 工作空间时,你会看到以下错误日志:

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

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

    hardware_interfaceConfig.cmake
    hardware_interface-config.cmake

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

解决方案

要安装它,请使用:

install_hardware_interface.sh
sudo apt -y install ros-jazzy-hardware-interface

或针对你的发行版使用类似命令。


Check out similar posts by category: Robotics, ROS