ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

Messages not being generated before dependent package

asked 2014-09-16 03:43:57 -0500

bjem85 gravatar image

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

edit retag flag offensive close merge delete

Comments

I think what you need is generate_messages(DEPENDENCIES ros_opto22)

fherrero gravatar image fherrero  ( 2014-09-16 04:20:53 -0500 )edit
1

I believe generate_messages is not for using message files from another package.

paulbovbel gravatar image paulbovbel  ( 2014-09-16 14:39:33 -0500 )edit

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.

fherrero gravatar image fherrero  ( 2014-09-17 02:03:13 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2014-09-16 13:09:29 -0500

William gravatar image

updated 2014-09-16 17:38:04 -0500

EDIT2: This line in your CMake code can be simplified:

add_dependencies(${p} ${catkin_EXPORTED_TARGETS} ${PROJECT_NAME}_generate_messages_cpp)

These are the only two things you would ever need to do, catkin_EXPORTED_TARGETS is never empty, which is important because add_dependencies will fail if you give it variables which do not exist.

I can't see why your code is not compiling on the first try from what you have shown us, is it where you could share these two packages with us, maybe even in private?


EDIT: I just noticed that you are actually using the right target dependency options here, let me look at it again. Sorry for the noise below.


I'm sorry you're finding this frustrating, I can sympathize. Unfortunately to resolve this, you need to have a target dependency on the message generation. We cannot do this automatically because catkin does not override the add_executable macro in CMake. Though we've tried to mention it everywhere we think it might be run into, if it is lacking from some piece of the documentation, please feel free to update it yourself or at least point someone to the deficient docs.

This extra step for depending on message generation targets is described in the ROS Tutorials:

http://wiki.ros.org/ROS/Tutorials/Wri...

It is also mentioned in the sort of cookbook for catkin CMakeLists.txt:

http://wiki.ros.org/catkin/CMakeLists...

And in the official genmsg documentation (genmsg is the package which generates messages):

http://docs.ros.org/api/genmsg/html/u...

There is also a answer on this site, which I think you've found:

http://answers.ros.org/question/11113...

Hope that helps!

edit flag offensive delete link more

Comments

I think the issue here is that the messages from package ros_opto22 are not being found by the package pac_industrial_robot_driver containing the above CMakeLists, even though the add_executable macro contains ros_opto22_generate_messages_cpp as a dependency

paulbovbel gravatar image paulbovbel  ( 2014-09-16 14:38:12 -0500 )edit

You're right, in this case he needs ${catkin_EXPORTED_TARGETS}

William gravatar image William  ( 2014-09-16 17:29:20 -0500 )edit

Oh, I guess I missed the part where he is using the EXPORTED TARGETS already, let me update my answer.

William gravatar image William  ( 2014-09-16 17:33:03 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2014-09-16 03:43:57 -0500

Seen: 2,240 times

Last updated: Sep 16 '14