2.2.11. Step 11: Graphical Data Publishing


This feature is experimental and under active development. As such, there is no guarantee of correct behavior for this feature and the feature is not yet complete. Upcoming versions could add to or replace the functionality explained in this section.

Admin Console allows you to publish data for a selected topic. To do this, Admin Console must have discovered the topic and have information about the topic’s Type.

Admin Console uses Python code to fill in the content of the samples and, once the code to fill in the samples is ready, you can choose how to execute that code. The code can be used to publish the sample, cache it in memory, or execute the code periodically caching and/or publishing the resulting samples.

In this step of the tutorial, we’ll see how to use Admin Console to publish samples for a specific topic. Preparing Admin Console to publish

Before we can publish samples, we must prepare our system.

If you try to publish samples with Admin Console before following these steps, Admin Console will report a problem. It will indicate that it cannot publish samples and that the publication is disabled. You can see this in the Admin Console preferences panel, in the Python section.

For example, the following image shows an invalid configuration. The Python version is not valid and the Connext Python DDS API is not found. The Publication Status is set to disabled due to the wrong configuration:

Python preferences in erroneous state

As seen in the above image, Admin Console is not ready to publish data. This happens because Admin Console relies on the Connext Python API to publish a specific topic. To be able to publish a topic, Admin Console checks that the system meets these requirements:

  1. Python is installed. The currently supported versions are: 3.6, 3.7, 3.8, 3.9, 3.10.

  2. The Connext Python API binding is installed and available for Admin Console to use.


For Windows users: The Python distribution available in the Windows Store has a specific folder configuration that may result in the OS denying access to the Python executable and the Python Shared Libraries from Admin Console.

Due to this, it is not recommended to use this distribution of Python. To use Graphical Data Publishing in Admin Console, we recommend downloading Python directly from the official Python page: https://www.python.org/

If you are using the Connext Professional version, Admin Console includes the Python API wheels, precompiled and ready to be installed. You can find the files in the Connext installation folder: rti_connext_dds-<version>/resource/app/app_support/admin_console/<architecture>/python_api/python_wheels


The Python API wheels are not included in the Connext evaluation (LM) version. To obtain the wheels and use them in the LM version, you must clone the Python API repository and compile it manually. The Python API repository is: https://github.com/rticommunity/connextdds-py.

For instructions on how to build and install the Python API, see https://community.rti.com/static/documentation/connext-dds/7.1.0/doc/api/connext_dds/api_python/building.html.

To install the Python API and be able to use it in Admin Console, you only need to execute the following command:

pip install <file_arch>.whl

Please note that you must select the wheel file that corresponds with your Python version and OS. The name of the file indicates the Python version with which it is compatible. For example, the file rti.connext-7.1.0-cp39-cp39-macosx_10_9_x86_64.whl is a wheel file specific for Python 3.9. This can be seen in the filename, which contains cp39. The wheels that are distributed with each host are specific for that kind of host. The Python Wheel folder will only contain wheels specific for the host operating system.


The Connext Python API wheels require pip 20 or greater. If you have a lower version, please upgrade pip. For example:

pip3 install --upgrade pip

Choose the file according to the architecture and Python version that you are running on your machine. Then everything should be ready for Admin Console to publish samples. In the Preferences panel, you will see that the Connext Python API has been found and the Publications status is enabled.

Python preferences in a correct state


Admin Console will automatically detect the Python version installed and use a valid configuration according to that Python version and the Python API wheels that are installed. If Admin Console cannot find the Python version automatically, this information can be provided through the environment variables.

The PATH environment variable should include the location of the Python executable. The library search path environment variable should include the location of the Python library files, as follows:

  1. On Windows systems, python<version>.dll can be set using the PATH environment variable.

  2. On Linux systems, libpython<version>.so can be set using the LD_LIBRARY_PATH environment variable.

  3. On macOS systems, libpython<version>.dylib can be set using the DYLD_LIBRARY_PATH environment variable. Please note that the DYLD_LIBRARY_PATH value can be removed by the operating system according to the Apple Runtime Protections. Please see: https://developer.apple.com/library/archive/documentation/Security/Conceptual/System_Integrity_Protection_Guide/RuntimeProtections/RuntimeProtections.html for more information.

If Admin Console is not able to find the python library files and this configuration is not correct, Admin Console will not be configured correctly and the Graphical Data Publishing feature will be disabled.

The values for the Python Executable file and the Python Shared libraries can be changed in this preference dialog. This will cause the values found in the environment variables to be overwritten. Additionally, changing those values will cause Admin Console to be restarted or it will not be able to use the provided values. Configuring the scenario

First, let’s configure the testing scenario using Admin Console and Shapes Demo:

  1. Use Launcher to start an instance of Shapes Demo. Make sure that this instance of Shapes Demo doesn’t use Partitions or Domain Tags. To do this, click on the Configuration button and make sure that the Domain Tag is empty and there are no partitions. Then create a Square subscriber with the default configuration.

    Shapes Demo default configuration
  2. Open Admin Console and, using auto-join, wait until the instance of Shapes Demo is discovered and the topic Square is visible in the DDS Logical View. You will see a warning because the topic is currently read-only.

    Admin Console DDS Logical view with one Square topic and a read-only warning Creating an Admin Console publication

The process to create a Publication in Admin Console for a specific topic is very similar to creating a subscription. It can be done in two different ways:

  • Using the context menu in the DDS Logical View: Right click on the topic Square in the DDS Logical View and select the option Publish… (experimental). Clicking on this option will open the dialog to create a publication in Admin Console.

    DDS Logical View context menu to create a publication
  • Using the Publication View: Select the topic Square in the DDS Logical View and open the Publication Tab. This will open the Publication View; it will be empty until you click the Publish… (experimental) button. Then you will see the dialog to create the publication.

    Publication View before creating the publication

Both of the above options will open the Create Publication dialog. This dialog allows you to create a publication and configure its QoS. For now, we will use the default configuration, so you don’t need to change settings in this dialog.

Create publication dialog

Press OK in this dialog and the Publication will be created. Now Admin Console is able to publish samples. Publication View

When the Admin Console publisher is created, the Publication View will open. This view contains all the elements required to publish samples of our topic.

Admin Console Publication View

The Publication View has two areas: a code editing area on the left, and tabs with detailed information on the right.

The code editing area contains all the elements required to edit the code that will fill in the samples. In our example, we can see that the code editing area has been loaded with example code that fills in a sample for the Square topic.

Code editing area

Let’s look at what actions you can take in the Publication View:

  • The Load button loadButton loads a previously stored script.

  • The Save button saveButton saves the current script in a Python file.

  • The Reset Code button resetCodeButton resets the code in the code editing area with the provided example code.

  • The Help button helpButton opens documentation about Graphical Data Publishing.

  • The Code Execution Preferences button codeExecPrefButton controls how the code will be run.

  • The Execute Code button executeCodeButton runs the code, based on the Preferences. The label before codeExecPrefButton shows how the code will be executed.

The detailed information area on the right will show the results of the execution in two tabs: the Samples Queue and the Python Log.

  • The Samples Queue tab shows information about the samples that are cached. At this point in the tutorial, this will be empty because we haven’t cached any samples yet.

    Empty sample queue tab

    Let’s take a brief look at what you can do with samples stored in the Samples Queue:

    • Edit a selected sample editSampleButton.

    • Remove selected samples removeSamplesButton.

    • Clear the Samples Queue clearQueueButton.

    • Load a previously stored Python script loadButton.

    • Save the current Python script saveButton.

    We will use these buttons later in this tutorial.


    The Python file is stored in text format, so you can edit it outside of Admin Console to change the sample values, add new samples, or remove samples.

  • The Python Log tab shows the Python output from the executed code. The log has two categories, normal console output and errors.

    Empty python output log Publishing samples

Now that we know the elements in the Publication View, it’s time to publish some samples. We will publish a Yellow square. Start by modifying the code in the code editing area as follows:

sample.color = "Yellow"
sample.x = 30
sample.y = 30
sample.shapesize = 20
sample.fillKind = ShapeFillKind.SOLID_FILL
sample.angle = 45.0

As you can see, we are filling in the sample with the color Yellow, at the X-Y position (30, 30), with a size of 20 units, solid fill, and an angle of 45º.

The label in front of codeExecPrefButton shows how the code will be executed. Since we didn’t modify the preferences, we will get the default behavior, which is to publish the sample and cache its value, executing the code only once.

Press executeCodeButton at the bottom of the text area. Look in the Samples Queue tab and you’ll see our first sample.

Result of executiong the code once

You will also see the published sample in Shapes Demo.

Shapes demo received sample

Before we publish more samples, change the position and rotation. Admin Console stores the value of the last published sample, which simplifies this task.

Press codeExecPrefButton. A new dialog will open, where you can choose how to publish the samples.

Check the “Execute code periodically” checkbox and fill in the period with a 500 ms delay between executions.

Publish and cache sample with 500 ms delay

After doing this, notice that the label before codeExecPrefButton has changed. Now it shows that the code will be executed with a 500 ms period.

Publish and cache sample with 500 ms delay

Let’s change the code to alter the position and angle of the square. In the code editing area, add the following code:

sample.x += 5
sample.y += 10
sample.angle += 5

if (sample.x > 250):
    sample.x = 0
if (sample.y > 250):
    sample.y = 0

The above code will cause each sample to move 5 units on the X axis and 10 units on the Y axis. At the same time, we will rotate the square 5 degrees, and, if it exceeds the limit of 250 units on either axis, the square will move back to the 0 position on that axis.

Run this code by pressing executeCodeButton at the bottom of the text area. Notice the following:

  • The Execute Code button executeCodeButton has been replaced with a Stop Execution button stopExecutionButton.

  • The Sample Queue is being filled with all the published samples.

  • The code editing area has been disabled. This code cannot be modified while it is being used to publish samples.

  • Shapes Demo is receiving all the samples.

Publication View publishing samples periodically

In Shapes Demo, you can see the last published samples. The number of samples that appear is based on the depth of the History QoS (by default, 6).

Shapes demo with received samples

After some samples have been published, press stopExecutionButton.

Shapes Demo will stop receiving samples, the Samples Queue won’t show new samples being added, and the code editing area will be editable again.

Now let’s change the Code Execution Preferences so that samples will not be cached in the Samples Queue:

Press codeExecPrefButton to open the Code Execution Preferences dialog. Uncheck “Cache sample after each execution”.

Code executor preferences without caching samples

We also want to print the samples’ X and Y values in our Python Log. Change the code to add a print statement, like the last line here:

sample.x += 5
sample.y += 10
sample.angle += 5

if (sample.x > 250):
    sample.x = 0
if (sample.y > 250):
    sample.y = 0

print (f'X= {sample.x}, Y= {sample.y}')

Then run the code by pressing executeCodeButton. As a result, Shapes Demo will still receive the published samples, but those samples will not be added to the Sample Queue, because we configured it to not cache samples.

Select the Python Log tab. You should see messages with X and Y positions in the “Console output” section.

Code execution with python log messages

Press stopExecutionButton to stop execution.

Reset the code in the code editor area by pressing resetCodeButton. This will remove our code changes and return to the provided example code that fills in a generic sample for the specific topic.

Reset code in code text area Working with the Sample Queue

Now that our Sample Queue has some samples, we will make some changes to the already existing samples.

Select the third sample in the Sample Queue. Press the Edit Sample button editSampleButton. This button is only enabled when one sample is selected.

Edit sample queue selection

This will open a code editor dialog that allows you to modify the selected sample. This code can be used to create the selected sample. To modify the sample, let’s change the color to “Red” and the size to 50 and press Apply.

Sample_3 = ShapeTypeExtended()
Sample_3.color = "Red"
Sample_3.x = 40
Sample_3.y = 50
Sample_3.shapesize = 50
Sample_3.fillKind = ShapeFillKind.SOLID_FILL
Sample_3.angle = 55.0

It should look like this:

Edit sample dialog

We can see that Sample 3 is updated in the Sample Queue. Now it has the color Red and its shapesize is 50.

Edit sample dialog

Next we want to publish all the samples that are in the Samples Queue. Set the Publication period to 200 ms. Press executeCodeButton at the bottom of the dialog to publish all the samples in the queue.

In Shapes Demo, you will see a red square with a size of 50.

Shapes Demo with red square

Now let’s edit one sample and publish only that sample, not the full Sample Queue. Select Sample 2 and press editSampleButton. Change its color to “Orange”, then press the executeCodeButton that is next to the sample. This will publish only Sample 2.

Sample queue only orange square

You will see the orange square in Shapes Demo.

Shapes demo with orange square

Now save all the samples to a Python script by pressing saveButton. In the resulting dialog, enter a file name and location. This will open a dialog where you to fill with the file name and location.

Save the script. We will load it later.

After that, clean up the sample queue by pressing clearQueueButton. A new dialog will open, showing you how many samples will be removed. Press Yes to confirm the removal.

Confirm removal of sample queue

Now our Sample Queue is empty. Press loadButton on top of the Sample Queue and select the stored file. This will reload the Sample Queue.

Finally, let’s change the maximum size of the Publication View. Press codeExecPrefButton, then change the Sample Queue size to 5.

If there are more than 5 samples in the Sample Queue, a new section will appear in this dialog, asking how you want to trim the Sample Queue. Choose “Trim the first elements of the queue” and press Apply.

Confirm removal of sample queue

After doing this, the Sample Queue size will be reduced to 5 items, and if new samples are published, those samples will replace existing samples.

Confirm removal of sample queue Stopping the publication

Admin Console will keep the information about the current Publication configuration until the Publication is closed. If we close the Square view, the Publication will remain active, but if the code is being executed periodically, it will be stopped when the view is closed.

Additionally, the configuration is stored, so the next time we reopen the Publication View, it will contain the same samples and code that we had when the view was closed.

To completely close the Publication View, press the Stop Publishing button on top of the Publication View or stop it using the context menu in the DDS Logical View.

Ways to stop the publication in Admin Console

When you stop the Publication View, the publication will be completely destroyed, removing both the entities created by Admin Console and the stored information. When the Publication is stopped and the Publisher is regenerated, the code in the code editor area and the samples in the Sample Queue will not be restored.

To finish this tutorial, press the Stop Publishing button.