Trouble with Catkin: Compiling node and generating messages in same package.
Hi Guys,
I am currently catkinizing the ublox driver found here: https://github.com/tu-darmstadt-ros-pkg/ublox
The node "ublox_msgs" builds a library and generates a number of messages at the same time. The library that is built in the package depends on the generated message header files that is created during compile time.
The problem is that it tries to compile the library without waiting for all the message headers to all be generated. The result is a error that it can not find one of the generated header files. For example:
../../ublox_msgs/include/ublox_msgs/ublox_msgs.h:41:35: fatal error: ublox_msgs/NavTIMEGPS.h: No such file or directory
I can see the messages being generated, and if I run "cakin_make" multiple times, it will generate all the headers and no longer error out. But I would like it to generate the message headers and then compile the library, so a error does not happen. I know the library and the messages should probably be in separate packages, but I just wanted to get it working in its current state.
I tried following what was referenced in this post, but it did not seem to work either: http://answers.ros.org/question/53265/catkin-messages-and-node-in-same-package/
Here is my package.xml file:
<?xml version="1.0"?>
<package>
<name>ublox_msgs</name>
<version>0.0.0</version>
<description>
</description>
<maintainer email="jane.doe@example.com">Jane Doe</maintainer>
<license>TODO</license>
<buildtool_depend>catkin</buildtool_depend>
<build_depend>message_generation</build_depend>
<build_depend>roscpp</build_depend>
<build_depend>ublox_serialization</build_depend>
<run_depend>message_runtime</run_depend>
<run_depend>roscpp</run_depend>
<run_depend>ublox_serialization</run_depend>
<export>
</export>
</package>
Here is my CMakeLists.txt file:
cmake_minimum_required(VERSION 2.8.3)
project(ublox_msgs)
find_package(catkin REQUIRED COMPONENTS genmsg ublox_serialization roscpp)
## Generate messages in the 'msg' folder
add_message_files(
DIRECTORY msg
FILES
AidALM.msg
AidEPH.msg
AidHUI.msg
CfgANT.msg
CfgCFG.msg
CfgMSG.msg
CfgNAV5.msg
CfgPRT.msg
CfgRATE.msg
CfgSBAS.msg
NavCLOCK.msg
NavDGPS.msg
NavDGPS_SV.msg
NavDOP.msg
NavPOSECEF.msg
NavPOSLLH.msg
NavSBAS.msg
NavSBAS_SV.msg
NavSOL.msg
NavSTATUS.msg
NavSVINFO.msg
NavSVINFO_SV.msg
NavTIMEGPS.msg
NavTIMEUTC.msg
NavVELECEF.msg
NavVELNED.msg
RxmALM.msg
RxmEPH.msg
RxmRAW.msg
RxmRAW_SV.msg
RxmSFRB.msg
RxmSVSI.msg
RxmSVSI_SV.msg
)
## Generate added messages and services with any dependencies listed here
generate_messages()
catkin_package(
INCLUDE_DIRS include
LIBRARIES ${PROJECT_NAME}
# CATKIN_DEPENDS message_runtime
# DEPENDS ublox_msgs
)
include_directories(include
${catkin_INCLUDE_DIRS}
)
## Declare a cpp library
add_library(ublox_msgs
src/ublox_msgs.cpp
)
## Add cmake target dependencies of the executable/library
## as an example, message headers may need to be generated before nodes
add_dependencies(${PROJECT_NAME} ${PROJECT_NAME}_gencpp)
## Specify libraries to link a library or executable target against
target_link_libraries(${PROJECT_NAME} ${catkin_LIBRARIES})
I tried to follow the tutorials as much as possible: https://github.com/ros/catkin_tutorials/blob/master/create_package_pubsub/catkin_ws/src/beginner_tutorials/CMakeLists.txt
Does anyone see a issue in these files? Or maybe there is still a bug in Catkin?
Thank you for your help.
Update
So it looks like it works with catkin_make -j1
but NOT with just catkin_make
. So it seems to be possibly a bug with running multiple jobs at once ...
Can you post the entire output of
catkin_make -j1
on a previously unbuilt workspace? Your package looks ok to me, I don't see why you would be getting the out of order build bug (I can pretty confidently confirm that this is that bug since you can resolve it by running multiple times).Look at update above.
Why is
CATKIN_DEPENDS message_runtime
commented out? What happens when you use it?I do not see a difference if I use it or not, at least during compile time.
I think it is needed for other catkin packages that use your messages.
Alright I will keep that in then.