btMultibody Per-Joint damping or friction

benelot
Posts: 350
Joined: Sat Jul 04, 2015 10:33 am
Location: Bern, Switzerland

btMultibody Per-Joint damping or friction

Post by benelot »

Hello,

I found out that the setLinearDamping() and setAngularDamping() methods of the btMultibody do not what I expected them to do. I thought they would add damping to every joint of the multibody and thereby dampen the linear and angular movement of the prismatic, revolute and spherical joints. But what they actually do is to dampen the movement of THE WHOLE multibody in the way that it does not fall as fast due to gravity and does stop rotating after a while when rotated with a torque impulse.

Does the multibody also provide per joint damping or something like joint friction? Or how could I implement this otherwise?
Last edited by benelot on Wed Dec 02, 2015 9:29 pm, edited 1 time in total.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: btMultibody Per-Joint damping or friction

Post by Erwin Coumans »

Yes, I will look into fixing the linear/angular damping issue for btMultiBody.
Does the multibody also provide per joint damping something like joint friction?
Yes, you can add a btMultiBodyJointMotor to each revolute/prismatic joint with target velocity 0, and tune its maximum force.
benelot
Posts: 350
Joined: Sat Jul 04, 2015 10:33 am
Location: Bern, Switzerland

Re: btMultibody Per-Joint damping or friction

Post by benelot »

Right, I forgot that we have motors for the Featherstone models as well. Thank you!
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: btMultibody Per-Joint damping or friction

Post by Erwin Coumans »

You can also apply explicit damping forces manually for 1-DOF joints (revolute, prismatic) based on the velocity and some factor that you need to tune. Assuming a fixed time step, you could do like this:
int jointIndex = 0;
btScalar c = -10.f;//tune this value
m_multiBody->addJointTorque(jointIndex, c*m_multiBody->getJointVel(jointIndex));
If needed, you can add this code in a tick callback, so it is properly in sync with the physics integrator (see world-> setInternalTickCallback).