Publishing on a ROS Topic Simulink

3 visualizaciones (últimos 30 días)
Hassan Hotait
Hassan Hotait el 24 de Abr. de 2021
Comentada: Hassan Hotait el 28 de Abr. de 2021
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!

Respuestas (1)

Josh Chen
Josh Chen el 25 de Abr. de 2021
Hello Hassan,
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:
  1. 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.
  2. Provide the correct length with 'Data_SL_CurrentLength' when you assign values with bus assignment block.
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,
Josh

Productos


Versión

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by