I’m doing Exercise 6.2 for the ROS Python course, where we learn how to create custom service messages. The instructions say to add “message_generation” under “find_package()” in “CMakeLists.txt”. But why do we not have to add “message_runtime” under “catkin_package()”? The description for this function states:
All of the packages stated here must be in the package.xml file as <exec_depend>.
And in “package.xml”, we can see that “<exec_depend>message_runtime</exec_depend>” is included.
In fact, the same is true for ‘std_msgs’: it does not appear under “catkin_package()” in “CMakeLists.txt”, but is still present as “<exec_depend>std_msgs</exec_depend>” in “package.xml”.
message_generation is a build dependency. So to have your ROS package use your custom messages (msg / srv / action), this message_generation is required under find_package() in CMakeLists.txt and as build_depend in package.xml.
But, message_runtime is not a package, it is a execution / run-time dependency. So to have your ROS package execute / make use of the created custom messages during execution / run-time. You must add message_runtime under build_export_depend and exec_depend only in your package.xml.
And, it is better to add std_msgs in catkin_package() of CMakeLists.txt in the line that starts with CATKIN_DEPENDS ... along with other dependencies (like actionlib_msgs if you are using actions).