Simple Spring

Bbilz
Posts: 26
Joined: Wed Feb 27, 2008 9:55 am

Simple Spring

Post by Bbilz »

Hi,

Just saw the new btSliderConstraint, and I was wondering if it would it be sensible to extend this with some spring forces to make a simple spring constraint?

I am looking at btRaycastVehicle, and I need the wheels themselves to physically interact with the world.
I am thinking rigid body wheels connected to a chassis by this simple spring constraint, and any driving forces they generate being applied directly to the chassis.
Is that crazy talk?

Thanks!

-bbilz
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Simple Spring

Post by Erwin Coumans »

Bbilz wrote:Hi,
Just saw the new btSliderConstraint, and I was wondering if it would it be sensible to extend this with some spring forces to make a simple spring constraint?
I am looking at btRaycastVehicle, and I need the wheels themselves to physically interact with the world.
I am thinking rigid body wheels connected to a chassis by this simple spring constraint, and any driving forces they generate being applied directly to the chassis.
Using 'real' wheels for vehicles usually doesn't work very well, because real wheels are not rigid but soft. When using a rigid body for a wheel, some additional logic has to be added, to prevent huge impact when hitting street curbs etc. Even worse, rigid body wheels rotating at high velocity don't behave well in simulation, the friction model is not appropriate to model tyres.

You can add a spring force to the slider constraint. It is also possible to use a 'cylinder' cast (see ConcaveConvexcastDemo and replace the box by a btCylinderShape), instead of a ray cast, to have more accurate wheel interaction with the world. Then you have to manually filter/disable contacts that affect driving in a bad way.

Hope this helps,
Erwin
Bbilz
Posts: 26
Joined: Wed Feb 27, 2008 9:55 am

Re: Simple Spring

Post by Bbilz »

I was thinking along the lines of having the wheels as frictionless cylinders bodies with no angular factor/forces/velocity.
I keep track of the contact points on the cylinders, and using the same logic as the btRaycastVehicle I apply forces to the chassis to drive the vehicle along.
Similarly lifting the wheel transform code from btRaycastVehicle I can then update a rotation matrix to simulate how the wheel should be rotating, if it was actually moving :)

I guess I just need to work through it, see what happens..

Thanks
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Simple Spring

Post by Erwin Coumans »

This is possible, just use some btCollisionObject with a btCylinderShape, disable response, and use the convexSweepTest, instead of the rayTestSingle. See ConcaveConvexcastDemo how to use this.

Hope this helps,
Erwin
Nico65
Posts: 8
Joined: Mon Apr 14, 2008 1:48 pm

Re: Simple Spring

Post by Nico65 »

I actually modeled a car on springs (see my McPherson post) without "cheating" and using bullet constraints. The car is unstable and explode when the string apply too much forces on the arms & chassis, which it sooner or later needs to unless you're driving on a plane surface. I did that because I was at first not convinced by the Vehicle demo, however it does look ok in bullet 2.68 in the end I think it might well turn out to be an acceptable compromise. Yet the "friction model" of the raycast vehicule is terrible...
Youne
Posts: 40
Joined: Sun Jan 27, 2008 2:55 pm

btSliderConstraint

Post by Youne »

Hi,

Qucik question : How do we designate the axe of translation for the two rigidbodies when we use btsliderconstraint to construct a slider between two rigidbodies ?


thanks you

Youne