Defining Custom Messages

From Lofaro Lab Wiki
Jump to: navigation, search

The majority of the information needed to create a message can be found by viewing the earlier tutorial on msg:

Creating a ROS msg and srv

Some other notes:

  • The msg file should be added to the msg folder of the package you are creating it for.
  • Messages are put into a namespace which matches the name of the package.

For C++, an example would be

#include <std_msgs/String.h>
std_msgs::String msg;

For Python:

from std_msgs.msg import String
msg = String()
  • If you are using a msg from one package (package 1) in another (new package 2), don't forget these changes to your package.xml file of package 2: