Generating the Fast RTPS type definition

Updated: April 19, 2023
Using an IDL file, we can create the C++ classes needed by the Fast RTPS provider for exchanging data samples based on the corresponding data type. In this example, we use an existing IDL file named DataBuffer.idl that has these contents:
struct DataBuffer {
    string          name;
    sequence<octet> data;
};
Note: Some IDL definitions limit the capabilities of the data type within the PiPS framework. For instance, with the structure shown above, no field is marked as a key (with @Key in front of it). This means neither point-to-point nor client-server communication is possible, because individual subscribers can't know if an update is directed to them. If you're using an existing IDL file, you must keep this in mind.
We generate the type definition from the IDL type by using the fastrtpsgen tool (which you can obtain from eProsima). This is a Java tool that can be run on Windows or Linux development hosts. We use the following command:
$ fastrtpsgen -d ${WORKSPACE} -replace DataBuffer.idl
openjdk version "9-internal"
OpenJDK Runtime Environment (build 9-internal+0-2016-04-14-195246.buildd.src)
OpenJDK 64-Bit Server VM (build 9-internal+0-2016-04-14-195246.buildd.src, mixed mode)
Loading templates...
Processing the file DataBuffer.idl...
Generating Type definition files...
Generating TopicDataTypes files...
$
This command generates the following C++ files in the workspace directory: