This week we are thrilled to announce RTI Labs, a free program that provides our customers with early access to new technology we are developing for the Industrial IoT. We are calling them experimental projects. Customers who take advantage of RTI Labs have the opportunity to leverage next-generation technology and influence our product roadmap by providing feedback on the experimental features. It’s a win-win situation!
We are launching the program with three new experimental projects, the first being RTI (R) Connector for Connext DDS. If you’ve already downloaded RTI Connext 5.3.0 and started the RTI Launcher, you will see a few new icons in the ‘Lab’ tab. One of these icons is for Connector.
But What is RTI Connector?
There are many use cases for RTI Connector. Some of the use cases from early adopters include:
Testing: oftentimes when you’re developing a complex distributed system, some of the components may not be ready; In this case, Connector is used to emulate the behavior of a DDS component that will be completed later or by another group. This allows you to test components in isolation –which is valuable either when you are working on a distributed team, or when you don’t want to wait until every component is built before testing.
Prototyping: In software development it is often required to validate an idea before all of the details are available. Using a scripting languate like python and a simplified DDS API, make it very simple and quick to develop a demo or a proof of concept – using an order of magnitude less code!
User interfaces: developing simple UIs (visualizing or sending DDS data using buttons and simple triggers) becomes really easy when the RTI Connector is paired with UI technology available for python, such as python QT.
Integration: Python, and other scripting languages, comes with a humongous ecosystem. At the time this blog was written, PyPl had 112,439 packages. If you are trying to integrate something, there is a good chance that there is a python package that will help you and now you can use Connector to talk DDS!
Your use case here: let us know if you are using RTI Connector in a different way on our forum!
Try It Out!
In this blog post we assume you have some familiarity with python. RTI Connector works both with python 3 and < 3. It is supported on all the major enterprise systems and also on boards like the Raspberry Pi. You can see the list of available platforms here. If you need support for something else do not hesitate to ask on the forum. To install RTI Connector for Connext DDS in python you can use the package available on PyPI:
pip install rticonnextdds_connector
Another way is to just clone the repository:
git clone https://github.com/rticommunity/rticonnextdds-connector.git
In the repository you will also find some examples to get you started:
- simple/writer.js: shows how to create a writer, set an instance and publish samples.
- simple/reader.js: demonstrates how to get a reader, get samples and access the content of them.
- simple/read_and_write.py: shows how to write a sample for each one received after inverting two fields.
- mixed/: these examples are updated periodically and contain different examples on how to access the length of a sequence, how to use wait() and more.
Let’s see what the API looks like. If you’d like more detailed information, you can view the README in our GitHub repository.
The first thing to do is to import the RTI Connector library:
import rticonnextdds_connector as rti
After you have a reference to RTI Connector, you can call the API to create a new Connector:
connector = rti.Connector("MyParticipantLibrary::Zero","./ShapeExample.xml");
The first string is the name of the configuration you want to use, while the second string is the XML file containing the XML-Base App Creation configuration. You can see an example of that file here.
Once the connector is created, you can access all the Data Writers using the getOutput API:
output = connector.getOutput("MyPublisher::MySquareWriter")
or you can access the Data Readers in the same way:
input = connector.getInput("MySubscriber::MySquareReader");
Both APIs get one string as a parameter representing the name of the entity as it was defined in the XML file.
Once you have a reference to the Data Writer (output in our example), you can set the fields of the associated instance. You can do that passing a dictionary:
or by setting each field individually:
On the Data Reader side (input in this example), you can call read or take:
Then, you can iterate through the samples received:
numOfSamples = input.samples.getLength();
for j in range (1, numOfSamples+1):
x = input.samples.getNumber(j, "x");
y = input.samples.getNumber(j, "y");
A sample can be accessed in two ways. As a dictionary:
sample = input.samples.getDictionary(j);
or field by field:
y = input.samples.getNumber(j, "y");
size = input.samples.getNumber(j, "shapesize");
Remember to protect the access to your Connector if you use multithreading libraries. You can find an example on how to do this here.
All of This Power Comes with Boundaries
RTI Connector is great and it can solve a lot of challenges! But, as everything, it is not perfect for everything. It has a limited set of APIs: some things that you can do with Connext DDS Pro cannot be done with the RTI Connector. It only works with Dynamic Data and not with compiled types. To make it simple to use and to port we made some assumptions having specific use cases in mind, it may not solve your specific use case or it may not be the most efficient way to solve it, but we probably have another tool or service for your specific issue: just ask us!
You might be wondering what this technology will cost … it’s free!! You can just get it and experiment with it. All we ask is that you give us your feedback and suggestions. This feedback will be considered while we’re prioritizing updates and features to include in our future product releases – so you could help influence our roadmap!
This blog is just an introduction to our RTI Connector for python. If you are interested, the best way to learn is to try it out. Let us know if you have any doubts or questions on the RTI Community Forum, and we will be happy to help you out! If you like it and you have suggestions or ideas for improvements, feel free to contact us; we are looking for feedback while deciding what’s next...