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

Custom messages in different package - Is tutorial correct?

asked 2018-04-25 11:46:37 -0500

PaulBouchier gravatar image

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?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
2

answered 2018-04-25 12:54:49 -0500

gvdhoorn gravatar image

updated 2018-04-25 13:02:28 -0500

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.

edit flag offensive delete link more

Comments

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

PaulBouchier gravatar image PaulBouchier  ( 2018-04-25 18:30:28 -0500 )edit

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.

gvdhoorn gravatar image gvdhoorn  ( 2018-04-26 01:59:37 -0500 )edit

Fixed http://wiki.ros.org/ROS/Tutorials/Def... Thanks for your help!

PaulBouchier gravatar image PaulBouchier  ( 2018-04-27 11:39:06 -0500 )edit

np. Thanks for updating the tutorial.

gvdhoorn gravatar image gvdhoorn  ( 2018-04-27 11:40:24 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2018-04-25 11:46:37 -0500

Seen: 2,354 times

Last updated: Apr 25 '18