Ask Your Question

Gazebo: disable physics or enable kinematics through code/command line

asked 2015-10-06 22:25:45 -0500

LevAva gravatar image

I know that Gazebo has its own answers page, but it doesn't seem to be up anymore so I thought I might try here.

I am trying to send model state information to gazebo for my robot, and control it using a teleop_twist_keyboard. The model state is sent and received fine, but then the robot starts rubberbanding around on the axis where I changed its position (I am sending absolute xyz/orientation, not velocity commands from the teleop keyboard). I noticed that if I either disable physics under the Physics tab on the gui, or set Models/MyRobot/link1/kinematic true, also through the gui, everything behaves much much better.

The problem is, I can't find a way to change either of those options through the command line or through ROS. The options are neither in the physics properties message nor the link properties message, and I haven't seen any other way to change them other than the gui.

Pausing and unpausing physics does not work, since that turns off the simulation timer altogether which means model state positions aren't updated, nor are laser scans. If I try to set my model to static, then my laser link stops updating rayscans, which is not helpful. Doing <kinematic>true</kinematic> on my .gazebo for the .urdf did nothing at all.

Is there a way to either disable physics (but keep the simulation running) or make my link/robot kinematic through command line arguments or through ROS service calls/messages? Preferably the disabling physics one, though, since it's running on a VM and disabling physics gives a massive speed boost.

ROS Version: Jade Gazebo Version: 5.0

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted

answered 2015-10-08 19:39:38 -0500

LevAva gravatar image

I have found a solution of sorts, instead of disabling physics directly I just set the solver iterations to 0 which has the same effect and can be done through messages. Of course this is the nuclear option, since this turns off all physics, not just for the link you want.

Here's a rosservice call to do it:

rosservice call /gazebo/set_physics_properties "
time_step: 0.001
max_update_rate: 1000.0
  x: 0.0
  y: 0.0
  z: 0.0
  auto_disable_bodies: False
  sor_pgs_precon_iters: 0
  sor_pgs_iters: 0
  sor_pgs_w: 1.3
  sor_pgs_rms_error_tol: 0.0
  contact_surface_layer: 0.001
  contact_max_correcting_vel: 100.0
  cfm: 0.0
  erp: 0.2
  max_contacts: 20"
edit flag offensive delete link more

answered 2016-12-08 03:28:27 -0500

mnschulz gravatar image

This might be an old thread but I haven't seen a direct answer. I solved it by defining a world plugin that exposes the WorldPtr (see Gazebo World Class Reference) in the Load function and disabling the Physics Engine in the on_update method:

void DisablePlugin::Load(gazebo::physics::WorldPtr ptr, sdf::ElementPtr sdf) {
    _world = ptr;
    _update_connection = gazebo::event::Events::ConnectWorldUpdateBegin(
            boost::bind(&DisablePlugin::on_update, this, _1));
void DisablePlugin::on_update(const gazebo::common::UpdateInfo& /*info*/) {
    if (_world->GetEnablePhysicsEngine())

You can then set the pose of a model for example by using the SetLinkWorldPose method.

edit flag offensive delete link more


To extend on your answer, you do not need to disable it on the on_update method, on the Load is OK, otherwise you are executing this every iteration.

Javier V. Gómez gravatar image Javier V. Gómez  ( 2016-12-14 11:52:12 -0500 )edit

You are not executing it at every iteration, as it is only executed if the Physics Engine is enabled. Having the disable in the on_update ensures that no iteration will be done with the Phyiscs Engine enabled as you have no guarantee on the order of the Load Method. It depends on the logic you want.

mnschulz gravatar image mnschulz  ( 2016-12-15 02:47:28 -0500 )edit

Thanks, this seems like an ok solution. However it would be nice to just start the simulator without any physics engine.

reinzor gravatar image reinzor  ( 2017-01-27 04:53:13 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2015-10-06 22:25:45 -0500

Seen: 4,031 times

Last updated: Oct 08 '15