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

Using msgs from the same package

asked 2015-05-14 14:55:48 -0500

RosFan19 gravatar image

Hi,

I'm trying to use msgs from the current package. So usually it's like this, when I'm using a different package:

#include package_name/msg_name
pub_ = nh_.advertise<project_name::msg_name>("topic", 1);

But I'm trying to use the msg I created in the same project package Let's say my package name is first_package and msg is first_msg, but doing so:

#include first_package/first_msg
pub_ = nh_.advertise<first_project::first_msg>("topic", 1);

Doesnt seem to work. Well why should I import something that is already in my package. What is the correct syntax here?

edit retag flag offensive close merge delete

Comments

It is always a good idea to include verbatim any error messages or warnings that you receive. Just stating that it doesn't work is making it really difficult for us to help you.

gvdhoorn gravatar image gvdhoorn  ( 2015-05-15 01:37:48 -0500 )edit

Also: for almost all msg pkgs, the package_name is used as the namespace for the messages, so in your example package_name and project_name should probably be identical?

gvdhoorn gravatar image gvdhoorn  ( 2015-05-15 01:38:50 -0500 )edit

I know, it's not a big help, but it may be worthwhile to move your message definition to a separate package (see ros best practices). Also, try simply copying the tutorial (see tutorials understanding topics) and analysing the differences, helps me usually.

Reiner gravatar image Reiner  ( 2015-06-02 03:14:52 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-05-14 16:43:03 -0500

anonymous user

Anonymous

Hi,

Is your #include in the following form with the triangular braces and *.h?

#include <first_package/first_msg.h>

Are you getting an error in the compiling process? If so, what type of error?

Another issue might be the generate/add messages components of your CMakeLists.txt

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-05-14 14:55:48 -0500

Seen: 223 times

Last updated: May 14 '15