How to use String array in a custom Message in Simulink?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Josh Chen
le 22 Jan 2021
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 commentaires
Voir également
Catégories
En savoir plus sur LEGO MINDSTORMS EV3 Hardware dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!