0
$\begingroup$

Rosanswers logo

In our system with >100 custom packages, there are >20 custom_msgs packages which provide for communication between packages. This question concerns correctly setting up CMakeLists.txt so the necessary messages get built before packages that depend on them.

The Defining Custom Messages tutorial shows how to declare build and exec dependencies in package.xml, and also says you need to declare a build dependency on message_generation and an exec dependency on message_runtime - this all makes sense.

The tutorial states you need to add the following to CMakeLists.txt:

find_package(message_generation)
catkin_package(CATKIN_DEPENDS message_runtime)
add_message_files(FILES your_msg_file.msg)

Is the last line correct? I understand add_message_files is needed in the package that declares the messages, but is it really also needed in packages that use the messages in the custom_msgs package? That would imply that every package that uses a custom message would need to list the messages it uses - it doesn't seem right.

Does the last line need to be deleted from the tutorial?


Originally posted by PaulBouchier on ROS Answers with karma: 300 on 2018-04-25

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

No, that is not correct.

add_message_files(..) only needs to be added to the build script of the package containing the messages.

Any consumers of the messages don't even interact with the .msg files themselves, only with the artefact generated from them (ie: source code / headers).

Does the last line need to be deleted from the tutorial?

Yes.

I believe all those lines should be removed actually. Neither message_generation, nor message_runtime are needed in packages that only depend on pkgs that provide messages.


Edit: it would appear that all of those lines were added in diff&rev1=19&rev2=20 (in 2015 !).

I'm also slightly confused by this tutorial: it's essentially the same content as Creating a ROS msg and srv. The only thing it adds is the fact that you can store messages, services and actions in a package by themselves (and it doesn't even really make that explicit). It also already links to the 'previous' tutorial.

I've always found the catkin documentation on all of this much clearer and to-the-point.


Originally posted by gvdhoorn with karma: 86574 on 2018-04-25

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by PaulBouchier on 2018-04-25:
Thanks for the confirmation @gvdhoorn. I didn't know whether to trust the catkin documentation you pointed to, but I see it has the add_dependencies(your_program ${catkin_EXPORTED_TARGETS}) that bit me so hard the other day. I think I will remove those 3 cmake lines and replace with EXPORTED_TARGETS

Comment by gvdhoorn on 2018-04-26:
I would trust the catkin documentation over every tutorial on the wiki, any day.

Note: it's not just those "3 cmake lines" that need to go, the dependencies on message_generation and message_runtime are also completely unnecessary.

Comment by PaulBouchier on 2018-04-27:
Fixed http://wiki.ros.org/ROS/Tutorials/DefiningCustomMessages Thanks for your help!

Comment by gvdhoorn on 2018-04-27:
np. Thanks for updating the tutorial.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.