MATLAB Answers

Why am I unable to create a ROS2 node on Windows 10?

23 views (last 30 days)
I am trying to follow the "Get Started with ROS 2" tutorial below:
However, I get an error when running the first command of the tutorial:
>> test1 = ros2node("/test1")
Error using ros2node/createNode (line 319)
​​​​​​Error creating the ROS 2 node /test1.
Error in ros2node (line 119)

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 22 Sep 2021 at 4:00
Edited: MathWorks Support Team on 22 Sep 2021 at 14:55
The above error message may be caused by certain paths being present in your PATH variable, and/or other environment variables set on your system. For example, if a native ROS 2 installation is present, there might be a library conflict between it and MATLAB's ROS 2 libraries.
PATH variable:
As a first step, inspect the value of your PATH environment variable by entering the following command at the MATLAB Prompt:
>> getenv('PATH')
The idea is to remove potentially problematic paths from PATH within MATLAB. In particular, remove entries such as:
C:\Program Files\rti_connext_dds-6.0.0\lib\x64Win64VS2015;
C:\Program Files\Docker\Docker;
C:\Program Files\Docker\Docker\resources\bin;
To set a new PATH environment variable for your MATLAB session, use the following comands:
% minimum example of a new PATH variable
>> newpath = 'C:\Program Files\MATLAB\R2020b\bin\win64;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\PROGRA~1\MATLAB\R2020b\bin;C:\Users\myUser\AppData\Local\Microsoft\WindowsApps;';
>> setenv('PATH', newPath)
>> ros2node('/test1')
Other environment variables:
If shortening PATH within MATLAB does not help, look out for other environment variables that may interfere with ROS 2 libraries, such as RMW_IMPLEMENTATION.
Enter the following command at the MATLAB Prompt to get a list of all set enviroment variables:
>> system('set')
If you find RMW_IMPLEMENTATION in this list, you can unset it in MATLAB by using the following command:
>> setenv('RMW_IMPLEMENTATION','')

More Answers (0)


No tags entered yet.




Community Treasure Hunt

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

Start Hunting!