Ask Your Question

catkin_make issue updating .srv and .cpp file simultaneously

asked 2019-01-28 18:32:03 -0600

stbuebel gravatar image

Think of a situation where rosnode (written in c++) is using messages generated by a .srv file. You want to add a field to the .srv file and use it in the rosnode. If you make these changes simultaneously, catkin_make will fail because it does not yet recognize the new field you have added. Is there a way to make sure that message_generation occurs before compilation of c++ files during catkin_make? Would this even avoid the issue?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2019-01-28 22:20:04 -0600

ahendrix gravatar image

The catkin message documentation describes how to do this. You can have messages in the same package as your executable, or in another package. In either case, if you're building with catkin_make, you need to tell cmake about the dependency between your C++ code and the messages.

If your messages are in the same package, you can use:

add_dependencies(your_program ${${PROJECT_NAME}_EXPORTED_TARGETS})

If you use messages from a different package, you can use:

add_dependencies(your_program ${catkin_EXPORTED_TARGETS})

If you use messages from other packages and your package, you will need both of those.

edit flag offensive delete link more


+1 and I would add: storing msg/srv/action definitions in a separate package is almost always preferable over merging them into the pkg that hosts the node(s) using them.

It makes interfacing with your nodes much easier, as a "client" now only needs to build your msg pkg.

gvdhoorn gravatar imagegvdhoorn ( 2019-01-29 03:49:54 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2019-01-28 18:32:03 -0600

Seen: 55 times

Last updated: Jan 28 '19