Simulink Bus Assignment for Array of Buses

6 views (last 30 days)
Tai Hoang
Tai Hoang on 7 Apr 2025
Answered: Shlok on 17 Jul 2025
I am working with a Simulink model to publish pointCloud data from Simulation 3D Lidar block. The requirement is to publish the message of type sensor_msgs/PointCloud2. In the message description, there is an information named "PointField[] fields". As the description, fields is an array of many subfields.
I created a Bus Assignment and would like to include "fields.name", "fields.offset", "fields.datatype", and "fields.count". However, an error occurs when I update the model: "Error:The Bus Assignment block '.../Bus Assignment4' could not replace signal 'fields.name', because this signal is inside an array of buses 'fields'."
When I use only "fields", which includes all the above signal, another error appears: "Error:The 'Input Port 2' of the Bus Assignment block '.../Bus Assignment4' is configured to accept a bus signal. However, the actual input is a non-bus signal."
The other signals/topics that I also use do not contain any array of buses like that. How can I set up my Simulink model correctly?
Simple model to publish PointCloud

Answers (1)

Shlok
Shlok on 17 Jul 2025
Hi Tai,
It appears to me you're trying to assign "fields.name" inside a "sensor_msgs/PointCloud2" message using a "Bus Assignment" block. That doesn’t work because "fields" is an array of buses, and Simulink doesn’t support assigning to subfields of elements within an array using the "Bus Assignment" block.
As per the documentation (here), to assign values to elements of a bus in an array of buses, you should use a MATLAB Function block. So you’ll need to build the full "fields" array using a MATLAB Function block and assign it in one go.
Refer to the following documentation, to know more about assigning into elements of Array of Buses:

Categories

Find more on Automotive in Help Center and File Exchange

Tags

Products


Release

R2024a

Community Treasure Hunt

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

Start Hunting!