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

How can I use my own .msg?

asked 2013-10-28 21:57:23 -0500

Mr Hillgren gravatar image

I've created my own .msg and can perform "rosmsg show MyMessage". The question is how can I use it in my C++ code?

I've seen this link that is exactly the same question (http://answers.ros.org/question/31779/how-to-use-a-message-that-i-made/) however I don't really get it all. =(

Why is there a Header header in the .msg file? Is it "standard" to have in a msg?

Where Is the MyMessage.h file saved? How do I create It? I can only find the .msg file. Since I can't find it I cant Include it in the cpp file naturally.

It also states that I should add the line <depend package="my_custom_msg_package"/> in the manifest. When I do this i get an error saying: - The manifest must not contain the following tags: depend

How can I solve this?

Many Thanks, Patrik

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2013-10-28 23:05:23 -0500

Thomas gravatar image

1/ manifest.xml is now package.xml. Your should look like this one: https://github.com/ros/catkin_tutorials/blob/master/create_package_pubsub/catkin_ws/src/beginner_tutorials/package.xml

As the syntax changed the link you mention is now obsolete.

See the tutorial example here: https://github.com/ros/catkin_tutorials/tree/master/create_package_pubsub/catkin_ws/src/beginner_tutorials http://wiki.ros.org/ROS/Tutorials/WritingPublisherSubscriber(c%2B%2B)

2/ A header is used to associate a timestamp and/or a frame with your message, this is very useful but not mandatory.

3/ Once you run cmake in your package, a directory called msg_gen will be created containing the headers and required source files. You don't have to really know where this directory is located. Just include #include <PACKAGE/MESSAGE> where PACKAGE is you package name and MESSAGE your message filename without the extension (mymsg.msg becomes mymsg).

edit flag offensive delete link more

Comments

Thanks for the quick response Thomas! I still have some trouble though, I explained it in the following question: http://answers.ros.org/question/95541/error-when-trying-to-use-my-own-msg/

Mr Hillgren gravatar image Mr Hillgren  ( 2013-10-29 03:01:19 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2013-10-28 21:57:23 -0500

Seen: 542 times

Last updated: Oct 28 '13