Introduction

This is the Python API for RTI® Connext® DDS.

As an experimental product, this API documentation is less comprehensive than the documentation for the other language APIs. We assume you are already familiar with Connext DDS and at least one of the other language APIs. You can check out the RTI Community for the Connext DDS Getting Started Guide, User’s Manual and the reference for the C, C++, Java, and .NET APIs.

RTI also provides RTI Connector, a limited, simpler API for Python® and JavaScript. RTI Connector for Python is production-ready and easier to use, but the Connext DDS Python API is more extensive.

This Python API is based on the Modern C++ API and is similar but has a few key differences.

The main difference is that DynamicData is the main way to manipulate data samples. The type of a DynamicData sample is defined with DynamicType. DynamicTypes can be defined programmatically or loaded from an XML definition. IDL definitions can be converted to XML.

In addition to DynamicData, you can create Topics for the built-in types StringTopicType, KeyedStringTopicType, BytesTopicType, and KeyedBytesTopicType.

There are a few other differences that make the API more pythonic. Most types define properties instead of getters and setters:

import rti.connextdds as dds
participant = dds.DomainParticipant(0)
print(participant.domain_id) # Will print zero

Many classes also provide built-in Python functions that allow iterating, converting to string, etc. Objects are automatically destroyed when their reference count reaches zero. Many can also be managed in a with block.

The following example shows how to iterate over the samples in a DataReader.

with reader.take() as samples:
    for sample in samples:
        print(sample)

The samples are loaned, and the loan is returned when the with block ends. The sample is automatically converted to a string by print.