/connextdds-py

Connext DDS Python API

Primary LanguageC++OtherNOASSERTION


RTI Connext Python API

RTI Connext Python API

A full Connext DDS binding for Python
Explore the documentation »
Getting Started · Install · API Overview · API Reference · Examples


Documentation

Hello World Example

The following is the basic code to publish and subscribe to a topic defined by a simple data type. Similar code can be generated by rtiddsgen from an IDL or XML file defining your data types.

Define your types:

# hello.py

import rti.types as idl

@idl.struct
class HelloWorld:
    message: str = ""

Create a DataWriter to publish the HelloWorld Topic:

# hello_publisher.py

import time
import rti.connextdds as dds
from hello import HelloWorld

participant = dds.DomainParticipant(domain_id=0)
topic = dds.Topic(participant, 'HelloWorld Topic', HelloWorld)
writer = dds.DataWriter(participant.implicit_publisher, topic)

for i in range(10):
    writer.write(HelloWorld(message=f'Hello World! #{i}'))
    time.sleep(1)

Create a DataReader to subscribe to the HelloWorld Topic:

# hello_subscriber.py

import rti.connextdds as dds
import rti.asyncio
from hello import HelloWorld

participant = dds.DomainParticipant(domain_id=0)
topic = dds.Topic(participant, 'HelloWorld Topic', HelloWorld)
reader = dds.DataReader(participant.implicit_subscriber, topic)

async def print_data():
    async for data in reader.take_data_async():
        print(f"Received: {data}")

rti.asyncio.run(print_data())

Feature highlights

  • Python-friendly design.
  • User data classes, defined in Python or generated from IDL.
  • DynamicData and the built-in types.
  • DDS Entities in code and in XML.
  • QoS Policies in code and in XML.
  • Content Filters with the ability to change the filter.
  • Discovery topics.
  • Status updates.
  • Listeners, WaitSets and Conditions, and async reading.
  • RTI Distributed Logger and integration with Python logging module
  • Pluggable RTI components, such as Monitoring and DDS Secure.

Building and Installing

The Connext Python API is currently provided as buildable source. See Building and Installing in the Connext DDS API Reference for instructions.

A future release will provide a pre-built pip distribution.

Note that the master branch contains the sources for the latest release, which currently requires RTI Connext 7.0.0 to build. For previous releases, check out the corresponding tag. For example, the tag v0.1.5 can be built with RTI Connext 6.