Using RSB to Receive and Publish Data » History » Version 3

J. Wienke, 06/30/2011 03:33 PM

1 1 J. Wienke
h1. Using RSB to Receive and Publish Data
2 1 J. Wienke
3 1 J. Wienke
This wiki page describes the first steps to integrate an existing component with RSB. We assume that this component requires data for processing, which is already available in RSB and wants to provide processed data for other components via RSB.
4 2 J. Wienke
5 2 J. Wienke
h2. Receiving Data
6 2 J. Wienke
7 3 J. Wienke
To receive data in RSB made available by other components you need to know the [[Glossary#scope|Scope]] under which the data are available, e.g. @/sensors/cam/left@ for video images of the left camera of a robot with stereo vision. Furthermore, you need to know how the data is represented. As data is transmitted over the network and should be available in multiple programming languages, this includes two aspects:
8 2 J. Wienke
9 2 J. Wienke
# which class/type represent the data in your programming language, e.g. @std::string@ is used for textual content in C++
10 2 J. Wienke
# how is the data transmitted over the network, i.e. how is your programming language class serialized into bytes and deserialized back to a class
11 2 J. Wienke
12 2 J. Wienke
While knowledge about the first item is essential to use RSB, the second point is only important slightly advanced use cases, where programming language classes will be used, which are not directly known to the RSB framework. Support for primary data types like strings is already built in (see [[Types]]).
13 2 J. Wienke
14 1 J. Wienke
In RSB terms the programming language representation is called [[Glossary#data-type|data type]] and the serialized representation is called [[Glossary#wire-schema|wire schema]].
15 3 J. Wienke
16 3 J. Wienke
So, assuming a simple component that works with a processing loop (see pseudo-code below), what are the required steps to receive data from RSB?
17 3 J. Wienke
<pre>
18 3 J. Wienke
<code class="cpp">
19 3 J. Wienke
while (true) {
20 3 J. Wienke
21 3 J. Wienke
    // receive new data
22 3 J. Wienke
23 3 J. Wienke
    // do some heavy processing with the data to generate new results
24 3 J. Wienke
25 3 J. Wienke
    // inform the world about the newly generated data
26 3 J. Wienke
27 3 J. Wienke
}
28 3 J. Wienke
</code>
29 3 J. Wienke
</pre>