Syncing publisher with subscriber

asked 2018-09-07 12:51:34 -0500

gambini gravatar image

I am building a plugin to simulate a 200N constant force spring. My method subscribes to "/gazebo/default/myRobot/link/wrench", reads in the force in the x-axis, adds 200N, then applies the force back on the link.

I am applying the force by right-clicking on the link, selecting Add Force/Torque, enter in a value, and hold ENTER. This publishes the force at a certain frequency.

If I do my arithmetic in the callback function then it only works while the force is being applied then stops. If I place the arithmetic in the OnUpdate function called by event::Events::ConnectorWorldUpdateBegin() in the Load function, then the frequency in which I apply my force back is faster than the frequency of the messages received (which varies highly), resulting in very little movement unless I apply large force.

Is there a way to match the frequency at which I apply a force back on the link to the frequency of the topic?

edit retag flag offensive close merge delete