Sign in to follow this  

Calculating torque force to self-right a rigid body

This topic is 2820 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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,

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

This topic is 2820 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this