How to setforce at a constant interval? [closed]

asked 2018-06-11 13:09:02 -0600

jwchang gravatar image

I have to write a gazebo 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 reach the goal?

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++;
};
edit retag flag offensive reopen merge delete

Closed for the following reason Gazebo Question: The Gazebo community prefers to answer questions at: http://answers.gazebosim.org by gvdhoorn
close date 2018-06-11 14:49:02.427307