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

4 次查看(过去 30 天)
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 个评论
Jagadeesh Konakalla
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.
federico ciresola
federico ciresola 2024-7-25
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

请先登录,再进行评论。

回答(1 个)

Abhas
Abhas 2024-9-3
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

类别

Help CenterFile Exchange 中查找有关 Custom Message Support 的更多信息

产品


版本

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by