A Python SDK for publishing and subscribing to topics using CycloneDDS without importing rclpy. This library provides a lightweight alternative to ROS 2 Python API while maintaining compatibility with ROS 2 message types.
- Lightweight: No ROS 2 runtime dependencies
- Compatible: Works with standard ROS 2 message types
- Easy to use: Simple publisher/subscriber API
- Extensible: Support for custom message types
- Python 3.8 or higher
- CycloneDDS 0.10.2
- Before using this package, you need to have CycloneDDS installed on your system. You can build it from source as follows:
# Install build dependencies
sudo apt update
sudo apt install -y git build-essential cmake libssl-dev
# Clone CycloneDDS source
git clone https://github.com/eclipse-cyclonedds/cyclonedds.git
cd cyclonedds
git checkout 0.10.2
# Create a build directory
mkdir build && cd build
# Build and install CycloneDDS
cmake -DCMAKE_INSTALL_PREFIX=$HOME/cyclonedds/install -DBUILD_EXAMPLES=ON ..
cmake --build .
cmake --install .- Note: You can change $HOME/cyclonedds/install to any directory you prefer.
- After installation, make sure to set the environment variables so that Python can locate the CycloneDDS libraries:
# For bash
echo 'export CYCLONEDDS_HOME=$HOME/cyclonedds/install' >> ~/.bashrc
echo 'export CMAKE_PREFIX_PATH=$CYCLONEDDS_HOME:$CMAKE_PREFIX_PATH' >> ~/.bashrc
echo 'export LD_LIBRARY_PATH=$CYCLONEDDS_HOME/lib:$LD_LIBRARY_PATH' >> ~/.bashrc
echo 'export PATH=$CYCLONEDDS_HOME/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
# For zsh
echo 'export CYCLONEDDS_HOME=$HOME/cyclonedds/install' >> ~/.zshrc
echo 'export CMAKE_PREFIX_PATH=$CYCLONEDDS_HOME:$CMAKE_PREFIX_PATH' >> ~/.zshrc
echo 'export LD_LIBRARY_PATH=$CYCLONEDDS_HOME/lib:$LD_LIBRARY_PATH' >> ~/.zshrc
echo 'export PATH=$CYCLONEDDS_HOME/bin:$PATH' >> ~/.zshrc
source ~/.zshrcFinally, install robotis_dds_python:
# Clone the repository
git clone https://github.com/robotis-git/robotis_dds_python.git
# Install the package
cd robotis_dds_python
pip install -e .Check the example/ directory for complete working examples:
trajectory_publisher.py- Publishing joint trajectory messagestrajectory_subscriber.py- Subscribing to joint trajectory messages
To add support for new ROS 2 message types:
-
Navigate to the IDL directory:
cd robotis_dds_python/robotis_dds_python/idl -
Generate Python bindings from IDL:
idlc -l py -I /opt/ros/jazzy/share/ /opt/ros/jazzy/share/{your_package}/msg/{YourMessage}.idl -
Update the generated files and
__init__.pyas needed.
Creates a DDS DataWriter for publishing messages.
Parameters:
topic_name(str): Name of the topictopic_type(Type): Message type classqos(Qos, optional): Quality of Service settings
Returns: DataWriter instance
Creates a DDS DataReader for subscribing to messages.
Parameters:
topic_name(str): Name of the topictopic_type(Type): Message type classqos(Qos, optional): Quality of Service settings
Returns: DataReader instance
We welcome contributions! Please see our Contributing Guidelines for details.
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.