[ODE] Self Righting Boxes (on castors)

Nate W coding at natew.com
Wed Oct 30 12:44:01 2002


On Wed, 30 Oct 2002, Ed Jones wrote:

> The "castorbox people" fall over quite regularly, which is fine and all 
> part of the "fun". But what I'd like to do is, after a couple of seconds 
> of lying down, get them to spring back up to their feet of their own 
> accord. Obviously I can just reset the little fella to be the right way 
> up but I'd like it to look more like they're jumping back up themselves.
> 
> Anyone got any ideas of what would be a good (and preferably simple!) 
> way to achieve this?

How about using an angular motor?
http://q12.org/ode/ode-latest-userguide.html#ref56

Set the motor to have one axis, and set one of the motor's bodies to the
"castorperson" body and set the other to null.  Use dJointSetAMotorParam
to set a desired (angular) velocity.  That should rotate the person
upright.  

To come up with a desired velocity, get the angle between the person's
current orientation and the desired "upright" vector.  Multiply that angle
by a "gain" factor.  To tune the way the people get upright, you can tune
the gain, the maximum force, the people's mass, gravity, etc.  When the
person's angular velocity gets close to zero, you can probably consider
them upright and turn off the angular motor.  

I haven't actually used angular motors yet in my own code, so this is as
much a question as a suggestion.  If anyone has other ideas I'm all ears.

-- 

Nate Waddoups
Redmond WA USA
http://www.natew.com