A full Connext DDS binding for Python
Explore the documentation »
Getting Started
·
Install
·
API Overview
·
API Reference
·
Examples
-
The Connext Getting Started Guide helps you install the software and run your first RTI Connext Python application while learning general concepts of Connext.
-
The Connext Python API Reference provides additional examples, an overview of the API and the API reference.
-
Additional Connext DDS documentation, including the User's Manual is available at the Connext Community Portal.
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())
- 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.
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.