Creating a custom interface for a topic
When creating a publisher or subscriber for a topic, you know that you have to use a name and an interface.
It’s quite easy to publish or subscribe to an existing topic: you’ll find the name and interface using the ros2
command line, and use that in your code.
Now, if you want to start a publisher or subscriber for a new topic, you will need to choose a name and interface by yourself:
- Name: No problem—it’s just a chain of characters
- Interface: You have two choices—using an existing interface that works with your topic or creating a new one
Let’s try to apply the ROS 2 philosophy of not reinventing the wheel. When you create a new topic, check if there is any existing interface that can match your needs. If so, then use it; don’t recreate it.
First, you’ll learn where you can find existing interfaces. Then, you’ll learn how to create a new one.
Note
...