Publishing on a ROS Topic Simulink

조회 수: 1 (최근 30일)
Hassan Hotait
Hassan Hotait 2021년 4월 24일
댓글: Hassan Hotait 2021년 4월 28일
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!

답변 (1개)

Josh Chen
Josh Chen 2021년 4월 25일
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

카테고리

Help CenterFile Exchange에서 Specialized Messages에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by