learning motion: evolutionary techniques for developing character controllers
Think "Dead or Alive 3" with realistic game physics--when you punch your opponent in the chest, they actually lurch back to remain balanced rather than cut to a mocap sequence.
I am attempting to solve this problem using a variety of evolutionary programming techniques. My first attempt used a static neural network with weights decided by a genetic algorithm. My second attempt used a virtual register machine with an extremely reduced linear instruction set with operations decided by a genetic algorithm. In the near future I hope to attempt an evolutionary technique that develops a neural network by evolving not only the weights but also the structure. I also hope to try a non-linear instruction set virtual register machine.
Today, my research is showing some promise but is far from complete. Using the first technique (above) I have successfully developed a controller for a simple 2 DOF character that can balance itself, but it is far from robust enough to handle the "harsh" environments I hope to put it through. You can read more about my current status more below.
In all of the related work that I have found, we are yet to see a robust, realistic looking controller that can survive in a "harsh" environment. Existing work today appears to rely on precise initial conditions and no external forces being applied to the character.
05.17.04 : Give 100 monkeys 100 generations...
I also scrapped my neural network code and rewrote it all. Doesn't work any better, but now I'm modeling the network as a directed graph, so eventually I'll be able to evolve the structure of the network a la Karl Sims' paper. I also added support for different activation functions, I think eventually I'll want to throw in some sine neurons instead of just sigmoids. (Yup, Sims did that too)..
I have a cool demo to share now, this video shows 100 agents all trying to remain standing. Their fitness function is the height at which they are standing. The robot with the best fitness is highlighted in green. Their neural network is a simple recurrent network with two outputs: knee and ankle torque (scaled from 0..1 to -2500..2500) and six inputs: knee angle (-Pi..Pi), ankle angle (-Pi..Pi), current height (0..inf), "touching" the ground (-10 or 10), and the previous knee and ankle torques the net choose to apply (0..1). Figuring out these input ranges took hours and hours of guesswork and observation. Eventually when I get around to the "evolutionary" part of this project I'll start evolving these I suppose. Here's the video.
I also have a rough draft of my presentation.
05.07.04 : Wheeled robots and a framework for neural networks
Next I wrote a small framework for handling neural nets. Never written a neural network program before, but it didn't seem that hard so I just flipped open my AI book and started coding. I created a base class NNode to represent a neuron and a class NNetwork that stores a multi-dimensional array of NNode's. I simply hard-coded NNode to have a fixed number of inputs (100) and initialized them all to 0.0, so no matter what the weights these inputs won't have any effect on the neuron until given an input other than 0.0.
I'm new to neural networks, and since I'm not writing a back-prop network I still don't have any idea if I did the neural network correctly. It's really tough to step through in a debugger and verify it's behaving correctly. I'm tempted to strip the code out, put it in it's own program, write a back-prop algorithm and test it properly, but, eh, that's more work. ;-)
Since I'm supposed to eventually drive the weights in the neural network using genetic programming, I designed the neural network so that the weight of an input on each neuron can be specified using an integer instead of a float/double. The integer is transformed using some constant to a floating point value usable by the neuron; I can also query the neuron for it's weights either as integers or the "true" floating point value. Using the integers I can query all of the neurons for their values and build up a big chromosome that represents all of the weights in the neural network.
Once I [thought I] had the neural network in place I constructed what I thought would be a simple task of building a small robotic model. I started with two wheels hooked together with a big board connecting them at the front of the board. I thought what would happen would be the wheels would move and drag the end of the board around behind it. What ended up happening wasn't at all what I expected. No matter how I tweaked the collision parameters with ODE the board that was supposed to cause drag on the robot bounced repeatedly until it violently bounced the robot over onto it's other side. Sadly, the system seemed to mysteriously gain bouce the more I moved it until it would bounce over so much it would fly out of the simulation (pos = #inf) and then crash ODE.
I tried several other approaches using two wheels and the only one that seemed to work at all was to have three wheels -- two big ones in the front and a small balancing wheel in the back. The small wheel in the back would prevent the center block from colliding with the ground; this made the simulation much more stable. I also had to simulate the wheels not as cylinders but as spheres; many people on the ODE mailing lists suggested spheres work better for this application. But now I had a new problem: the robot could move forward and backward, but couldn't turn! For reasons beyond me I could not get ODE to simulate the friction that occurs when the wheels rotate in opposite directions, which should intuitively rotate the robot. It didn't. Instead the robot would just sit there frozen, and then jump up and fly out of the simulation to infinity, and crash. Sigh.
This week I scrapped the wheeled robot approach and I'm trying to build a robot that consists of three blocks with two hinge motors connected them. I'm having little success so far, but I think I can get it to work. I'm not handling collision detection between the blocks, whenever I try and simulate that they start bouncing wildly until the simulation crashes. Sigh. Sigh.
05.01.04 : The beginning of a new project...
A new area in computer animation that is beginning to become popular is interacting motion captured movement with physically simulated movement. ``Rag-doll physics'' used in many video games (Unreal Tournment, Half-Life, etc.) involve using motion capture for the ``living'' character animation and then transitioning to a physically simulated character when the character ``dies,'' to give a more life-like feel to the character's suffering when their health meter went below zero. Real-time back-and-forth transitioning between physically simulated movement and motion capture movement is an area the author is yet to see in computer animation, for example, transitioning to physically simulated movement every time the character takes damage, rather than only when they die. update: Michael Mandel is doing exactly this for his thesis at CMU.
A far more realistic approach to generating human character motion for computer animation would be to completely physically simulate all of the motion. Physical simulation of all character movement requires development of bones, joints, skin, muscles, and a ``virtual brain'' to accurately control the character. This approach has been tried with varying degrees of success by several groups over the last few years. Previous attempts have used genetic algorithms to evolve a neural network to control muscle movement. Other work has evolved even the creature itself.
For my project, I propose to evolve a bipedal articulated character that can walk. To develop this character I will create a dynamically sizable neural network to control the character muscles, described by an array of integers that will make up the chromosomes for genetic evolution. I will begin with a fixed-body creature (the body will not change between evolutions), but given time I would like to make the creature body itself evolving as in Sim's work. The character will live if a physically simulated environment using the Open Dynamics Engine.