How to setforce at a constant interval? [closed]
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++;
};