ROS:使用同一工作空间下不同包的头文件

例如:在B_package下使用A_package的头文件

A_package的配置

被引用的.h文件放在A_package/include/A_package/

CMakelist.txt

catkin_package(
		INCLUDE_DIRS include
)
include_directories(
	include
  	${
     catkin_INCLUDE_DIRS}
)
add_library(A_function
		include/A_package/A_function.h
		src/A_function.cpp)
target_link_libraries(A_function
		${
     catkin_LIBRARIES})

B_package的配置

package.xml

<build_depend>A_packagebuild_depend>
<exec_depend>A_packageexec_depend>

CMakelist.txt

find_package(catkin REQUIRED COMPONENTS
        A_package
        )
include_directories(
	include
  	${
     catkin_INCLUDE_DIRS}
)
add_executable(B_node
        app/B_node.cpp
        )
target_link_libraries(B_node
        ${
     catkin_LIBRARIES}
        A_function
        )

参考:ROS笔记:引用同一工作空间下其他包中的 .h 文件

你可能感兴趣的:(ROS学习)