[ODE] Character control
Sami Kyostila
skyostil at kempele.fi
Tue Jul 22 02:32:02 2003
Hi!
On Mon, 21 Jul 2003, Troy Chard wrote:
> I think it may be a little non-trivial, but would be curious if others have
> ideas on this.
I've been stuck on this problem for a while now too. I've attempted to get
a basic ragdoll (much like the one that comes with Juice, or Porrasturvat
:) to stand and walk around some world geometry. The first thing I
realized after some experimenting was that I wasn't going to get the thing
to stand upon its own feet, at least not without cheating.
So what I did was create an invisible sphere at the ragdoll's feet and
attach that to its spine with a ball joint. The sphere acted like a
unicycle wheel for the doll to ride on.
The next step was to get the doll to keep from falling over. I solved this
by creating a bunch of constraints for differents parts of the ragdoll,
e.g. "the head should be here", "the left hand should be here", "the right
knee should be here", etc. and for each timestep I used a more or less
standard PID controller (some background here:
http://members.aol.com/pidcontrol/pid_algorithm.html) to figure out the
forces to add to each constrained body to eventually bring them where they
should be.
Here's where I ran into some trouble. The whole ragdoll kept oscillating
violently. I think there was something wrong with my force calculations,
as the PID should take care of easing the bodies into position. However, I
took the easy way out and added some dampening in the spirit of
body.addLinearVelocity(body.getLinearVelocity()*-linearFactor);
and
body.addTorque(body.getAngularVelocity()*-angularFactor);
This worked fine most of the time, but in some nasty situations the
ragdoll would get a bad case of spontaneous combustion, i.e. it simply
exploded to infinity. This happened almost immediately if the angular
dampening factor above was anything significantly above zero. If I took
out the angular dampening, things were more stable but some parts
(especially the capped cylinders) of the ragdoll started spinning around
at great speeds, which isn't a problem until the spinning part hits some
other geometry and the guy blows up again.
I think this system might work if universal joints were used instead of
balljoints in places like the elbows and shoulders (to counter the
spinning), but I haven't had a chance to try that out yet.
This certainly isn't an easy problem, but solving it in a sufficiently
stable and realistic manner would bring a lot to the world of physically
accurate gaming (and why not other simulation as well). I'd love to hear
how other people have approached this problem.
- Sami Kyöstilä