
Chapter 2. Related Work/Fundamentals 25
Services are for communication between two nodes, whereas topics are for many-to-many com-
munication. Nodes can host a service server under a string name and a client can send a request
and wait for the response. Services are composed of a name and a request and response message.
They are synchronous and therefore do not abstract sender and receiver.
Node A Node B
event
handler
Node A Node B
request
handler
response
wait
(a) Asynchronous event (b) Synchronous call
Figure 2.15.: Differences between a topic (a) and a service (b). Adopted image from [28]
Messages are strictly typed data structures. They can be composed of primitive data types, such
as int, float, boolean, etc. as well of other messages and arbitrarily deep nested arrays of messages.
They are specified in text files, which are generated into headers for all supported programming
languages during compilation. An example of two different messages is given in figure 2.16. To
ensure, that both sender and receiver have the same message files and not different versions, each
message contains a MD5 checksum, which has to match for a successful transmission.
bool sender
int id
string name
myMessage data_struct
bool sender
int id
---
myMessage data_struct
device_has_been_seen.msg get_device_data.srv
Request
Response
Figure 2.16.: Two example messages: One topic message (left) and one service message (right).
Request and response are saved in the same file, but are separated by “- - -“. MyMes-
sage is a custom message from another .msg file.
The ROS-Master is a central declaration and registration service, which keeps track of all nodes,
topics and services and makes it possible for nodes to find each other and exchange data. The
Master uses XML-RPC, providing all information encapsulated in XML files. When starting a new
node or creating a new topic or service, registration data is send to the Master and saved in a
database. Clients can request this information by sending a service or topic name and they will
get a list of subscribers or the address of the service server. The Master is not involved in the
data flow; it just exchanges information, allowing the node to establish peer-to-peer connections.
Image of ros network generated with rxgraph.
Kommentare zu diesen Handbüchern