
Chapter 4. Implementation 52
by the "switch sender/receiver"-services and topics. However, if the state was changed by
direct manipulation via the "add/remove/change"-services, no message is published.
Database changed: The "database changed"-publisher publishes a message, every time a
database entry is changed by the "add/remove/change"-services to enable automatic syn-
chronization of other device manager instances. The published message contains the action
that was performed and the full receiver or sender structure. The database changed sub-
scriber listens for those messages and applies them to the database. Messages from the
same node are filtered out to prevent and endless loop.
Switch receiver/sender: These two topics can switch receivers on and off, similar to the "switch
receiver/sender"-services. The difference is the missing response message, therefore requests
via topics are performed faster. Nevertheless, an indirect acknowledgement can be obtained
by subscribing to the "device changed"- topic.
It is possible to start multiple instances of the device manager, as it provides services and topics for
synchronization, such as "set/get device list" and "database changed". However, the node cannot
start the synchronization by itself, it must be started externally. It is not recommended to run
multiple instances simultaneously, because there are no major advantages and the synchronization
can be problematic. Instead, the synchronization functions were designed to enable local copies
of the database.
device manager
rosnode
main
request
device
list
ros
device manager
thread 1 thread 2
XML
database
Figure 4.14.: The internal structure of the device manager node.
The internal structure of the database (figure 4.14) is composed of two main parts, the device
manager object and the rosnode class. The main function initialises both objects and starts the
Qt event system to enable the signal and slot mechanism. Similar to the gateway driver, the
device manager is divided in two threads, to separate the ROS from the rest of the program. The
communication between the two parts is mainly done via signals/slots but also via direct method
calls. Direct methods calls are not thread safe, therefore the calling-thread has to wait until the
Comentarios a estos manuales