How to use a service message defined in another package?

I created a service message called MySrv.srv on package my_custom_msg. This service message works fine on node inside the package my_custom_msg but when I want to use it service message on another package (test_custom_msg) a have the following error message:

 fatal error: my_custom_msg/MySrv.h: No such file or directory #include "my_custom_msg/MySrv.h"

Thanks for your help! :smiley:


To use a service message defined in another package (letโ€™s call that another_package), you need to add another_package as a dependency when creating the new package (say new_package):

catkin_create_pkg new_package roscpp [...other_dependencies] another_package

If you did not do this while creating new_package, itโ€™s better to just recreate it and include another_package as a dependency. The other way to correct this error is just too cumbersome.