MATLAB Stall During Execution When Using FastDDS (Earlier FastRTPS) as ROS 2 Middleware

5 views (last 30 days)
When using FastDDS (earlier FastRTPS) as the ROS 2 middleware (RMW) on Windows, MATLAB stops responding. In this state, the MATLAB Command Window no longer executes commands, and the session does not respond to user input.

Accepted Answer

Abhishek
Abhishek on 11 Nov 2025 at 6:02
Edited: Abhishek on 11 Nov 2025 at 6:03
This issue occurs because FastDDS stores shared memory files in the local file system to manage inter-process communication. Normally, these files are cleaned up automatically when the application closes properly. However, if MATLAB or Simulink closes unexpectedly, the cleanup routines are not executed, leaving stale shared memory files on the system. These files can prevent new FastDDS processes from initializing communication channels, causing MATLAB to become unresponsive when you use ROS 2 features.
To resolve this issue, use one of the following workarounds:
Clean up shared memory files manually
1. In MATLAB Command Window, run the following command to clear resources:
clear all;
2. Navigate to the path provided below:
C:\ProgramData\eprosima\fastrtps_interprocess
3. Delete all contents inside this folder.
4. In MATLAB Command Window, run the follow command to clear resources to avoid conflicts:
clear all;
Disable shared memory (transport)
1. In MATLAB Command Window, run the following command to clear resources:clear all;
2. Create a file named “fastdds.xml”.
3. Copy and paste the following XML content into the file.
<?xml version="1.0" encoding="UTF-8" ?>
<!-- Configuration file for FAST-DDS to disable the SHM (Shared memory) as builtin transport and use custom UDP transport -->
<profiles xmlns="http://www.eprosima.com/XMLSchemas/fastRTPS_Profiles" >
<transport_descriptors>
<transport_descriptor>
<transport_id>UdpTransport</transport_id>
<type>UDPv4</type>
</transport_descriptor>
</transport_descriptors>
<participant profile_name="udp_transport_profile" is_default_profile="true">
<rtps>
<userTransports>
<transport_id>UdpTransport</transport_id>
</userTransports>
<useBuiltinTransports>false</useBuiltinTransports>
</rtps>
</participant>
</profiles>
4. Set an environment variable to point to the “fastdds.xml” file by running this command in MATLAB Command Window:
setenv("FASTRTPS_DEFAULT_PROFILES_FILE", "<path/to/fastdds.xml>")
Please note: This step is required every time you restart MATLAB.
5. In MATLAB Command Window, run the follow command to clear resources to avoid conflicts:
clear all;

More Answers (0)

Community Treasure Hunt

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

Start Hunting!