Cant Input Constant to Simulink Bus Assignment Size and Stride
3 views (last 30 days)
Show older comments
I am currently on Simulink trying to input a std_msgs/Float64MultiArray to a publisher. I have it in a bus assignment block with the inputs of bus, data, layout.dim.size, and layout.dim.stride. The data I am passing is a 1x20 float64multiarray. Since the size and stride is constant, I tried passing those constants to the bus assignment, and I made sure it was type casted to uint32 as those are the data types the size and stride use for std_msgs/multiarray. The error I am getting is Error:The Bus Assignment block 'lidarobjectdetect/Subsystem3/Bus Assignment' could not replace signal 'layout.dim.size', because this signal is inside an array of buses 'layout.dim'. Below shows an image of my setup on Simulink. If anyone could help, that would be great. Thanks.

0 Comments
Answers (1)
Spruha
on 24 Apr 2025
I see you are encountering a Simulink Bus Assignment limitation: ‘You cannot directly assign to a field inside an array of buses using the Bus Assignment block’. This is because ‘layout.dim’ is an array of buses (not a single bus), and Simulink's Bus Assignment block cannot access or assign to fields inside elements of a bus array.
Please refer to this discussion on MATLAB answers community : https://www.mathworks.com/matlabcentral/answers/461711-how-can-i-handle-the-array-type-of-ros-messages
You can use 'MATLAB function' block to construct the entire ‘layout.dim’ array then assign it to bus as whole.
Refer this to learn more about MATLAB Function block: https://www.mathworks.com/help/simulink/slref/matlabfunction.html
Hope this helps!
0 Comments
See Also
Categories
Find more on Publishers and Subscribers in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!