How to configure CycloneDDS in MATLAB to communicate with WSL/Docker/VM?

8 views (last 30 days)
When using CycloneDDS as the ROS 2 middleware (RMW), MATLAB fails to discover nodes running on any of the virtualized environments in the same host, such as WSL, Docker, or Virtual Machine.

Accepted Answer

Abhishek
Abhishek on 30 Oct 2025 at 6:06
CycloneDDS may not be able to evaluate if communication is possible across multiple network interfaces, unless you explicitly configure them. To configure desired network interfaces, follow the steps below:
  1. Open a MATLAB® session.
  2. Create a file named “cyclonedds.xml”.
  3. Copy and paste the following XML content into the file.
<CycloneDDS xmlns="https://cdds.io/config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://cdds.io/config https://raw.githubusercontent.com/eclipse-cyclonedds/cyclonedds/master/etc/cyclonedds.xsd">
<Domain>
<General>
<Interfaces>
<NetworkInterface name="vEthernet (WSL (Hyper-V firewall))"/>
</Interfaces>
<DontRoute>true</DontRoute>
</General>
</Domain>
</CycloneDDS>
  • Set the value of <NetworkInterface name=""/> in the code to define each network interface.For example, if your interface is vEthernet (WSL (Hyper-V firewall)), add <NetworkInterface name="vEthernet (WSL (Hyper-V firewall))"/>.
  • Set the General/DontRoute tag to prevent automatic routing that can interrupt communication when multiple interfaces are configured.
4. In MATLAB command window, run the following command to set the 'CYCLONEDDS_URI’ environment variable to point to the “cyclonedds.xml“ file.
setenv("CYCLONEDDS_URI", "<path/to/cyclonedds.xml>")
5. After you set the environment variable, run the following command in the MATLAB command window to clear existing resources and then list the nodes available in network:
clear all;
ros2 node list

More Answers (0)

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!