[SOLVED] Vehicle class stability and other issues

chuddle

03-09-2007 21:52:43

I think I'm going to implement my own basic vehicle, as I don't need the additional elements in the OgreNewt::Vehicle class, but maybe someone can correct my errors while I'm here.

In the first image we've got a basic forklift (minus mast/carriage etc, we'll get to that further down). It's sitting pretty in front of some i beams, drops from a height and settles in on the suspension with no problems.

Mass of the body is 1000, mas of tires 50, dampening is 30 and springs at 200.

Body inertia is a cylinder .5 radius, 1 in length. Center of mass is at the object origin (bottom of body in the center).



In the second image I apply a torque of 0.8. The wheels completely come apart on me - splatting all over the place.

I set up a material pair between the body and the surface of .7/.3 static /dynamic, have tweaked that up and down and removed with no differences.



The third image is a different issue - we've got no torque in place here, but rather have added the mast on the front of the lift truck. Mast mass is 5, inertia is a cylinder .25 radius x .5 length, centered in the geometric center of the mast.

Interestingly, if I up the body's mass to 2000, the same thing still happens. I've moved the body's center of mass all the way to the back with a mass of 2000, at which point it almost remains balanced. When upping the mass to 3000 in that situation the tires come unglued and the thing spins through the air in a perpetial-motion flying machine imitation.

I've upped the mast mass to 100 and brought the body down to 1000 wondering if it was a relative mass issue.

also note that I've had a mast mass of 50 and body of 2000 working nicely together before I turned this thing into an OgreNewt::Vehicle.

Any suggestions or rules of thumb on heavier vehicles with offset masses?



I've worked the spring stiffness up to 3000 and the damping up to 300 with similar results (i.e. the wheels come apart on me). I'm assuming there's a fundamental bit that I'm missing.

I can post the code particulars later if they'll prove useful. I think I'm going to start working on a slightly more vehicle implementation of my own for higher mass low speed/ little/no suspension vehicles.

Would appreciate any pointers!

(editing to put "solved")

walaber

03-09-2007 22:19:31

a few pointers.

1. don't use cylinder for calculating inertia. use the newton functions to calculate it for you (convexcollision->calculateInertiaMatrix()).

you can even do this on a compoundcollision, as long as all elements are convex parts.

this will return 2 vectors. 1 for inertia, and one that give you the offset from the local origin to the geometrical center of mass.

then you can do
setMassMatrix( mass, inertia * mass );

and
setCenterOfMass( offset );



also, it looks like the pin for your tires is wrong, and they are rotating around the wrong axis.

chuddle

05-09-2007 06:35:04

Thanks! It all works now. Using calculateInertiaMatrix cleared balance things up perfectly.

And the pin - you were right - I had an uninitialized value kicking around :oops:

Many thanks!

Now I'm working out a buoyancy issue - may have to post for help if I don't get it in another few days...