How to use String array in a custom Message in Simulink?
4 次查看(过去 30 天)
显示 更早的评论
I have a custom message imported in matlab which requires Velocity and Name. In the custom msg file, Name is defined as string[] name. So I read The robotrosmessageExample and followed the same procedure, However I get an error in ros of a dimension mismatch. I used same messages in matlab and It worked fine. So How can this issue be resolved ?
The model is attached in the screenshot below with the code of matlab function.
Thank you for your time
function msg = assignString(blankMsg)
stringToAssign = '[blade_joint_1; blade_joint_2; blade_joint_3; blade_joint_4; blade_joint_5; blade_joint_6]';
msg = blankMsg;
strLength = length(stringToAssign);
msg.Data(1:strLength) = uint8(stringToAssign);
msg.Data_SL_Info.CurrentLength = uint32(strLength);
0 个评论
回答(1 个)
Josh Chen
2021-1-22
Hello David,
It seems that the the message you are assigning here is of type "std_msgs/String", have you tried to change the maximum length of the "std_msgs/String" message to match the actual assigned string length?
The screenshot shows the correct pane to set this up, however, I assume it should be the third message (currently it is showing the first message). If this is not the case, please share a model so we can take a look.
Not sure if you've already checked this out, but this example model tries to do a pretty similar work.
Hope this helps.
Josh
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Custom Message Support 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!