Simulink Bus Assignment for Array of Buses
10 次查看(过去 30 天)
显示 更早的评论
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?

0 个评论
回答(1 个)
Shlok
2025-7-17
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:
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!