Creating a custom service interface
In Chapter 5, when we created the ROS 2 application with the number_publisher
and number_counter
nodes, we used an existing interface for the number
topic. Since we wanted to publish an integer number, the example_interfaces/msg/Int64
interface seemed to be exactly what we needed. At this point, you know that you must avoid using the example_interfaces
package for real applications, but for a first test, that wasn’t a problem.
We’re going to continue working on this application and add more functionalities so that we can practice with services. Here, we will focus on the number_counter
node. For now now, in this node, every time we receive a message from the number
topic, we’ll add this number to a counter and print the counter.
What we want to do is allow the number_counter
node to reset the counter to a given number when we ask it to. For that, we will add a service server inside the node. Then, any other node can send...