MATLAB: ROS custom message listed but Matlab fails to create message/pu​blisher/su​bscriber

custom messagerosROS Toolbox

Hi everybody,
I use MATLAB2020a under Win10 and use rosgenmsg to use grid_map messages in Matlab.
  1. I created the custom message as stated in the documentation (I had to add two build dependencies in grid_map_msgs package.xml though)
  2. The new custom messages are visible if I exected rosmsg list, e.g. the message type 'grid_map_msgs/GridMap':
If I now want to create a message I get the following error:
>> rosmessage('grid_map_msgs/GridMap')
Cannot find a MATLAB message class for type grid_map_msgs/GridMap.
Also, if I create an publisher (rosinit works, connected to master), I get the following error:
>> pub = rospublisher('/MyTest', 'grid_map_msgs/GridMap');
Failed to create a publisher with topic name /MyTest and type grid_map_msgs/GridMap.
Same applies for a subscriber.
Does anybody have an idea why this does not work, even though the custom messages are listed in Matlab correctly?
Best regards,
Emanuel

Best Answer

Hi everybody,
I figured out the root of the problem: I did not check the system requirements carefully. On Win10 I needed Python 2.7 and Cmake 3.15.5+. After recreating the messages with rosgenmsg I also got more outputs during the process: e.g., that I have to add the absolute paths of the jar-files to the javaclasspath text-file.
Now it works.
Cheers,
Emanuel
Related Question