- Under Simulink->Prepare->VariableSize Messages, click on 'std_msgs/Int32MultiArray', uncheck 'Use default limits for this message type', and write down the correct length (in this case, 16) for the 'Data' field on the right pane.
- Provide the correct length with 'Data_SL_CurrentLength' when you assign values with bus assignment block.
Publishing on a ROS Topic Simulink
8 views (last 30 days)
I am trying to publish a message on the /command topic using ROS Toolbox block. I am receiving this error from my linux system where ROS is running. The 'data' variable is 16x1 array as shown above. I am not sure why it says that size is not 16. I have tried to change the data to 1x16 but that doesnt work. The strange thing is that I can publish a message using an m script and it works fine. Below you can see that the message.Data is the same data type and size as 'data'.
I would appreciate any help on this, this step is crucial for my project. Thanks in advance!
Josh Chen on 25 Apr 2021
In Simulink when creating a bus, it requires more information than MATLAB to lock down the message you want to send when it comes to variable size messages. As you might have noticed, 'std_msgs/Int32MultiArray' is one of the variable size messages. To get this to work, you would need to make sure you've done the following to steps:
I am not sure which version of MATLAB are you using, but I've attached an image based on R2021a for your reference.
You may also find this page helpful when dealing with ROS messages in Simulink.
Hope this helps,