ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

An introduction tutorial to services and messages is available here

In the Beginner Tutorial you have linked, under

  1. Writing a Service Node

it is clearly mentioned that you should have already completed the introduction to services and messages tutorial!

An introduction tutorial to services and messages is available here

In the Beginner Tutorial you have linked, under

  1. Writing a Service Node

it is clearly mentioned that you should have already completed the introduction to services and messages tutorial!

Edit following @gvdhoom 's feedback.

The service interfaces are defined in .srv files in a package, which are then compiled into .h files by the ROS client libraries. Each service interface consists of two components. Request and Response. For an example, the AddTwoInts interface is defined as

int64 a
int64 b
---
int64 sum

The request component is defined above --- in the .srv file and the response component below it. This is why the service server accesses the two integers passed by the client as req.a and req.b. The client, once the response is received into the variable res, will access the sum as res.sum.

You can define your own service interface with your own field names and your own data types. The data types you can use to define custom message and service interfaces are described here. How to define custom service interfaces is explained here.

For an example, I here is a custom service interface I have defined.

string command

uint8[] ids
string addr_name
int32 value
---
bool comm_result