Creating msg and srv files

In this section, we are going to learn how to create msg and srv files for use in our nodes. They are files where we put a specification about the type of data to be transmitted and the values of this data. ROS will use these files to create the necessary code for us to implement the msg and srv files to be used in our nodes.

Let's start with the msg file first.

In the example used in the Building the node section, we created two nodes with a standard type message. Now we are going to learn how to create custom messages with the tools that ROS has.

First, create a new msg folder in our chapter2_tutorials package; create a new chapter2_msg1.msg file and add the following lines:

int32 A 
int32 B 
int32 C 

Now, edit ...

Get ROS Programming: Building Powerful Robots now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.