4. Examples

Several examples are provided to demonstrate the Python DCPS features.

The examples can be found in the following directory:

  • $OSPL_HOME/tools/python/examples

4.1. Example Files

4.1.1. File Types

The examples directory contains files of different types. The runnable python script files reference the xml and idl files.

File Type Description
py A program file or script written in Python
xml An XML file that contains one or more Quality of Service (QoS) profiles for DDS entities.
idl An interface description language file used to define topic(s).

4.1.2. Examples

Example Description
qos_example.py An example that demonstrates how to specify QoS settings using Python DCPS APIs. Also shows usage of a waitset.
example1.py Dynamic generation of Python Topic classes using IDL file and name. Uses a topic with a sequence.
example2.py Dynamic generation of Python Topic classes using Enumeration and nested modules.
example4.py Demonstrate finding DDS topics over-the-wire. Find topics registered by other processes, and read and write samples to those topics.

4.2. Running Examples

To run an example python script:

  1. Setup OSPL environment variables.

    Linux

    • source release.com
    Windows
    • release.bat
  2. Run an example python script

    • > python3 example1.py

Table Of Contents

Previous topic

3. Installation

Next topic

5. Python API for Vortex DDS

This Page