Up until now, we have worked with standard type messages (e.g. strings). Let’s see how we can create our own custom messages in ROS.
Open a new terminal window, and type the following command to go to the noetic_basics_part_1 package:
Create a msg folder inside that package.
Move inside that folder.
Create a new .msg file
Add the following lines.
Click Save and close out the window.
In the code above, we have written three message descriptions. Specifically, we have declared three signed 32-bit integers. The syntax for a message description is:
Now, go back to the package.
Open the package.xml file.
Uncomment these two lines by deleting the arrows on each side:
Click Save, and then close the editor.
Now open CMakeList.txt.
Add message_generation inside the find_package(catkin REQUIRED COMPONENTS…) scope.
Also uncomment the add_message_files (…) lines and add the name of the message you just created.
Now uncomment the generate_messages(…) lines.
Since we made all these changes, we now need to build the package.
Check to see if everything built properly by typing the following command:
rosmsg show noetic_basics_part_1/noetic_basics_part_1_msg
Here is what you should see:
You can also see the custom message you just created by typing this command:
The message types are listed in alphabetic order by package name.
You can also just see a list of message types for just the noetic_basics_part_1 package.
rosmsg package noetic_basics_part_1