[ODE] Combining (low-level) physical simulation and (high-level) AI/user control (long text :-)

Bertram Dieterich bertram.dieterich at gmx.de
Sat Feb 5 11:09:41 MST 2005


I am new to simulated physics in general, but I'am about to write some game stuff for which I thought ODE might 
be of some use. I will describe a bit what I want to do and which ideas I have in mind. I know the text is quite 
long and not exactly about ODE (but a physics sim problem in general). But if there's anyone who is willing to 
share his opinion on this topic with me (or maybe even wants to enter a discussion of the topic), I would be very 
glad.

Ahem:
Since this mail isn't directly ODE related, I understand that maybe this newsletter is the wrong place to pose my 
problem. I don't want to take the valuable time of those, who commit their anyway scarce spare time to supporting 
the ODE community, from those who need help with truely ODE related problems. So if you realize at some point 
that you're not interested in this mail, feel free to skip it anytime :-)


What I want to have is a character, whose motion is controlled by a human player. As far as I understand, this 
usually is achieved by dividing the character's body into body parts (and the connecting joints) and playing some 
wireframe animation depending on the user input. I.e. like the "jump" key in a first person shooter that will, 
depending on the characters forward speed, just play one out of two or three pre-recorded jump animations. Doing 
all this seems to be trivial.

However, I also want the body to react "physically" to external influences that are out of the human player's 
control. For example, the character gets hit into the leg while running ... this will possibly throw him 
offbalance. Ideally he will try to regain balance by setting his feet differently for the next steps or, if the 
hit was to hard, will stumble and fall to the ground. At least the last could theoretically be achieved by 
applying a physics simulation like ODE.

Now the problem is to combine the two requirements: human (or AI) controlled movement AND correctly simulated 
physics.

Although I cannot believe that the idea is totally new, I havn't yet seen it in any PC game. Normally, computer 
games restrict the possible motions of their characters to a very limited set of pre-defined animations. Even 
games that are quite fond of their physic engines (like HalfLife2) simulate physical influence only to lifeless 
bodies, thus avoiding the problem of combining simulation results with an intendet target posture. But I want to 
write some small fantasy swordfight simulation in which throwing the opponent off-balance or beating aside his 
shield arm should be legitimate moves.

Now I'm kind of mentally stuck since all I managed to come up with are the following two ideas:

1. Pure simulation:
Letting the character's posture completely to the physics engine. This would surely produce good results as to 
the reaction to external influences (like the oppontents weapon). On the other hand, it requires that the motion 
control works only by applying forces to the simulated body parts (thus simulating the muscles). There, some kind 
of AI is required that translates the players input into muscle stimuli. I can imagine that it is difficult to 
keep a human upright against gravity just by applying muscle forces, let alone to have him moving around at the 
same time as being punched by an enemy at the same time as wielding his own weapon. I guess this is a very hard 
AI task.

2. The string puppet aproach:
One could play pre-recorded animation. But instead of directly playing it on the character body, it is played on 
an invisible double (the "puppet master"). At the same time, there exists a characters body that is e.g. 
simulated by ODE. The simulated body is then attached to the puppet master by joints with some "spring" 
behaviour, i.e. the ODE body is dragged around by the puppet master, thus inducing the animation into the ODE 
body. Now, if external forces add to this, the ODE body parts are no longer able to follow the animation (since 
the springs are not stong enough to attract them "at all costs") and the springs will somehow "break", switching 
the body into pure simulation when it falls.
Problem here is: when/how will the body ever be re-attached to the animation double? And wouldn't it behave 
rather strangely, one second having elf-like elegance, the next moment behaving like a rag doll?

Currently I'm favoring the first approach in combination with some external stabilizer, that will be able to 
directly apply external forces in order to correct for AI insufficencies (e.g. some small force that tends to 
drag the body into upright posture and thus keep it from "stumbling over its own feet" while running).

Do I completely miss a different, maybe more promising approach? Has anyone ever done AI for walking/running of 
two-legged creatures and can tell me how stable it can be done? Any "black magic", that allows to increase 
stability at the expense of physical correctness? Anyone interested in the same topic, just wanting to share 
thoughts or even work together on it?

bye
Bertram Dieterich




More information about the ODE mailing list