I am simulating a manipulator and would like to get the forces acting on a link in the tree due to links that are after it. I can see that the gravity force is being computed this way but it only returns in joint space. I tried getting the getBodyForce() from the body node but it has ‘0’. How should I go about this?
BodyNode::getBodyForce() should be the function you’re looking for. It returns the wrench acting on the body due to its parent in the local coordinate. So you can get the wrench acting on the body due to its child by negating the wrench of the child body force and coordinate transformation from the child local coordinate to itself.
It’s interesting that
getBodyForce() always returns zero though. Could you share a minimal code that I can reproduce the case?