Gazebo | Ignition | Community
Ask Your Question

How to implement a Force Sensor

asked 2012-12-03 17:33:25 -0500

PMilani gravatar image

Hi All,

I am wondering how you would implement a simulated force sensor to measure joint torques if the method physics::joint::GetForce(int) is not implemented. If anyone has done this with Gazebo any help would be appreciated.



edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted

answered 2012-12-03 22:47:57 -0500

ThomasK gravatar image

John just committed a new (?) force torque sensor to the issue_16 branch:

So there should be an official working solution in trunk soon.

edit flag offensive delete link more


It looks like that's a re-implementation of a feature that used to exist. It's necessary to create a force-torque sensor plugin as pointed to in my answer, but is not a force-torque sensor itself.

asomerville gravatar imageasomerville ( 2012-12-04 09:58:44 -0500 )edit

There is a ticket on bitbucket for creating an actual sensor:

nkoenig gravatar imagenkoenig ( 2013-01-11 18:03:52 -0500 )edit

answered 2012-12-03 18:27:44 -0500

asomerville gravatar image

updated 2012-12-04 14:58:37 -0500

DARPA arm simulator does that, as a gazebo plugin, here:

Note there was a specific gazebo tag in the URDF (<provideFeedback value="true"/>) that had to be used to get ODE to compute the force and torque at a particular point because it does some optimizations that typically prevent it from working.

I don't know if they've written a better implementation in the mean time, but this worked at the time.

Update: Note that from @ThomasK's response, the current version of Gazebo may not be able to use such a plugin until, the referenced patch is released.

edit flag offensive delete link more


Okay, thanks. It appears that the algorithm is a simplified Recursive Newton Euler Algorithm (google), basically only working with gravitational component (centrifugal and coriolis forces neglected (no big deal)), calculating the force backward from the tip of the end effector to the base. Correct?

PMilani gravatar imagePMilani ( 2012-12-04 17:32:52 -0500 )edit

Some of the code came from other places, and It's been a while so I don't exactly remember, but I'm sure I didn't specifically account for centrifugal and coriolis force unless it's already baked into GetBodyForce which it may be. I think that comes from ODE's calculations.

asomerville gravatar imageasomerville ( 2012-12-04 17:44:35 -0500 )edit

Okay, what then does GetBodyForce() output? Is it the cumulative force of child links on the COG of the current body, plus external (contact) forces? Your code suggests the cumulative force of the child links is calculated in calculatedForce loop (similar to RNEA) not using the GetBodyForce method

PMilani gravatar imagePMilani ( 2012-12-04 20:06:54 -0500 )edit

Hi, @asomerville, the files can't find anymore, can you post a new link?

littleghost gravatar imagelittleghost ( 2018-06-27 02:08:33 -0500 )edit

answered 2012-12-04 09:49:23 -0500

AndreiHaidu gravatar image


Have you tried creating a plugin, and then accessing the joint like this:

physics::JointPtr jointPtr;

jointPtr = this->myModel->GetJoint("jointName"); OR jointPtr = this->myModel->GetJoint(int index);


Here are some tutorials with plugins.

Cheers, Andrei

edit flag offensive delete link more


Hi Andrei, the documentation and .h files I have all say the joint::GetForce() is not implemented yet (of which jointPtr is a pointer to). Has this changed?

PMilani gravatar imagePMilani ( 2012-12-04 17:23:17 -0500 )edit

As Thomas mentioned, I've just begun implementing it in a brunch (e.g. see

hsu gravatar imagehsu ( 2012-12-04 21:28:55 -0500 )edit

Sounds good, if you would like a working algorithm the Recursive Newton Euler Algorithm is an accepted algorithm for it and Roy Featherstone has made some nice tutorials on IEEE Explore. I've implemented it in my own non-gazebo sim, but I'm unsure how to make it work for a generic sdf. can send copy

PMilani gravatar imagePMilani ( 2012-12-04 22:42:24 -0500 )edit

Question Tools

1 follower


Asked: 2012-12-03 17:33:25 -0500

Seen: 4,277 times

Last updated: Dec 04 '12