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

catkin messages and node in same package

asked 2013-01-24 00:45:10 -0600

Dickvdsteen gravatar image

updated 2013-01-24 02:10:13 -0600

Hi,

While working on some ROS node we bumped into the following problem:

We got a package containing a library, messages and services, the library is using these messages and services

The header files of the services and messages are generated succesfully, however when building the library, the error occurs that the header files of the messages and services are not found.

Is this due to the fact that services and messages should not be in a same packages as library or node?

the error looks like

header.h:34:27: fatal error: ns/header.h: No such file or directory compilation terminated.

Thank in advance

edit retag flag offensive close merge delete

Comments

@KruseT, thanks for your answer, i inspected the cmake and i dont think its a typo

Dickvdsteen gravatar image Dickvdsteen  ( 2013-01-24 01:57:45 -0600 )edit

Please provide the exact error message, failing code snippets and cmake files.

dornhege gravatar image dornhege  ( 2013-01-24 02:02:21 -0600 )edit

I noticed that the messages and services are generated after the library builds, for that reason it cant be found. However i call generate_messages before add_executable

Dickvdsteen gravatar image Dickvdsteen  ( 2013-01-24 02:06:22 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted
5

answered 2013-01-24 01:17:26 -0600

KruseT gravatar image

No, messages and services may lie in the same package as other code, though it is usually a good practice to put them into separate packages, to make the definitions reusable without the other code.

See the tutorial here, where messages and code are mixed: http://www.ros.org/wiki/ROS/Tutorials/WritingPublisherSubscriber%28c%2B%2B%29

So you may have made a typo somewhere in your package or message names instead.

edit flag offensive delete link more

Comments

I was having a similar issue, the message generation part may be quite tricky and requires some care. Please also refer to this answer and its links for more tips about the problem.

Avio gravatar image Avio  ( 2018-06-12 07:23:21 -0600 )edit
4

answered 2013-01-24 02:23:20 -0600

Dickvdsteen gravatar image

updated 2013-01-24 02:29:35 -0600

Solved it!

Seems the following line was needed after calling add library

add_dependencies(lib lib_gencpp)

is this the right way to do it or not?

edit flag offensive delete link more

Comments

1

This would be a bug, at least in the documentation. Is it possible for you to post the full CMakeLists.txt, so that we may reproduce?

KruseT gravatar image KruseT  ( 2013-01-24 11:20:22 -0600 )edit

The dependency is perfectly right assuming that your project is called "lib".If you build code which depends on generated C++ headers (which is usually the case) you need to tell CMake about that dependency else it may try to build the library before generating the headers for the messages.

Dirk Thomas gravatar image Dirk Thomas  ( 2013-01-24 21:00:10 -0600 )edit
3

Note that lib is a very bad name for a project or library. Choose library names which are prefixedwith your project names, and choose meaningful project names.

KruseT gravatar image KruseT  ( 2013-01-26 00:18:51 -0600 )edit
1
KruseT gravatar image KruseT  ( 2013-01-26 00:19:25 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2013-01-24 00:45:10 -0600

Seen: 4,948 times

Last updated: Jan 24 '13