What is a ROS Message?

You may already have heard about ROS topics and services using ROS messages. So… What is a ROS message ?

This post is a part of the What is ROS? series.

ROS messages in topics and services

If you haven’t read the explanations on ROS topics and ROS services yet, please read them now and come back here after you finished.

With topics, you have seen that all nodes publishing or subscribing to a topic must have the same data type which is given by the topic.

With services, you have seen that the client must send a message respecting a certain data type, and the server must respond with another message respecting another data type.

A topic is defined by 2 things : a name, which is the interface to reach, and a message definition, which is the data structure of the information you send.


You are learning ROS?

Check out ROS For Beginners and learn ROS step by step.


A service is also defined by 2 things : a name, which is the interface to reach, and a service definition. This service definition contains one message definition for the request, and one message definition for the response.

Well, you can see topics and services as the communication layer tools, and messages as the actual content you send.

Yay, another real life example

Let’s just make another very simple real life analogy. When you send a mail, the transport company will transport your letter. The content of this letter is the analogy of a ROS message.

What is a ROS message? 1/2

As simple as that.

When you send a letter and you wait for a response, then the first letter contains a Request message, and the letter that you receive back contains a Response message.

The combination of the two message definitions is the service definition.

What is a ROS message? 2/2

As you can see, message and service definitions are quite useful. Without them, you would have nothing to send over a topic or a service.

How are ROS messages created ?

Now, technically speaking, how is it possible that you can use those messages directly in your code? In this post I won’t show you how to actually create a ROS message, but instead I’ll explain what is the creation process. Writing the code will be for another day.

So, first you create a message definition. When you use the catkin_make command line, the message will be parsed by the build system. And then, a source code will be generated for this message, in any ROS supported language: C++, Python etc.

That’s why you can, for example, directly include the message header in your C++ code. Because the build system generated this header file.

What is a ROS message? 3/3

ROS messages will be an important part of your robotics application. They will state what kind of information all your nodes need to produce in order to communicate together.

Did you find this tutorial useful?

Do you want to learn how to program with ROS?

If yes, this course is for you:

ROS For Beginners - A Step By Step Course

>> ROS For Beginners - A Step By Step Course <<