1
Animation of Articulated Figuresusing Genetic Programming
Logistics
Assignments Checkpoint 1 -- Framework
Feedback for all (mycourses or mail) Except those who used Python.
Checkpoint 2 -- Problem statement Will look at starting this evening
Checkpoint 3 -- Genotype / Phenotype Due January 18
2
Logistics
Grad Report Will need topics first week after we return
from break (Jan 11th). That’s tonight. Dropbox in mycourses
Final exam date
Final exam date has been announced:
Tuesday, February 27, 2007 10:15am - 12:15pm 70-1435
3
Project Presentation Approx Presentations:
Dates: Week 9: Thurs, Feb 15 Week 10: Tues, Feb 20 Finals Week: Tues, Feb 27 (2:45-4:45)
15 minutes / presentation Schedule now on Web Please send me choice of time/day
Plan for today
Our first application: Animation of Articulated Figure using
Genetic Programming.
Questions before we start
4
Evolutionary Algorithms An EA uses some mechanisms inspired by biological evolution:
reproduction, mutation, recombination, natural selection andsurvival of the fittest.
Candidate solutions to the optimization problem play the role ofindividuals in a population, and the cost function determines theenvironment within which the solutions "live".
Evolution of the population then takes place after the repeatedapplication of the above operators.
Evolutionary Computationprocess
Initializepopulation
Select individuals forcrossover (based onfitness function
Crossover
Mutation
Insert new offspringinto population
Are stopping criteriasatisfied?
Finish
5
Genetic Programming What is it?
Genetic programming (GP) is anautomated method for creating a workingcomputer program from a high-levelproblem statement of a problem.
Genetic programming starts from a high-level statement of “what needs to be done”and automatically creates a computerprogram to solve the problem.
Genetic Programming
In genetic programming: Problem -- involves not finding a solution,
but instead creating a program that canfind the best solution.
Phenotype (solution) is a computerprogram
Search space is the set of all possiblecomputer programs.
6
Genetic Programming
In Koza’s original work LISP was used as the programming
language Parse trees were used as the genotype.
Straight-forward genetic mapping Functional program --> parse tree.
Defining your problem For programs to be be evolved, must define:
Terminal Set Leaves of the parse tree Correspond to program inputs
Function Set Interior nodes of parse tree Set of functions allowable in program Should be chosen with relation to problem to be solved. Can have side effects.
7
Defining your problem Sufficiency and Closure
Sufficiency terminals + functions must be able to solve the
problem at hand Choose your terminal and function set wisely
Closure Functions should be able to accept as
argument any value returned by otherfunctions
Universal return type.
GPs: Crossover and Mutation
Before crossover
After crossover
crossover mutation
Before mutation
After mutation
Note that operation maintain validindividuals.
8
Fitness Evaluate the effectiveness of the
program to solve the problem
Two stage fitness: Run resultant program Compare to correct / desired results
Questions…
Definition of animation
an·i·ma·tion (n)a motion picture made from a series ofdrawings simulating motion by means ofslight progressive changes in the drawings
9
Problem in animation For each object in your scene
For each frame generated Must define position / orientation of the object.
Each controllable parameter is a degreeof freedom
Degree of Freedom problem 3 objects 1 minute animation
30 frames / second 30 frames x 60 seconds = 1800 frames Must define position and orientation of each
(12 degrees of freedom/object) = 36 degreesof freedom
1800 frames x 36 dof = 64,800 values
10
Animation
“There is no particular mystery inanimation…it’s really very simple, andlike anything that is simple, It is aboutthe hardest thing in the world to do”
-- Bill Tytla, Disney Animator, 1937
Articulated Figures
What is an articulated figure? A set of rigid objects connected by joints Individual joints are linked together in a
parent-child hierarchy Each object has a joint at one end where
any child bones may be attached. The skeleton
11
Articulated Figures
Joints Motion of articulated figures are determined by
providing the angle of rotation about each joint Any joint is only permitted to rotate about the three
local axes of its parent joint. However, you may wish to limit the extent of rotation
Disallow rotation about one of the axes Provide rotational constraints to a given axis.
12
Degrees of freedom
Degrees of freedom Number of parameters
whose values must bedefined in order to fullyposition the articulatedfigure
44 DOF: 38 (joint angles) + 6(position and orientation)
Our problem
Problem: For each time step, determine the values
of the degrees of freedom (joint anglerotations) to achieve a “desirable”animation.
Approach: Construct a program that will determine
these joint angles, with respect to time.
13
Our problem “Desirable” animation
Follow the laws of physics Achieve some predefined goal Don’t overexert useless energy “Natural poses”
To achieve physically accurate motion, go tothe source!
The Source: Sir Isaac Newton 1643-1727 Discovered
(amongst otherthings) Calculus Physics of Light Physics of Motion
Busy Man
14
Kinematics vs. Dynamics Kinematic control
Refers to motion of object irrespective of the forcesinvolved
Dynamic control Concerned with computing the underlying forces which
are then used to produce motion.
Problem with dynamics: How does one determine the correct forces that
will produce “desirable motion”
Our problem revisited Problem:
For each time step, determine the forcesrequired to produce values of the degreesof freedom (joint angle rotations) toachieve a “desirable” animation.
Approach: Construct a program, based on physical
dynamics, that will determine these jointangles, with respect to time.
15
Genetic Programming
In genetic programming: Problem -- involves not finding a solution,
but instead creating a program that canfind the best solution.
Phenotype (solution) is a computerprogram
Search space is the set of all possiblecomputer programs.
Two approaches
[Gritz, Hahn] -- Control motion of afixed hierarchy
[Sims] -- Evolution of virtual creatures
Papers on Web site
16
Genetic Programming for Articulated Figure Motion
System architecture:
Genetic Programming for Articulated Figure Motion
Classic Genetic Programming Genotype: parse tree Phenotype: LISP program Ideal Joint angles determined by mutated
control programs represented as parsetrees
17
Genetic Programming andAnimation
Introducing Dynamics Control programs actually define “desired”
joint angle Motion is determined by physical
simulation using simple spring model todetermine torques at joints
Genetic Programming andAnimation
Function set Arithmetic functions (+, -, *, %) Conditional (ifltz -- if less than zero)
(x < 0 ) ? expr1:expr2
Trig / Mathematical functions (cos, abs,etc).
18
Genetic Programming andAnimation
Terminal set: Internal state variables:
Position, velocity, current joint angle, forces Allowed for coupled motion.
time Ephemeral random constant.
Genetic Programming andanimation Fitness:
Primary Goal: Get from here to there Style points:
Penalty for violating safety rules Reward for speed Penalties for inefficient behaviour Rewards for ending in neutral position. Reward for minimizing energy consumption Other subgoals.
19
Example
Results
L*xo Learns to Limbo Main Goal:
Get from start to finish in time allotted
Style Points: Bonus for getting there early Penalty for motion after getting there. Penalty for hitting head or falling over Bonus for finishing at neutral position.
21
Genetic Programming andAnimation
Questions?
Break.
Taking Genetics to theExtreme
Sims (1994) Not only used GP as a means for defining
motion but also used it to evolve creaturesstructure.
22
Sims’ goal
Evolve virtual creatures that are suitedto obtaining a given goal in a givenenvironment.
Evolutionary Algorithm is used to defineboth: Morphology (structure) of creature Control (motion) of creature.
Genotype Directed graph. Each node represents a rigid part of the
creature. Dimensions Joint type (between this part and parent) Joint limits Recursive Limits Neurons
Each edge represents a potential link toanother part of the body.
23
Phenotype
Phenotype: “Smart” Articulated figure. -- hierarchy of
3D parts
Genetic Mapping: Use genome as guide to constructing
figure.
Creature Morphology
24
Creature Control
Each creature has a virtual brain: Accepts input sensor values Has access to internal neurons Produces output effector values
Sensors
Internal sensors Joint angle sensors
External sensors Contact sensors -- collisions Photo-sensors -- sensitive to simulated
light source.
25
Internal nuerons Mini-LISP like functions associated with
each node. Take input from other nodes Ships output to other nodes Sample of Function set:
+, *, /, >, sign, min, max, abs, if, interpolate.sin, cos, log, exp, sigmoid, integrate,differentiate, smooth, oscillate-sin, oscillate-sawtooth.
Effectors
Effectors controls joint forces on eachjoint Simulation is doing using dynamics. Can be connected to sensor or internal
neuron.
26
Genetic Mapping Each morphological genotype node contains a
neuron “program” which can have sensorsand effectors as terminals.
Neurons are generated with each body part. Connections are made between adjacent
parts in the hierarchy. Creature are also given neurons not
corresponding to any body part.
Genetic Mapping
27
Crossover
Mutation
Strategies: Internal parameters of individual nodes are
modified New random node added Edges are redirected New edges are added Same mutations can take place on
“neuron” programs.
28
Simulation
Creature motion is determined byphysical simulation. Effectors produce forces Environment contains external forces. Collision detection / response Friction, etc.
Fitness
Creatures are placed in an environmentand judged on success towards a giventask: Swimming -- locomotion in a viscous force
field Walking -- land locomotion Jumping -- judged on height Following -- a light source.
29
Selection Survival-ratio
Constant population size maintained. Percentage of population that will survive
to next generation Offspring fill rest of slots
Minimum fitness required.
Results
30
EAs and Animation
This is clearly a case where we’vecrossed the line between SolvingProblems and Simulating Evolution. Creatures, given a task, are evolved via
EAs to best perform the task. Functional control programs represented
and manipulated as parse trees Looks a lot like nature’s creatures.
Evolutionary Algorithms To use evolutionary algorithms your must:
Define your problem Define your genotype Identify your phenotype Define the genotype -> phenotype translation Define crossover and mutation operators Define fitness Determine selection criteria Set population parameters