ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

how to speed up gazebo simulation?

asked 2022-10-01 04:42:23 -0600

underscoredavid gravatar image

updated 2022-10-02 08:59:17 -0600

Mike Scheutzow gravatar image

I'm working with the panda_gazebo package to control the 7-dofs franka manipulator, using the cartesian velocity controller of ros_control. For computational constraints, I have to slow down the gazebo simulation, settting real_time_update_rate from 1000.0 to 100.0 and max_step_size from 0.001 to 0.01. That's to keep a real time factor of 1. Consequently, the PID controller frequency of the manipulator has been set from 1Khz to 100Hz. The original PID values of the velocity controller working at 1Khz are as follows:

# Panda SDK Controllers: Velocity --------------------------  
  type: panda_sim_controllers/PandaVelocityController         
  topic: /panda_simulator/motion_controller/arm/joint_commands
      joint: panda_joint1                                     
      pid: {p: 10,  i: 0.0, d: 0.1}                           
      joint: panda_joint2                                     
      pid: {p: 100,  i: 1.0, d: 0.1}                          
      joint: panda_joint3                                     
      pid: {p: 0.05,  i: 0.0, d: 0.01}                        
      joint: panda_joint4                                     
      pid: {p: 0.5,  i: 0.01, d: 0.1}                         
      joint: panda_joint5                                     
      pid: {p: 1.0,  i: 0.0, d: 0.01}                         
      joint: panda_joint6                                     
      pid: {p: 0.05,  i: 0.0, d: 0.01}                        
      joint: panda_joint7                                     
      pid: {p: 0.05,  i: 0.0, d: 0.01}

These parameters works fine for the simulation running at the 1Khz, but as soon as the frequency turns to 100Hz, I'm not able to control the manipulator anymore. Indeed, it starts moving randomly even when no commands are being sent at all.

I know a popular technique to manual tuning PID values is to increase Kp as much as possible, then working on Kd and finally Ki. There is also a pid_tuning package available.

However, I wasn't any luck with those approaches.

Knowing the correct parameters at 1Khz, I'm pretty sure there should be a rule of thumb to make those values work at 100Hz. I've tried to just multiply/divide them by 10, since I'm now operating at 1/10th of the frequency, but again that approach failed.

edit retag flag offensive close merge delete



The issue is you have created a bad physics simulation by making the time_step coarser. I doubt any amount of pid tuning is going to fix that.

Mike Scheutzow gravatar image Mike Scheutzow  ( 2022-10-01 09:38:17 -0600 )edit

I reduced the timestamp because I need to work in real time but my machine doesn’t bear 1Khz. Are there other strategies to reduce the gazebo high-resource demanding or it’s a dead end project?

underscoredavid gravatar image underscoredavid  ( 2022-10-01 09:53:27 -0600 )edit

I edited your title to make it more general.

Mike Scheutzow gravatar image Mike Scheutzow  ( 2022-10-02 09:00:00 -0600 )edit

Is there any tutorial explaining how to fix a broken gazebo simulation?

underscoredavid gravatar image underscoredavid  ( 2022-10-10 00:51:01 -0600 )edit

@underscoredavid Not that I'm aware of. It's a very difficult problem, because the input files are complex and there are so many possible configurations.

A common strategy is to start from a working simulation, and test each incremental change you make - that tends to help you narrow down where to look for the problem.

Mike Scheutzow gravatar image Mike Scheutzow  ( 2022-10-10 08:35:24 -0600 )edit

1 Answer

Sort by » oldest newest most voted

answered 2022-10-02 08:58:00 -0600

Mike Scheutzow gravatar image

updated 2022-10-02 09:09:17 -0600

Yes, there are strategies to speed up the gazebo simulation. This is a general answer as I'm not familiar with your specific simulation:

  • never ever use a mesh for collision geometry. This causes massive slowdown because each face has to be checked for collision. For a robot arm, you typically want to use a cylinder primitive for a link's collision geometry.
  • reduce the number of "objects" in your world. They may look nice, but each one slows down the simulation.
  • use top to make sure nothing else is using a significant amount of cpu on the host (the gazebo physics engine does not use multiple cpu cores, but you want to try to avoid pushing the cpu into thermal throttling.)
  • run only the gazebo server, not the gazebo client (the GUI). If your host does not have a GPU with hardware OpenGL support, definitely do not run the GUI on the same machine.
edit flag offensive delete link more

Question Tools



Asked: 2022-10-01 04:42:23 -0600

Seen: 820 times

Last updated: Oct 02 '22