Messages not being generated before dependent package
Hi All,
I am having a very frustrating problem. I have a package pac_industrial_robot_driver
that uses messages declared in another package ros_opto22
. However, I cannot get the dependency recognised by the pac_industrial_robot_driver
CMakeLists.txt
file.
The error message:
[ 31%] In file included from /home/controller/catkin_ws/src/pac_industrial_robot_driver/lib/PacIndustrialDriver.cpp:8:0:
/home/controller/catkin_ws/src/pac_industrial_robot_driver/include/PacIndustrialDriver.hpp:32:38: fatal error: ros_opto22/valve_command.h: No such file or directory
Clearly it is not finding the include file.
# Create executables and add dependencies.
foreach(p ${ALL_EXECS})
add_executable(${p} ${${p}_SRC})
add_dependencies(${p} ${PROJECT_NAME}_generate_messages_cpp ${catkin_EXPORTED_TARGETS} ${${PROJECT_NAME}_EXPORTED_TARGETS} ros_opto22_EXPORTED_TARGETS ros_opto22_gencpp ros_opto22_generate_messages_cpp)
target_link_libraries(${p} ${ALL_LIBS} ${catkin_LIBRARIES} industrial_robot_client simple_message industrial_utils)
endforeach(p)
Note the inclusion of ros_opto22_gencpp
and ros_opto22_generate_messages_cpp
.
I also have the following earlier on in the CMakeLists.txt
file:
catkin_package(
# INCLUDE_DIRS include
# LIBRARIES pac_industrial_robot_driver
CATKIN_DEPENDS ros_opto22
# DEPENDS system_lib
)
and
## Specify additional locations of header files
## Your package locations should be listed before other locations
include_directories(include ${catkin_INCLUDE_DIRS})
as well as a having ros_opto22
listed under the find_package
call.
I am very frustrated with this, not in the least because there does not seem to be a single definitive guide to solving this problem. What is the best way to go about solving this problem? I can run catkin_make
twice but that only masks the problem. I want catkin_make
to run properly first time every time even after deleting everything in the build
and devel
directories under my catkin
workspace.
Kind Regards Bart
I think what you need is
generate_messages(DEPENDENCIES ros_opto22)
I believe
generate_messages
is not for using message files from another package.True, my mistake. I meant
add_dependencies(${PROJECT_NAME} <msg_package_name>_cpp)
. We use this in order to ensure the necessary messages are compiled before the current package.