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

Revision history [back]

click to hide/show revision 1
initial version

As pointed out in tutorial CreatingMsgAndSrv for message/service generation with catkin you need to:

  • Add to package.xml:

    <build_depend>message_generation</build_depend>
    <run_depend>message_runtime</run_depend>

  • Add message_generation in CMakeLists.txt as REQUIRED catkin component (like any package, e. g. roscpp):

    find_package( catkin REQUIRED COMPONENTS roscpp message_generation )

  • uncomment add_message_files in CMakelists.txt and add your msg files with messages to be generated:

    add_message_files( FILES my_message.msg )

  • uncomment add_service_files in CMakelists.txt and add your srv files with services to be generated:

    add_message_files( FILES beginner_tutorials.srv )

  • uncomment generate_messages in CMakeLists.txt with packages containing msgs depending on:

    generate_messages( DEPENDENCIES std_msgs )

  • in CMakeLists.txt add ${PROJECT_NAME}_generate_messages_cpp as dependency of your target that required the message to be generated before being compiled (in C++, I am not sure if is also necessary for python)

    add_executable( foo_exec src/foo.cpp)
    target_link_libraries( foo_exec ${catkin_LIBRARIES} )
    add_dependencies( foo_exec ${PROJECT_NAME}_generate_messages_cpp )

As pointed out in tutorial CreatingMsgAndSrv for message/service generation with catkin you need to:

  • Add to package.xml:

    <build_depend>message_generation</build_depend>
    <run_depend>message_runtime</run_depend>

  • Add message_generation in CMakeLists.txt as REQUIRED catkin component (like any package, e. g. roscpp):

    find_package( catkin REQUIRED COMPONENTS roscpp message_generation )

  • uncomment add_message_files in CMakelists.txt and add your msg files with messages to be generated:

    add_message_files( FILES my_message.msg )

  • uncomment add_service_files in CMakelists.txt and add your srv files with services to be generated:

    add_message_files( add_service_files( FILES beginner_tutorials.srv )

  • uncomment generate_messages in CMakeLists.txt with packages containing msgs depending on:

    generate_messages( DEPENDENCIES std_msgs )

  • in CMakeLists.txt add ${PROJECT_NAME}_generate_messages_cpp as dependency of your target that required the message to be generated before being compiled (in C++, I am not sure if is also necessary for python)

    add_executable( foo_exec src/foo.cpp)
    target_link_libraries( foo_exec ${catkin_LIBRARIES} )
    add_dependencies( foo_exec ${PROJECT_NAME}_generate_messages_cpp )