解决方法:
catkin build 没有执行make install ,所以ompl库在catkin build后生成的.h文件和链接库并没有安装到上述OMPL_INCLUDE_DIRS和OMPL_LIBRARIES中,而是在devel文件中。
将find_package(ompl REQUIRED)改为:
set(OMPL_INCLUDE_DIRS "/home/hy/ws_moveit/devel/include")
set(OMPL_LIBRARIES "/home/hy/ws_moveit/devel/lib/libompl.so")
include_directories(
include
${catkin_INCLUDE_DIRS}
${OMPL_INCLUDE_DIRS}
)
target_link_libraries(avoid_static ${catkin_LIBRARIES} ${OMPL_LIBRARIES})