Error with addpath in MATLAB Runtime when Using ROS 2 Custom Messages in a Deployed Application
3 views (last 30 days)
Show older comments
I am developing a MATLAB application that uses ROS 2 and requires custom messages. The code works fine in the MATLAB development environment, but when I compile it using MATLAB Compiler and try to run the deployed application, I encounter the following error:
Error using matlabpath
Modifying the search path is not supported by MATLAB Compiler. Remove functions that modify the search path from your MATLAB code. To make files visible to your deployed application, add the parent folder to your MATLAB session.
Error in path (line 109)
Error in addpath>doPathAddition (line 126)
Error in addpath (line 90)
Error in ros.internal.getEmptyMessage>getCachedMap (line 53)
Error in ros.internal.getEmptyMessage (line 33)
Error in ros.internal.utilities.findMsgDepends (line 17)
Error in ros.internal.utilities.getPathOfDependentDlls (line 16)
Error in ros2publisher/createPublisher (line 460)
Error in ros2publisher (line 267)
How can I properly include the custom ROS 2 messages in a deployed MATLAB application without triggering this error? Is there a way to avoid the dynamic modification of the path or preload the required dependencies before deployment?
Any guidance on handling custom ROS 2 messages in MATLAB Runtime would be greatly appreciated.
0 Comments
Accepted Answer
Githin George
on 5 Dec 2024
Edited: Githin George
on 5 Dec 2024
I am assuming that you are using MATLAB Compiler to create a ROS 2 application which registers custom ROS 2 messages during execution.
Assuming that you do not want any dynamic dependencies at runtime, you can use the options provided by the “mcc” command to add more files to the deployable archive. Please refer to the documentation below to do so:
Even if the above solution helps resolve the issue with “addpath”, I doubt whether you will be able to deploy your application successfully, since MATLAB Compiler does not provide support for “ros2genmsg” function as stated in the limitations section of the documentation below:
I would suggest that you look at the look at the following workflow to deploy ROS 2 nodes to your target machine by generating C++ code with MATLAB Coder.
The following MATLAB Answers post may also help you resolving some of the issues regarding custom messages that you may end up facing with this workflow
0 Comments
More Answers (0)
See Also
Categories
Find more on Custom Message Support in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!