Gazebo Customized Plugin: Read contact positions that contains both a variable sized element and an array of sub-buses
6 views (last 30 days)
I have tired to use the customized Gazebo plugin with Simulink and Gazebo in the virtual machine (Ubuntu).
The communication works between Gazebo in the virtual machine and Simulink.
However, when I try to read the contact-positions information (multiple contacts), the error occurs as shown below.
04:28 AM Elapsed: 3 sec
01:52 AM Elapsed: 20 sec
01:52 AM Elapsed: 2 sec
02:30 AM Elapsed: 3 sec
02:31 AM Elapsed: 3 sec
The bus object 'Gazebo_SL_Bus_gazebo_msgs_custom_gazebo_msgs_Contacts' associated with
the block 'gazeboCosimControl_ys_v3/Gazebo Robot/Bus Selector13' contains both a variable sized element
and an array of sub-buses. Arrays of buses cannot be used in conjunction with bus objects that
contain variable sized elements.
Component: Simulink | Category: Block error
In addition, the contact-positions have the following variable sized elements based on Gazebo simulation. I mean multiple contacts can include to this information as shown below.
To solve this issue, I have tried to use several blocks related to 'bus' such as, bus to vector, to virtual bus, bus selector, etc, but I couldn't solve it.
Do you have any advice to address this issue?
Thank you so much in advance,
Gaurav Bhosale on 28 Jun 2021
I created Simulink model for Contacts message and able to subscribe Contacts message data. To enable this, I did following changes.
1] The Contacts message is repeatative so you have to change few messages as follows.
You should change Dimensions as per you message length. Also, don't forget to change DimesnionMode to 'Variable' ( Highlighted in red ). The contacts message keep changing its size so it should be variable. Make sure, you do all following changes.
2] The Simulink model look as follows,
Basically, you we get values in array form. e.g. If Contacts message contains 14 Contact messages/details, which you see as repeated fields in protobuf but in Simulink, these messages are in array form as shown above.
In above figure, <x> contains Wrench.force.x in array form, in which, each index define force.x value for each body.
You can separate these values in MATLAB function.
More Answers (2)
Gaurav Bhosale on 14 Jun 2021
You can directly get Position.x at Bus Selector 13 by selection/expanding Position in Bus Selector.
Any specific reason to have two bus selector?