Gazebo subscribe block error in Simulink

23 views (last 30 days)
Hi, all. I have created Gazebo plugin including several message types, such as contacts, pose, link, joint, and etc. using gazebogenmsg to communicate Simulink and Gazebo.
The plugin works appropriately, and I can read forces and torques using the Gazebo subscribe block in Simulink.
However, when I try to read contacts, then there is an error as shown below.
[Error in Simulink]
An error occurred while running the simulation and the simulation was terminated
Caused by:
  • For 'Output Port 2' of 'gazeboCosimControl_ys_v3/Gazebo Robot/Gazebo Subscribe con_info_redbox/SourceBlock', the method 'outputImpl' of the System object 'robotics.slgazebo.internal.GazeboSubscribeBlk' returns a bus type whose field Gazebo_SL_Bus_gazebo_msgs_custom_gazebo_msgs_Contacts.contact.wrench.body_1_wrench.force.x size does not match the field Gazebo_SL_Bus_gazebo_msgs_custom_gazebo_msgs_Contacts.contact.wrench.body_1_wrench.force.x size defined in the method 'getOutputDataTypeImpl'.
I have no idea how to solve this problem. Would you let me know if you have any ideas to solve it?
Thanks!
In addition, I defined the contacts to the Gazebo *.world file as shown below. And I have checked these topics are published in Gazebo.
<collision name='m1n6s300_link_finger_tip_1_collision'>
<pose frame=''>0 0 0 0 -0 0</pose>
<geometry>
<mesh>
<scale>1 1 1</scale>
<uri>/home/user/catkin_ws/src/kinova-ros/kinova_description/meshes/finger_distal.dae</uri>
</mesh>
</geometry>
<max_contacts>100</max_contacts>
<surface>
<contact>
<ode/>
</contact>
<bounce/>
<friction>
<torsional>
<ode/>
</torsional>
<ode/>
</friction>
</surface>
</collision>
<visual name='m1n6s300_link_finger_tip_1_visual'>
<pose frame=''>0 0 0 0 -0 0</pose>
<geometry>
<mesh>
<scale>1 1 1</scale>
<uri>/home/user/catkin_ws/src/kinova-ros/kinova_description/meshes/finger_distal.dae</uri>
</mesh>
</geometry>
</visual>
<self_collide>0</self_collide>
<enable_wind>0</enable_wind>
<kinematic>0</kinematic>
<sensor name = 'con_info_finger_tip_1' type = 'contact'>
<contact>
<collision>m1n6s300_link_finger_tip_1_collision</collision>
</contact>
</sensor>

Accepted Answer

Gaurav Bhosale
Gaurav Bhosale on 13 May 2021
Hi Yunsik,
The Gazebo_SL_Bus_gazebo_msgs_custom_gazebo_msgs_Contacts.contact.wrench.body_1_wrench.force.x is of variable length. The received message data is excceding dimension limit ( default is 128), so you need to increase dimension limit from Bus Editor.
Check Customize Bus Objects for Simulation from https://www.mathworks.com/help/robotics/ug/control-manipulator-robot-with-co-simulation.html
Try to change bus dimension and let me know if you face any issue in doing that.
  2 Comments
Gaurav Bhosale
Gaurav Bhosale on 21 May 2021
Hi Yunsik,
You can check message sizes from Gazebo but that is not straightforward. Currently, there is no direct way to determine bus size is MATLAB.
You can keep larger dimension size such that you never exceed bus dimension limit.
Further, there are several fields in Contacts message which are variable size. So, I recommend you to check field name mentioned in the error and try to increase dimension size of that field.
I used Contacts message below. The Contacts message is repeatative Contact message. So, if you are using just Contact message then ignore 3rd modification from below.
For Contacts message, I modify bus sizes as follows,
1] I modifed bus sizes for Vector3d message as,
2] I modified bus sizes for bodyname, body id from JointWrench message as,
3] I modified bus sizes for Contact message as follows,
Basically, these sizes can vary with input message. Also, there are many messages which are repeatative in Contacts message, so you need to tune those fields as per your Gazebo message.
Try to modify above fields and let me know if you still face same issue.
Thanks

Sign in to comment.

More Answers (2)

Yunsik Jung
Yunsik Jung on 10 Jun 2021
Dear, Gaurav.
Really appreciate giving the detailed comments on the issue!
I carefully followed your descrionts in the bus editor.
But, I am still have some issues.
[1] Extract contacts/positions from the Gazebo Subscribe
When I tried to get the positions from the Gazebo Subscribe over the bus selector, I got the following error.
Simulation 2 1
05:14 AM Elapsed: 5 sec
Simulation 1 1
05:16 AM Elapsed: 2 sec
'Input Port 1' of 'gazeboCosimControl_ys_v3/Gazebo Robot/Display1' is not connected.
Component: Simulink | Category: Block warning
Simulink cannot propagate the variable-size mode from the 'Output Port 1' of
'gazeboCosimControl_ys_v3/Gazebo Robot/extract1/Bus Selector1' to the 'Input Port 1' of
'gazeboCosimControl_ys_v3/Gazebo Robot/extract1/Mux2'. This input port expects a fixed-size mode.
Examine the configuration of 'gazeboCosimControl_ys_v3/Gazebo Robot/extract1/Mux2'
for one of the following scenarios:
1) the block does not support variable-size signals;
2) the block supports variable-size signals but needs to be configured for them.
Component: Simulink | Category: Block error
And here is my simulink,
Can you see any problems with them?
[2] Extract contacts/collision from the Gazebo Subscribe
When I tried to get the pocollision[collision body name] from the Gazebo Subscribe over the bus selector, the simulation works! However, when a contact occurs, then I got the following error message.
Simulation 2 1
05:14 AM Elapsed: 5 sec
Simulation 1 1
05:16 AM Elapsed: 2 sec
Model Save (gazeboCosimControl_ys_v3)
05:37 AM Elapsed: 0.584 sec
Model Save (gazeboCosimControl_ys_v3)
05:37 AM Elapsed: 0.659 sec
Simulation 1 1
05:38 AM Elapsed: 25 sec
Block 'gazeboCosimControl_ys_v3_2/Gazebo Robot/Display1' shows truncated signal data.
The Display block can show up to 200 elements of vector or matrix signals.
Component: Simulink | Category: Block warning
An error occurred while running the simulation and the simulation was terminated
Caused by:
For 'Output Port 2' of 'gazeboCosimControl_ys_v3_2/Gazebo Robot/Gazebo Subscribe con_info_redbox/SourceBlock',
the method 'outputImpl' of the System object 'robotics.slgazebo.internal.GazeboSubscribeBlk'
returns a bus type whose field Gazebo_SL_Bus_gazebo_msgs_custom_gazebo_msgs_Contacts.contact.wrench.body_1_name
size does not match the field Gazebo_SL_Bus_gazebo_msgs_custom_gazebo_msgs_Contacts.contact.wrench.body_1_name
size defined in the method 'getOutputDataTypeImpl'.
Component: Simulink | Category: Block error
In addition, here is my simulink blocks.
Do you have any comments for me to solve this issue?
Thank you very much!
Best,
Yun

Gaurav Bhosale
Gaurav Bhosale on 10 Jun 2021
Hi Yunsik,
1] This issue is more related to mux don't support variable size input. So, might be you need to try with fixed size bus. If you aware of size of incoming message then you can change bus to fixed size and add the bus size. Similar, settings are mentioned in the UR10 Gazebo Example in 'Customize Bus Objects for Simulation' section.
2] You need to increase bus size for Gazebo_SL_Bus_gazebo_msgs_custom_gazebo_msgs_Contacts.contact.wrench.body_1_name
Whenever collision occurs, the wrench.body_1_name contains body name string, which is exceeding bus limits of Contacts.contact.wrench.body_1_name.
So, try with higher value.
Thanks
  1 Comment
Yunsik Jung
Yunsik Jung on 14 Jun 2021
Hi, Garurav.
Thank you so much for the information. I can address those issues except the variable sized elements from the contact-positions.
So, I created new question related to this.
https://kr.mathworks.com/matlabcentral/answers/855615-gazebo-customized-plugin-read-contact-positions-that-contains-both-a-variable-sized-element-and-an
Thank you so much for your help, again!
Yun

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by