ROS2: Unrecognized message without using it in script
이전 댓글 표시
Hello Everyone,
i managed to import custom massages via the command ros2genmsg. But now i get allways the error, that some massage type is not recognisable by matlab. Even when i dont use any commands that need the custom commands. See code snippet:
clc
clear
topicName="/sensor_state";
matlabNode = ros2node("matlabNode");
SensorState = ros2subscriber(matlabNode,topicName);
This example gives me now the following error massage:
Error using ros.internal.getEmptyMessage>getMessageDataAndInfo
Unrecognized message type turtlebot3_msgs/SensorState. Use ros2 msg list to see available types.
Error in ros.internal.getEmptyMessage>getCachedMap (line 46)
[structInfo.data,structInfo.info] = getMessageDataAndInfo(msg, msgInfo, rosver);
Error in ros.internal.getEmptyMessage (line 35)
[data,info] = getCachedMap(msgMapROS2,msg,msgInfo,rosver);
Error in ros.internal.utilities.findMsgDepends (line 17)
[msgStruct,info] = ros.internal.getEmptyMessage(msgName,rosver);
Error in ros.internal.utilities.getPathOfDependentDlls (line 14)
pkgNamesMap = ros.internal.utilities.findMsgDepends(msgType,map,rosver);
Error in ros2subscriber/createSubscriber (line 669)
dllPaths = ros.internal.utilities.getPathOfDependentDlls(obj.MessageType,'ros2');
Error in ros2subscriber (line 330)
createSubscriber(obj, ordinalParser.Results.node.ServerNodeHandle, ...
Error in Turtlebot3_Subscription_SensorState (line 21)
SensorState = ros2subscriber(matlabNode,topicName);
I used turtlebot3_msgs/SensorState in the past, but deleted it afterwards because it was not longer necessary in my project. Is there any kind of storage in matlab that i have to reset when i delete packages on my disc?
EDIT: I can subscribe every topic, but not /sensor_state. E.g. /rosout.. Anyone a guess what it could be?
I use Matlab 2022a and ROS Toolbox 1.5.
I would much appreciate your help.
greetings, André
채택된 답변
추가 답변 (1개)
Hari Krishna Kakarla
2022년 4월 11일
0 개 추천
Hi Andre,
When you generate any custom messages, It registers with MATLAB Preferences. And when you want to delete your custom messages, you need to delete your generated matlab_msg_gen folder. After deleting it, Doing "clear all" in MATLAB should actually remove the messages from preferences.
Else, call this command to update your MATLAB preferences:
reg = ros.internal.CustomMessageRegistry.getInstance('ros2',true)
This will update the MATLAB preferences correctly. I hope this information is helpful.
Thanks
Hari
댓글 수: 6
Andre Below
2022년 4월 13일
편집: Andre Below
2022년 4월 14일
Hari Krishna Kakarla
2022년 4월 13일
Hi Andre,
I see that, you are getting this error message, if I am correct:
"Unrecognized message type turtlebot3_msgs/SensorState. Use ros2 msg list to see available types."
It means your message type "turtlebot3_matlab/SensorState" is depending on "turtlebot3_msgs/SensorState" which is not existing. Or you might have created your custom messages in two different folders. Ideally you need to have all your custom message packages in a single folder and generate your custom messages.
Try verifying these things:
reg = ros.internal.CustomMessageRegistry.getInstance('ros2',true)
msgInfo = reg.getMessageInfo('turtlebot3_msgs/SensorState')
From the fields of msgInfo, you can know where you have generated your custom messages and you can delete if not required. I hope this helps.
Thanks
Hari
Andre Below
2022년 4월 14일
편집: Andre Below
2022년 4월 14일
Andre Below
2022년 4월 14일
편집: Andre Below
2022년 4월 14일
Hari Krishna Kakarla
2022년 4월 14일
Hi Andre,
reg = ros.internal.CustomMessageRegistry.getInstance('ros2',true) will create a registry object. If you want to see the messages in the registry:
>> reg.getMessageList
Then check this:
>> reg.getMessageInfo('turtlebot3_msgs/SensorState');
If the above command says that there is no such message type in registry, then you can confirm that your previously generated custom messages are deleted from custom message registry.
Regarding your second question, I see that your topic is still subscring to the old message. It means some ROS 2 nodes are still active in background which earlier used those old messages. Please make sure to check all the ROS 2 nodes available in network and delete them. Please make sure to close all your MATLAB sessions running and start a new MATLAB session.
Thanks
Hari
Andre Below
2022년 4월 19일
카테고리
도움말 센터 및 File Exchange에서 Publishers and Subscribers에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!




