Ask Your Question
0

custom message generation causes problems when compiling my code

asked 2014-10-24 10:37:27 -0600

Marcus gravatar image

Hello guys, I have tried to find if someone has the same problem in the forum but it does not seem that way.

Basically I want to create a custom ros message to publish something from my own package. So far so good.

I have created a msg folder in my package and added a file ("sla_tracker.msg") containing:

float64 s
float64 sd
string status

I have followed the tutorial given here everything worked without a problem, except to the last point:

changing:

# generate_messages(
#   DEPENDENCIES
#   std_msgs
# )

to:

generate_messages(
  DEPENDENCIES
  std_msgs
)

as soon as I do this when using "catkin_make" it is like the header file of my cpp file does not exist which then obviously leads to a lot of missing declarations an other includes which were not done. I hope I could explain my problem properly.

Maybe the custom message must be created in a separate catkin package and can not be created in the package in which I need the custom message?

I am using ros hydro on ubuntu 12.04

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2014-10-24 11:11:44 -0600

joq gravatar image

You can define messages in the same package with other programs.

If you do, message generation targets need to be built before any programs that depend on them. Every target that directly or indirectly uses one of your message headers must declare an explicit dependency:

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

See the catkin howto for more details.

edit flag offensive delete link more

Comments

Thanks Jack, decided to follow the good programming practice of ros and have a separate pkg for the msgs. Could you maybe add a short explanation for what "your_program" and "PROJECT_NAME" are resembling to? I guess "PROJECT_NAME" is what can be found in the 2. line of the CMakeLists file. Thx again

Marcus gravatar imageMarcus ( 2014-10-27 05:29:34 -0600 )edit

Yes, ${PROJECT_NAME} is the package name from the project() CMake command.

joq gravatar imagejoq ( 2014-10-29 10:56:18 -0600 )edit

Moving the messages to a separate package is generally a good idea. But, you still need to declare dependencies where they are used:

add_dependencies(your_program ${catkin_EXPORTED_TARGETS})

Substitute your actual CMake target name for your_program.

joq gravatar imagejoq ( 2014-10-29 10:58:45 -0600 )edit

Yup, I have done as you suggested and it looks much cleaner now. Thanks again

Marcus gravatar imageMarcus ( 2014-10-31 12:27:58 -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

1 follower

Stats

Asked: 2014-10-24 10:37:27 -0600

Seen: 93 times

Last updated: Oct 24 '14