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

8 ビュー (過去 30 日間)
Abhishek
Abhishek 2025 年 10 月 30 日 6:04
回答済み: Abhishek 2025 年 10 月 30 日 6:06
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.

採用された回答

Abhishek
Abhishek 2025 年 10 月 30 日 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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeROS 2 Network Access in Simulink についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by