Gazebo | Ignition | Community
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to setforce at a constant interval?

I use gazebo7.12.0 and want to write a model plugin to apply torque to a joint at a constant interval of 0.01 sec. It seems that the update rate of gazebo is 1000Hz, so I wirte the following code in OnUpdate(). This is not a good way because it's not exact 1000Hz in simulation from my testing. Is there other way to do it?

int count = 0;
public: void OnUpdate()
{
  if (count <= 10)
     this->model->GetJoint("joint")->SetForce(0,5);
  else if (count > 10 && count <= 20)
     this->model->GetJoint("joint")->SetForce(0,5);
  ...
  count++;
};