ROS - find_package - 其他本地包中的 MSG

ROS - find_package - MSG in other local package

我在 ROS 上工作,但在 CMAKE 步骤中受阻。 所以解释一下

build
devel
src
  package_a
    node_a
      source
        node_a.cpp
    CMakeList.txt
    package.xml
  package_b
    msg
      msg_between_a_b.msg
    node_b
      source
        node_b.cpp
    CMakeList.txt
    package.xml

我在 CMakeList.txt 的步骤中受阻 package_a。 包a需要知道消息定义在package_b.

来自 TERM 控制台的错误消息。

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

我(非常)对“package_b_DIR”感兴趣。

这是我在CMalkeList.txt中写的:

# SEARCH package that already EXIST in /opt/ros
find_package(catkin REQUIRED COMPONENTS
 message_generation
 rostime
 roscpp
 std_msgs
 rosconsole
 roscpp_serialization)

# Add package PACKAGE_B (usefull) for MSG
find_package(catkin REQUIRED COMPONENTS
  package_b)

非常非常感谢!

问题已解决

1. ROS 应找到 package_b.

如果为真,您可以通过此命令找到此文件:

find ./ -type f -name "*Config.cmake"

结果:

./build/package_b/catkin_generated/installspace/package_bConfig.cmake

./devel/share/package_b/cmake/package_bConfig.cmake

如果没有,打开 CMakeList.txt 并检查 IF:

catkin_package(
)

通过catkin_make检查构建是否成功。

2。告知包a需要包b

通知package_a后需要package_b。 此信息在 package_a 的 package.xml 中:

找到并告知需要package_b。

<build_depend>package_b</build_depend>