MultiBody (Featherstone) - Setting damping

Post Reply
Isos
Posts: 3
Joined: Mon Mar 10, 2014 2:12 pm

MultiBody (Featherstone) - Setting damping

Post by Isos »

I'm using the Featherstone implementation for an accurate application, and I noticed that a pendulum, for instance, loses energy fairly rapidly.

Glancing through the code for btMultiBody, I noticed that there's a built-in damping factor of 0.04. I'm brand new to C++, but I can't seem to find a way to set this value externally. Before I attempt to change Bullet's source code and reinstall everything, is there an obvious solution I'm missing? It seems unlikely to have an unsettable parameter like this.

Thanks for bearing with my stupid question :P

Code: Select all

btMultiBody::btMultiBody(int n_links,
                     btScalar mass,
                     const btVector3 &inertia,
                     bool fixed_base_,
                     bool can_sleep_)
    : base_quat(0, 0, 0, 1),
      base_mass(mass),
      base_inertia(inertia),
    
                fixed_base(fixed_base_),
                awake(true),
                can_sleep(can_sleep_),
                sleep_timer(0),
                m_baseCollider(0),
                m_linearDamping(0.04f),
                m_angularDamping(0.04f),
                m_useGyroTerm(true),
                m_maxAppliedImpulse(1000.f),
                m_hasSelfCollision(true)
Flix
Posts: 456
Joined: Tue Dec 25, 2007 1:06 pm

Re: MultiBody (Featherstone) - Setting damping

Post by Flix »

Well, I've never used that class so far, and m_linearDamping and m_angularDamping seem to be private.
However there are some accessors:

Code: Select all

	btScalar getLinearDamping() const
	{
			return m_linearDamping;
	}
	void setLinearDamping( btScalar damp)
	{
		m_linearDamping = damp;
	}
	btScalar getAngularDamping() const
	{
		return m_angularDamping;
	}
The problem is that btMultiBody::setAngularDamping(...) seems to be missing... :?, at least in the Bullet version I'm using (from the old SVN repository, maybe I should use the Bullet2 version that is contained in the Bullet3 git repo, should I?).

P.S. I think you can just add btMultiBody::setAngularDamping(...) in btMultiBody.h without recompiling the library (it should stay inline and it won't change the size of the class as far as I can remember; alternatively it should be possible to replace "private:" with "public:" without recompiling as well).
Isos
Posts: 3
Joined: Mon Mar 10, 2014 2:12 pm

Re: MultiBody (Featherstone) - Setting damping

Post by Isos »

Thanks! I was able to add a set method without fairly easily.

New issue -- Maybe the damping was there for a reason? Now my model quickly gains energy and spins out of control. It seems that the damping was a hack to keep things stable. Any ideas about a real fix that doesn't involve arbitrary damping?
Flix
Posts: 456
Joined: Tue Dec 25, 2007 1:06 pm

Re: MultiBody (Featherstone) - Setting damping

Post by Flix »

Isos wrote:New issue -- Maybe the damping was there for a reason? Now my model quickly gains energy and spins out of control. It seems that the damping was a hack to keep things stable. Any ideas about a real fix that doesn't involve arbitrary damping?
Well, I don't have enough experience with the Featherstone Multi Body Bullet implementation to answer this. However there's a recent paper by Erwin about the implementation details here (http://box2d.org/downloads/): maybe you can find it useful (it's too technical for me :) ).

BTW: In the Bullet Multi Body Demo, if I set the target velocity of the rotational motor to something different from zero (the value used in the demo), its limits are ignored.
Post Reply