Co-simulation Simulink and Gazebo: Gazebo custom support block makes simulation very slow

Hi, all.
I have an issue related to the too slow simulation speed due to the Gazebo Custom Support block in Simulink for Co-simulation Simuink and Gazebo. (I used MATLAB and Gazebo on the same mashine, Ubuntu)
I imagined that the contact message has too many fields, so it makes the speed slow.
But, even I selected /gazebo/default/joint in the Gazebo Custom Support block, it makes the speed very slow.
Once I remove the block, the speed is normal.
Is this a known issue?
If it is, please let me know when it would be solved. This is very critical issue for my project, since I am using reinforcement learning. For instance, a policy is trained with a normal simulation speed. And if i try to train it further only adding the Gazebo Custom Support block to the Simulink model, the performance is changed greatly due to the slow speed. it may be not related to this issue, but it is still critical.
Thanks.
In addition, I attached the comparison between a inverse kinematics result vs. a inverse kinematics result with the Gazebo Custom Support block. (a dffierence is this block)
Even they have the same target joint angles, just adding the Gazebo Custom Support block makes the changes in the results.
Some joints' responses without the block are fast while other joints' responses without the block are slow.
Are they some kinds of bugs?

 Accepted Answer

Hi Yunsik,
Which MATLAB version you are using?
Further, I didn't get the comparision part. Which two results you are comapring?
Are you comparing Gazebo MATLAB API vs Gazebo Simulink Subscribe block ?
Can you please add more details about experiment.
Thanks

5 Comments

Hi, Gaurav.
Thank you for the response.
The experiment is that,
  1. set any model for Co-simulation with Gazebo without Gazebo Custom Support block in Simulink
  2. set another model that is exactly same with the previous one. And just add Gazebo Custom Support block to the simulink model. Do not need to connect, just add the block.
  3. Compare these two model.
Then, you can see the performance differences. Just addition the Gazebo Custom Support block makes the performance very slow. Typically, the simulation speed of Gazebo slows down as 3-5 times.
And in my view point, the above results (responses) might be resulted by the changes of the simulation speed.
If you need any further details, please let me know.
Thanks,
Yun
Hi Yunsik,
Okay. This might be due to still you are using /gazebo/default/joint which can have large message size. My suggestion was, to create customize message which contains few fields which you need. Further, you need to call Gazebo API inside custom message plugin. This is complex workflow and need some Gazebo API understanding to enable this.
But, as I mentioned in the another post, the use of JointState can help you to get joint details.
If that works, you don't need custom message block.
Thanks
Hi, Gaurav.
Thank you for the response.
Actually, the reason why I need to use the Gazebo custom block is to get contact information (collisions, contact points' positions). In my experince, there is no way to get contact information without using the custom block unless I can understand the workflow and Gazebo API.
Further, in my point of view, the gazebogenmsg function generates 5 proto files as shown below.
Since I selected only "gazebo.msgs.Contact", "gazebo.msgs.Contacts" in the message.
I think it is difficult to understand these information makes the simulation very slow.
Have you try to check the reduced simuilation speed due to only includng the gazebo custom block?
Is there any workaround to ge the contact infomation (collisions' geometries, contact points' positions) in Simulink instead of using the gazebo customized block?
(like using ROS topics?)
Sorry I asked similar questions several times, but this is typical for our project progress.
Thanks,
Yun
Hi Yunsik,
One more thing you can fix for older MATLAB version.
1] You need to open Gazebo library \toolbox\robotics\robotsimulink\robotslgazebo\robotgazebolib.slx
2] Unlock library
3] Click on down arrow
4] Check the sample time value. If it is 0.001 then change to 'sampleTime'. Compare all parameters shown below.
After this, save the robotgazebolib.slx and relaunch MATLAB.
Further, try to keep higher sample time for subscribe block, which can imporove performance.
Thanks.
Hi, Gaurav.
It works! The reduced performance caused by this, "toolbox\robotics\robotsimulink\robotslgazebo\robotgazebolib.slx"!
In next version, it should be fixed.
Thank you very much!
Yunsik

Sign in to comment.

More Answers (0)

Products

Release

R2021a

Community Treasure Hunt

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

Start Hunting!