# Calculating torque force to self-right a rigid body

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

## 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 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 on other sites
Quote:
 Original post by dangerdaveCSMy 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 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.

1. 1
2. 2
3. 3
Rutin
21
4. 4
5. 5
gaxio
10

• 14
• 30
• 13
• 11
• 11
• ### Forum Statistics

• Total Topics
631777
• Total Posts
3002308
×