Co-simulation between Simulink and Gazebo runs slowly

조회 수: 4 (최근 30일)
Haruki SHIMOTORI
Haruki SHIMOTORI 2021년 2월 7일
댓글: Gaurav Bhosale 2021년 2월 22일
Hello.
I want to use Gazebo and Simulink to simulate a robot, so I tried this example first. Gazebo runs on a virtual machine on wondiws, and it works as shown in the example.
However, if I set the sampling time to subscribe to the IMU or image to be shorter than the default (e.g. 0.001[s]), the simulation takes a very long time. I am having trouble because I want to subscribe IMUs and images with a sampling time of about 0.001[s].
I don't think it is a lack of PC performance that causes the simulation to take so long. When I look at the resources of my PC, I see that the CPU is the most highly used, only about 80%. The virtual machine that Gazebo is running on also uses 80% of the CPU.
Do you have any ideas on how to reduce the simulation time?
Thank you!

채택된 답변

Gaurav Bhosale
Gaurav Bhosale 2021년 2월 8일
Hi Haruki,
You changed sampling time from 0.01 to 0.001 in the Gazebo Simulink block, which is correct. Currently, this is the way to change sample time.
I think, your concern is more about why Gazebo-Simulink runs slower after changing sample time.
If so, then the sample time is related to simulation step size. If you keep sample time equal to to 0.01 then each simulation step is of 10 msec. While, 0.001 sample time means each simulation step is of 1 msec. Thus, to finish 1 sec simulation with sample time of 0.001 will take longer time ( 1000 steps) than 0.01 ( 100 steps).
Further, the Gazebo Co-Simulation provides synchronized behavior between Gazebo and Simulink blocks. To maintian synchronization, Simulation is carried-out with step-by-step approach, which further add overhead and slow down simulation.
Thanks.
  댓글 수: 3
Haruki SHIMOTORI
Haruki SHIMOTORI 2021년 2월 9일
편집: Haruki SHIMOTORI 2021년 2월 9일
What I am particularly concerned about is whether there is a limit set on the communication speed between Gazebo and Simulink.
I would like to upgrade my PC if upgrading my PC specs will reduce the simulation time, but if the communication speed is limited, then my PC specs will have no effect on the simulation speed and there will be no point in upgrading my PC.
Gaurav Bhosale
Gaurav Bhosale 2021년 2월 22일
Hi Haruki,
When you launch Gazebo, it runs faster as it is Play mode. But, Gazebo Co-Simulation provides lock stepping and synchronization between Simulink and Gazebo, which need Gazebo single step call ( world->Step() ). So, the single stepping in Gazebo is takes more time as it is 'Play' - 'Pause' mode. Further, it will be more costly if the Simulation invloves senosor like camera, lidar. i.e. sensor simulation in Gazebo. on other hand, the message exchange adds few seconds but the major processing time is needed for Gazebo stepping.
Therefore, increasing specs of PC will help you at some extend but the incrasing sample time or decreasing sensor update rate can help you more for fast simulation.
Thanks

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Gazebo Co-Simulation에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by