ROS2 Toolbox error when I try to add custom service/message

Hi Guys,
I have been facing this problem for some days when I try to change the parameters of the ROS2 blocks
Error: ros.slros2.internal.block.ServiceCallBlockMask.dispatch('serviceEdit',gcb) caused by: cell array input must be a cell array of character vectors
OS version: Ubuntu 22.04
Matlab version: 23.2.0.2599560 (R2023b) Update 8

4 Comments

I noticed that this error is propagated in all ROS Toolbox because when I try to create a node from Command Windows
with this command
ros2node(["/test1"])
I obtaind the same error:
Error using ros2node/createNode
Error creating the ROS 2 node /test1.
Error in ros2node (line 163)
createNode(obj, parser.Results.name, parser.Results.id);
Caused by:
Error using matlab.internal.math.uniqueCellstrHelper
Cell array input must be a cell array of character vectors.
I have also tried reinstalling the ROS Toolbox but this hasn't resolve the problem
I discovered that this error is born when I import a custom share library created in my PC with ros2RegisterMessages
but I don't understand why this thing happens
Hi Federico,
Can you describe more about your workflow ?
I would like to know which version of MATLAB that you are using. Please note that ros2RegisterMessages works only on same OS platform and same release of MATLAB. Also let me know how you created custom message generation on other machine.
Thanks,
Jagadeesh K.
Hi Jagadeesh,
sorry for my delay in answering your comment. I know that ros2RegisterMessages only works on the same OS platform and the same release of MATLAB.
My workflow that I was trying is as follows:
  1. from the Matlab Project in a X folder, I created the custom message with the following command: ros2genmsg(<path_custom_msg_srv>,CreateShareableFile=true);
  2. on the same machine, I copied the .zip (generated by the command above) into the Y folder
  3. I ran the following command: ros2RegisterMessages(<path where is the zip file>)
after this procedure, when I open Simulink and I click on the ROS2 block, the error (that I have reported in the main message) starts to appear. I have found that If I remove the `~/.matlab` folder, the problem disappears
OS version: Ubuntu 22.04
Matlab version: 23.2.0.2599560 (R2023b) Update 8

Sign in to comment.

Answers (1)

Hi Federico,
The above error message may be caused by certain paths being present in your "PATH" variable and/or other environment variables 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.
To avoid this potential issue, inspect the value of your "PATH" environment variable by entering the following command at the MATLAB Prompt:
>> getenv('PATH')
The idea is to remove potential problematic paths from "PATH" within MATLAB. In particular, remove entries such as:
/opt/ros/foxy/bin;
/usr/local/bin;
/usr/bin;
/bin;
/usr/sbin;
/sbin;
To set a new "PATH" environment variable for your MATLAB session, use the following commands:
% minimum example of a new PATH variable
>> newPath = '/usr/local/MATLAB/R2023b/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin';
>> setenv('PATH', newPath)
>> ros2node('/test1')
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 environment variables:
>> system('printenv')
If you find "RMW_IMPLEMENTATION" in this list, you can unset it in MATLAB by using the following command:
>> setenv('RMW_IMPLEMENTATION', '')
You may refer to the following MathWorks documentation links to have a better understanding on ROS 2 and creating custom messages:
  1. https://www.mathworks.com/help/releases/R2023b/ros/ref/ros2.html
  2. https://www.mathworks.com/help/releases/R2023b/ros/ug/ros2-custom-message-support.html

Categories

Products

Release

R2023b

Asked:

on 12 Jul 2024

Answered:

on 3 Sep 2024

Community Treasure Hunt

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

Start Hunting!