Page 1 of 1

Hinge2 damping

Posted: Mon Nov 19, 2018 8:00 pm
by bram
btHello()

I am following the Hinge2Vehicle example to create a vehicle.

When I drop my vehicle on the ground, it oscilates indefinitely.

I create my hinge as follows:

Code: Select all

                btVector3 anchor = wp;
                anchor[1] += (i&2) ? WHEELPIVOTOFFSET : -WHEELPIVOTOFFSET;
                btVector3 axis1( 0,0,1 );
                btVector3 axis2( 0,1,0 );
                btHinge2Constraint* hinge = new btHinge2Constraint( *cb, *wb, anchor, axis1, axis2 );
                obdb_joints[j] = hinge;
                hinge->setParam( BT_CONSTRAINT_CFM, 0.20f, 1 );
                hinge->setParam( BT_CONSTRAINT_ERP, 0.25f, 1 );
                hinge->enableMotor( 3, true );
                hinge->setMaxMotorForce( 3, 500.0);
                hinge->setTargetVelocity( 3, -1 );
                hinge->enableMotor( 5, true );
                hinge->setMaxMotorForce( 5, 500.0);
                hinge->setTargetVelocity( 5, 0 );
                obdb_world->addConstraint( hinge );
I notice that the example code has a variable suspensionDamping commented out.
How can I damp the suspension of Hinge2?

ODE uses CFM and ERP for this, so I tried setting those parameters, to no avail.

Thanks,

Bram

Re: Hinge2 damping

Posted: Mon Nov 19, 2018 8:11 pm
by bram
Ah, OK, I think I found it.

From the parent class, setDamping() is inherited.

With trial and error, I saw that damping on axis2 will stop the oscilations.

Code: Select all

                hinge->setDamping( 2, 2.0f );

Re: Hinge2 damping

Posted: Mon Nov 19, 2018 8:48 pm
by bram
I spoke too soon.

Even with setDamping() and setStiffness() calls, there is residual oscillation that never goes away.

https://youtu.be/WHhR5poTSew

Any ideas why the spring will not settle?

Re: Hinge2 damping

Posted: Mon Nov 19, 2018 9:48 pm
by Erwin Coumans
We need to look into that. Would it be possible to re-create a small demo that shows the problem in the ExampleBrowser,
and file a issue in the tracker? See https://github.com/bulletphysics/bullet3/issues
(note that this tracker is mostly volunteering work, so it sometimes takes long time before it gets resolved)

In the meanwhile, I highly recommend trying to use the btGeneric6DofSpring2Constraint. It is more configurable and the spring is easier to control.

If I would be creating vehicles myself, I would use btMultiBody in combination with the URDF loader.
But that may be more work than you want to put into. btMultiBody would also let you create the tank with large mass ratios, something you tried in the past.

Re: Hinge2 damping

Posted: Mon Nov 19, 2018 10:48 pm
by bram

Re: Hinge2 damping

Posted: Tue Nov 20, 2018 5:51 pm
by bram
Erwin Coumans wrote: Mon Nov 19, 2018 9:48 pm In the meanwhile, I highly recommend trying to use the btGeneric6DofSpring2Constraint. It is more configurable and the spring is easier to control.
I tried btGeneric6DofSpring2Constraint, which exhibits the same never ending oscillation as the Hinge2 does.
Which I think is to be expected, because Hinge2 derives from this very class?

Also, the 6Dof constraint also explodes on me, after a while, whereas the Hinge2 did not?
So maybe I'm using it wrong.