Ask Your Question
1

Must Compile Message and Service Several Times To Work

asked 2016-07-12 12:52:27 -0500

Pototo gravatar image

Folks (sorry for the upper case in advance...they just to make sure people understand those are examples of my code),

What is the proper way to create a CMakeList.txt file that includes messages and services? Every time I create a new group of messages or services and include them in my code, for EXAMPLE,

"my_package_msgs/MessageOrService.h"

it always takes a few "catkin_makes" for my system to recognize the library. Here is my CMakeList file:

cmake_minimum_required(VERSION 2.8.3)
project(message_package_msgs)
find_package(catkin REQUIRED COMPONENTS
  roscpp
  rospy
  std_msgs
  message_generation
  geometry_msgs
  sensor_msgs
)
add_message_files(
  DIRECTORY
    msg
  FILES
    Message_EXAMPLE.msg
)
add_service_files(
  DIRECTORY
    srv
  FILES
    Service_EXAMPLE.srv
)
generate_messages(
  DEPENDENCIES
  std_msgs
  geometry_msgs
  sensor_msgs
)
catkin_package(
  CATKIN_DEPENDS roscpp rospy std_msgs message_runtime geometry_msgs sensor_msgs
include_directories(
  ${catkin_INCLUDE_DIRS}
)

And my package.xml with the build/run only:

  <buildtool_depend>catkin</buildtool_depend>
  <build_depend>roscpp</build_depend>
  <build_depend>rospy</build_depend>
  <build_depend>std_msgs</build_depend>
  <build_depend>message_generation</build_depend>
  <build_depend>geometry_msgs</build_depend>
  <build_depend>sensor_msgs</build_depend>
  <run_depend>roscpp</run_depend>
  <run_depend>rospy</run_depend>
  <run_depend>std_msgs</run_depend>
  <run_depend>sensor_msgs</run_depend>
  <run_depend>message_runtime</run_depend>
  <run_depend>geometry_msgs</run_depend>

What am I missing?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2016-07-12 13:11:55 -0500

Dirk Thomas gravatar image

You need to add dependencies to your library / executable targets on the target which generates the code for the messages and services. Please see the last two code snippets in the documentation: http://docs.ros.org/api/catkin/html/h...

edit flag offensive delete link more

Comments

groovay...

Pototo gravatar imagePototo ( 2016-07-12 14:25:59 -0500 )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

1 follower

Stats

Asked: 2016-07-12 12:52:27 -0500

Seen: 30 times

Last updated: Jul 12 '16