Recording Topics from RTI Connext DDS Micro applications with RTI Recording Service

This solution describes steps to configure RTI Recording Service to record topics published by RTI Connext DDS Micro for post data-analysis and debugging.

RTI Connext DDS Micro provides a small-footprint modular messaging solution for resource-limited devices. It supports a subset of the standard and extended APIs and QoSs of Connext DDS. 

One feature not supported currently by RTI Connext DDS Micro is the ability to send TypeCode information. TypeCodes are used by many of RTI’s tools to determine and display Type information. By default, the Record tool of RTI Recording Service expects TypeCodes for topics it receives. This may seem to be a problem when trying to use the Record tool with RTI Connext DDS Micro applications. However, this is not a problem because the Record tool also supports configuration of type information via an XML configuration file. 

This solution uses RTI Connext DDS Micro and the “HelloWorld_dpde” example provided with RTI Connext DDS Micro: ~/rti_connext_micro.2.2.3/example/C/HelloWorld_dpde. The operating system is Ubuntu 12.04, with SQLite 3.7.9 2011-11-01.

Step 1: Generate or build an XML type-definition file

If you are using an IDL (Interface Definition Language) file to define your data types, you need to convert the IDL file into an XML type-definition file by using the rtiddsgen tool.

For example, execute rtiddsgen with the option –convertToXml and pass in your IDL file:

$ rtiddsgen -convertToXml HelloWorld.idl
Running rtiddsgen version 5.0.0, please wait ...
Done
$ ls -l
total 72
drwxrwxr-x  2 rticonnext rticonnext  4096 Jan 10 00:29 .
drwxrwxr-x 10 rticonnext rticonnext  4096 Jan 10 00:27 ..
-rw-rw-r--  1 rticonnext rticonnext  5850 Jan 10 00:29 HelloWorld.cxx
-rw-rw-r--  1 rticonnext rticonnext  2819 Jan 10 00:29 HelloWorld.h
-rw-rw-r--  1 rticonnext rticonnext    45 Jan 10 00:28 HelloWorld.idl
-rw-rw-r--  1 rticonnext rticonnext 23636 Jan 10 00:29 HelloWorldPlugin.cxx
-rw-rw-r--  1 rticonnext rticonnext  8675 Jan 10 00:29 HelloWorldPlugin.h
-rw-rw-r--  1 rticonnext rticonnext  2739 Jan 10 00:29 HelloWorldSupport.cxx
-rw-rw-r--  1 rticonnext rticonnext  1701 Jan 10 00:29 HelloWorldSupport.h
-rw-rw-r--  1 rticonnext rticonnext   374 Jan 10 00:29 HelloWorld.xml 

Here you can see the difference between a type definition in IDL and XML. For more details, see the XML-Based Application Creation Getting Started Guide.

struct HelloWorld {
    string<128> msg;
};
<?xml version="1.0" encoding="UTF-8"?>
<types>
    <struct name="HelloWorld">
        <member name="msg" stringMaxLength="128" type="string"/>
    </struct>
</types>

For simplicity and to follow the rest of the steps, rename the generated XML type definition file HelloWorld.xml to HelloWorld_type.xml

Caution: If you do not want to overwrite the existing DDS type-support files for your IDL, copy the IDL file to a separate directory, then run rtiddsgen. Note that rtiddsgen will also regenerate type-support files; however out of all the generated files, you only need the XML type-definition file.

Note: Use the version of rtiddsgen provided with regular RTI Connext DDS, since the code generator provided with RTI Connext DDS Micro does not include the -convertToXml option. Otherwise you will get the following error message,

ERROR com.rti.ndds.nddsgen.Main Invalid option –convertToXml

Step 2: Configure the XML configuration file for RTI Recording Service

Add the Type definition (from HelloWorld_type.xml) to the RTI Recording Service configuration file (e.g., HelloWorld_rec_cfg.xml) under the domain_type_config tag (see Section 4.9 "Domain Type Configuration" in the RTI Recording Service User’s Manual for a complete description). 

For example, review HelloWorld_rec_cfg.xml:

<dds xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:noNamespaceSchemaLocation="../../resource/schema/rti_record.xsd">
 <!-- This simple configuration records all topics from domain ID 0 -->
 <recorder name="example">
<!-- Specify configuration name for the Record tool -->
    <recorder_database>
         <database_name> simple_config.dat </database_name>
       <!-- Specify where to store the recorded data. -->
    </recorder_database>
<domain_type_config>
  <domain_group>
    <element>    
      <domain_filter>
        <element>domain0</element> 
      </domain_filter>
      <type_config> 
        <xml>
          <file_group>
            <element>
              <file_name>
                <element>HelloWorld_type.xml</element>
                <!-- Specify the XML type definition file name. -->  
             </file_name>
             <type>
               <element>
                 <type_name>HelloWorld</type_name>
                 <!--Specify the type name you would like to record -->
               </element>  
             </type>
           </element>
         </file_group>
         <path>
           <element>.</element>
           <!--Specify path for the Recording Service config file (e.g., HelloWorld_rec_cfg.xml) and 
           type definition file (e.g.,HelloWorld_type.xml). Here, "." represents the local directory -->
         </path>
       </xml>
     </type_config>
    </element>
  </domain_group>
 </domain_type_config>
    <!-- Create a DDS DomainParticipant in domain 0 with default QoS -->
<domain name="domain0">
  <domain_id>0</domain_id>
    <deserialize_mode>RTIDDS_DESERIALIZEMODE_ALWAYS</deserialize_mode>
    <!-- Note: The Record tool records RTI Connext DDS Micro topics in either serialized or deserialized mode. 
      But deserialized mode is available only when type-information is provided in XML. 
      RTI Recording Service can run in either serialized or deserialized mode, but it’s with deserialized mode 
      that one can see the deserialized fields in SQLite in this example.-->
</domain>
    <!-- Create a TopicGroup. A TopicGroup is a collection of Topics whose names match the topic_expr.
     The field_expr specifies which fields in the Topics to record. Note that a TopicGroup is not bound to a 
     particular domain yet. In this example, the TopicGroup All means all fields in all Topics -->
 <topic_group name="All">
   <topics>
     <topic_expr> * </topic_expr>
   </topics>
     <field_expr> * </field_expr>
 </topic_group>
    <!-- Create a RecordGroup. A RecordGroup controls which TopicGroups are recorded for a set of domains.
        Each recorded Topic is stored in a table with the format "record_group.domain.Topic" In this example, 
        we want to record data from topics in TopicGroup "All" from "domain0." -->
  <record_group name="RecordAll">
     <!-- specify which domains to record from -->
    <domain_ref>
      <element> domain0 </element>
    </domain_ref>
     <!-- specify which topics to record -->
      <topic_ref>
        <element>All</element>
      </topic_ref>
    </record_group>
  </recorder>
</dds>  

Step 3: Launch the Record tool from a command line

Run the Record tool. For example,

$ rtirecord -cfgFile HelloWorld_rec_cfg.xml -cfgName example
RTI Recorder started

This will create a database and store your published samples in it. Later, you can inspect the database contents using sqlite3 (see Chapter 9 in the RTI Recording Service User’s Manual). You can also use the Replay tool to playback the recorded samples. You can find more information about the Replay tool in Chapters 6 and 7 in the RTI Recording Service User’s Manual

To stop the Record tool, press “Control + C”.

$ rtirecord -cfgFile HelloWorld_rec_cfg.xml -cfgName example
RTI Recorder started
^CStopping RTI Recorder...
RTI Recorder stopped&nbsp;

To list which configurations are available in your configuration file, run the following command,  

$ rtirecord -listCfgs -cfgFile HelloWorld_rec_cfg.xml
RTI Recording Service - Record
Version 5.0.0.rev00

The following configurations are available:
 - default (/home/ashish/RTI/RTI_Recording_Service_5.0.0/resource/xml/RTI_RECORDING_SERVICE.xml)
   Record all topics and fields in domain 0. Remote administration with distributed logger is enabled on domain 0.
 - defaultNoAutoStart (/home/ashish/RTI/RTI_Recording_Service_5.0.0/resource/xml/RTI_RECORDING_SERVICE.xml)
   Record all topics and fields in domain 0, but don't start recording right away (wait for remote start). 
   Enable remote administration in domain 0. Distributed logger is also enabled with filter level set to warning.
 - defaultNoAdmin (/home/ashish/RTI/RTI_Recording_Service_5.0.0/resource/xml/RTI_RECORDING_SERVICE.xml)
   Record all topics and all fields in domain 0. Remote administration is disabled.
 - example (HelloWorld_rec_cfg.xml)            

Step 4: Start the  RTI Connext DDS Micro Publisher and Subscriber applications

For a Topic and data recording, you only need to run the Publisher application. You will see "Matched a subscriber" if the Record tool is already running and subscribed to the published topic type (defined in and passed thru HelloWorld_type.xml to the Record tool in an RTI Recording Service configuration XML file). 

$ ./objs/i86Linux2.6gcc4.4.5/HelloWorld_publisher
Hello World! (0)
Hello World! (1)
Matched a subscriber
Hello World! (3)      

Running the Subscriber application is optional. But it is good to see if the Subscriber is getting data from the Publisher in real-time. Alternatively, you can follow Step 5 in parallel to view the data with <1 sec delay. 

$ ./objs/i86Linux2.6gcc4.4.5/HelloWorld_subscriber
Matched a publisher
Running for 24 hours, press Ctrl-C to exit

Sample received 
        msg: Hello World! (0)       

NOTE: Make sure you are publishing data using the same domain ID (e.g. domain ID 0) you have configured in the RTI Recording Service XML configuration file (e.g., HelloWorld_rec_cfg.xml). 

Step 5: Verify the recorded data

Open the dataBase “simple_config.dat_0_0” using sqlite3 and list the available tables (sqlite> .tables). The data published for the topic "Example HelloWorld" is recorded in the table “Example HelloWorld$RecordAll$domain0”.

To form the table name, the Record tool concatenates the Topic Name, the Record Group, and the Domain name; for example: <Example HelloWorld><RecordAll><domain0>, which gives us Example HelloWorld$RecordAll$domain0. Further related details can be found in the RTI Recording Service Getting Started.  

$ sqlite3 simple_config.dat_0_0 
SQLite version 3.7.9 2011-11-01 00:52:41 
Enter ".help" for instructions 
Enter SQL statements terminated with a ";" 
sqlite> .tables 
DCPSParticipant  Example HelloWorld$RecordAll$domain0 
DCPSPublication  RTILog 
DCPSSubscription RTIVersion 
sqlite> select from "Example HelloWorld$RecordAll$domain0; 
1382438856898131|0|0|2|1|1|1382438856|898066996|0|0|0|0|-950573486|1087397860|-557797922|2563|0|0|0|0|0|1382438856898131|000002|000001|1|Hello World! (1) 1382438857898667|0|0|2|2|1|1382438857|898586997|0|0|0|0|-950573486|1087397860|-557797922|2563|0|0|0|0|0|1382438857898867|000003|000002|1|Hello World! (2) 1382438858899436|0|0|2|2|1|1382438858|899352998|0|0|0|0|-950573486|1087397860|-557797922|2563|0|0|0|0|0|1382438858899436|000004|000003|1|Hello world! (3) 
...

Alternatively, to view the data using a GUI tool, you can use SQLite Studio (http://sqlitestudio.pl/). 

References

1. RTI Core Libraries and Utilities User's Manual

2. RTI Recording Service User’s Manual

3. RTI Recording Service Getting Started

Programming Language: