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

messages from subfolders

asked 2015-06-29 03:31:25 -0600

Reiner gravatar image

Hi, I'm writing a Package, that has to contain multiple message definitions. In order to manage the amount I divided the messages in subfolders:

/msg/test
/msg/test2

I've already checked, this works(CMakeLists.txt):

add_message_files( FILES
test/test_msg.msg
)

However: I still have to list every .msg in add_message_files. Is there a way to add whole folders? (Every .msg in a particular subfolder of /msg?

cheers

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2015-06-29 04:16:35 -0600

gvdhoorn gravatar image

updated 2015-06-29 04:19:41 -0600

Looking at the docs for genmsg (where add_message_files(..) is coming from) and at the code (specifically: here) it would seem that if you only pass the DIRECTORY argument to add_message_files(..) it will search for .msg files in that directory. So that would remove the need to list all files explicitly.

I'm not sure whether it does that recursively though (most likely not, as GLOB_RECURSE is not used), so that would require calling add_message_files(DIRECTORY ..) multiple times (once for each subdir of $pkg_dir/msg in your specific case) and I don't know whether that is supported.

Note btw that this 'auto-discovery of msg files' uses GLOB-ing, which is sort-of frowned upon in the CMake community (see Best way to specify sourcefiles in CMake on stackoverflow fi).


As an aside: making things explicit in software (engineering) is actually a good thing, as it avoids depending on implicit assumptions in your components (ie: "message my_message.msg will be there, as it is in the directory I have catkin search for messages"). If you GLOB, a missing msg file will cause an error at a much later time (while compiling any sources depending on the message) than if you explicitly listed it (existence of .msg files is checked at configuration time here) and it will also be more easily understood (ie: message file not found vs some/path/to/my_source.cpp:LINE:CHAR: fatal error: my_msgs/my_msg.h: No such file or directory which can also be caused by missing or misstated dependencies).

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-06-29 03:31:25 -0600

Seen: 1,638 times

Last updated: Jun 29 '15