Calculating torque force to self-right a rigid body

Started by
2 comments, last by bzroom 14 years ago
I have a rigid body that I want to keep upright, within some tolerance. The rigid body is a modelled as a vehicle using the Bullet physics engine, but the object itself isn't a vehicle, its actually an insect, just modelled as a vehicle for convenience. I would like to allow for a certain amount of 'wobble', but if the orientation does not match the ground orientation within some threshold, I want the body to self-right. My current method is to extract the 'up' vector from the body's centre of mass matrix, then cross product that with the ground 'up' vector and use that as the torque axis. However, then I run into the problem of what the magnitude of that torque should be. Either I set it too low and it can't overcome gravity/friction enough to self-right, or I set it too high and the body bounces all over the place like crazy. So my first question is, how do I determine the magnitude of the torque? The next, secondary, problem, is that I want to prefer rotation about the 'forward' axis of the body, so it rolls over sideways from it's belly to its feet/wheels. However, fixing the torque direction to the body's forward vector causes wild spinning behaviour...? Any hints, or links to relavant material, would be most appreciated,
Dave.
Advertisement
The magnitude of the force would be proportional to the sine of the angle between 'up' and your 'tilt' vector.

e.g, f = c sin(alpha)

You could use an empirical value for the constant, or you could work things out a little more accurately by calculating the force exerted on you model by gravity.
Quote:Original post by dangerdaveCS
My current method is to extract the 'up' vector from the body's centre of mass matrix, then cross product that with the ground 'up' vector and use that as the torque axis.


Y can try:
[torque] = Constant * [body's Up]^[World's Up]
where:
'^' is the cross product operator.
'Constant' is related to the body's inertia. I gess the product of the mass and the size of the body is a good start.
The control method is simple. You'll just need to tune the parameters carefully. Either analytically or through experimentation.

This is not an easy thing to have feel natural in a game.

This topic is closed to new replies.

Advertisement