O'Reilly logo

Robot Operating System Cookbook by Kumar Bipin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating ROS services

In this section, we will to learn how to create a .srv file, which will be used in our nodes. It contains a specification about the type of data to be transmitted. The ROS build system will use this file to create the necessary code to implement the srv in the ROS computational framework or network.

In the previous section, Creating ROS messages, we created two nodes with a custom type message. Now, we will learn how to create services with ROS tools.

First, create an srv folder in the chapter2_tutorials package. Furthermore, create a new chapter2_srv.srv file there and add the following lines:

int32 A  
int32 B  
---  
int32 sum 

Here, A and B are data types for a request from the client and sum is the response data type ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required