Crowd Simulations Sashi Kumar Penta Robotics – Class Presentation The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Overview • Motivation • Background • Behavior Planning for Character Animation, Kuffner et.al, Symposium on Computer Animation 2005 • Continuum Crowds, Adrein et.al, SIGGRAPH 2006 • Summary 2 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Motivation • Crowds are every where!! • Motivating video Clip • Movies ♦ The Chronicles of Nornia – The witch, The Lion and The ward robe ♦ The Lord of the ring ♦ I, Robot, etc 3 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Applications Courtesy: Illknur • Entertainment industry (animation production, computer games) • Training of police & military (demonstrations, riots handling) • Architecture (planning of buildings, towns, visualization) • Safety science (evacuation of buildings, ships, airplanes) • Sociology (crowd behavior) • Transportation research for urban planning 4 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Background • Motion-graph approaches ♦ [Gleicher et. al TOG 2003] ♦ [Kuffner et. al SCA 2005] • Static potential fields ♦ [Kirchner 2002] • Continuous density field ♦ [Hughes 2003] ♦ [Adrien et. al SIGGRAPH 2006] 5 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Behavior Planning for Character Animation, Kuffner et.al, SCA 2005 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Abstract • Automatically generate realistic motions for animated characters • Motion clips - amount FSM -ofmovements From small data of a virtual character • Global search of the FSM – a sequence of behaviors for the character 7 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Behavior Finite-State Machine • Behavior FSM defines movement capabilities of the character • Each state consists of a collection of motion clips that represent a highlevel behavior • Each directed edge represents a possible transition b/w two behaviors • There can be multiple motion clips with in a state. 8 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Environment Abstraction • Environment as a 2D height-field gridmap • Gridmap also encodes ♦ Obstacles that the character should avoid ♦ Free space where character can navigate ♦ Information about special obstacles such as an archway • Height value is used so that we can represent terrains with slopes or hills. • Virtual character is bounded by a cylinder with radius r & position is the center of the cylinder 9 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Data structures • A tree with nodes that record explored states in the FSM ♦ Each node in the tree stores the motion clip, position, orientation, time and cost • Priority queue of FSM states ordered by cost, which represent potential nodes to be expanding during the next search iteration 10 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL A* - search • Total cost = ( cost of the path up to that node) + (expected cost to reach the goal) • Using A*-search, The planner iteratively expands the lowest cost node in the queue until either the a solution is found or the queue is empty. 11 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL ALGORITHM 1: BEHAVIOR PLANNER FunctionFTreturns takes the input Function set of Function G determinesthe if we state sA an action a as in and actions that theas character should expand Snext a and returns the isparameters allowed take from sbest child of sbest intothe tree. output state sout 12 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Motion Generation & Blending • Search algorithm returns a sequence of behaviors • Sequence is converted into an actual motion for the character • Blending: to smooth out any slight discontinuities where the transitions b/w behaviors occur. 13 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Advantages • • • • • • 14 Scalability Memory Usage Intuitive Structure Generality Optimality Anytime The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Limitations • This technique requires an existence of a behavior FSM • This technique expects the data has been appropriately segmented & categorized 15 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Results 16 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL 17 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL What needs to be taken care … ♦ Individual human motion ♦ Environmental constraints ♦ Intelligent path planning Large group of people exhibit behavior of enormous complexity and subtlety. ♦ Dynamic interactions between people 18 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Previous methods • Agent based methods ♦ Funge et al. [1999] ♦ Shao and Terzopoulos [2005] ♦ Massive Software [2006] • Graph based techniques ♦ Bayazit et al. [2002] ♦ Kuffner et al. [2005] • Static potential fields ♦ Goldeinstein et al. [2001] • Continuous density field ♦ Hughes [2002] ♦ Adrien et. al [2006] 19 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Agent based methods • Pros ♦ Operate with each individual making independent decisions ♦ Capture each person’s unique situation: visibility, proximity of other pedestrians, etc ♦ Different simulation parameter may be defined for each crowd member • Cons ♦ Computationally expensive ♦ Difficult to develop behavioral rules that consistently produce realistic motion 20 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Key points • Real-time crowd model based on Dynamic potential field continuum dynamics • Global navigation with moving Interactive rates obstacles such as other people Smooth flow • Motion of large crowds without need for explicit collision Emergent phenomena avoidance 21 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL The Governing Equations • Hypothesis 1: ♦ Each person is trying to reach a geographic goal G R2 • Hypothesis 2: ♦ People move at the maximum speed possible. ♦ Maximum speed field f ♦ Where • Hypothesis 3: ♦ There exist a discomfort field g so that, people would prefer to be a point x rather than x’ if g(x’) > g(x) 22 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Tying together – Hypothesis 4 • People choose paths so as to minimize a linear combination of ♦ The length of the path ♦ The amount of time to the destination ♦ The discomfort felt, per unit time, along the path • Hypothesis 4: ♦ A path P that minimizes 23 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Optimal path Computation • Suppose, Cost function every where equal to the cost of the optimal path to the goal. • Optimal strategy: to move the opposite the gradient of this function. • Potential function ( ) : by following set of all optimal paths outwards from the goal. ♦ In the goal ♦ Every where, 24 =0 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Speed field • Speed is a density-dependent variable • Crowd density field • Low density (< min): depends on slope • High density (> max): depends vel of crowd • Medium density (> min ; < max) 25 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Models of the future • Predictive discomfort ♦ Future path planning through a constantly updated static view of environment. • Expected periodic changes ♦ When the field deterministically changes over time 26 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Algorithm • For each time step: ♦ Convert the crowd to a density field. ♦ For each group: • Construct the unit cost field C. • Construct the potential and it’s gradient • Update the people’s locations ♦ Enforce the minimum distance between people 27 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Implementation details • Physical fields as 2D arrays of floating point numbers. ♦ Scalar fields : defined at the center of each grid cell • Its true for average velocity ( ), stored as pair of floats ♦ Anisotropic fields : those depend on both position and direction • Stored with four floats per cell corresponding to = {0o, 90o, 180o, 270o} , i.e. EAST, NORTH, WEST and SOUTH faces of each cell 28 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Density Conversion • • “Splat” the crowd particles onto a density grid, to compute speed field which are dependent on density Requirements of density function 1. Must be continuous w.r.t location of the people ♦ to avoid sharp discontinuities in density and subsequently to the speed 2. Each person should contribute no less than to their own grid cell, but no more than to any neighboring grid cell ♦ 29 to ensure each individual is not affected by its own contribution to the density field The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Density Conversion ctd.. • For each person, we find the closest cell center whose coordinates are both less than that of the person • Relative coordinates of that person w.r.t the cell center • Person’s density then added to the grid as 30 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Unit cost field • Compute speed field f • Then calculate cost field C using • f and C are anisotropic ♦ We would evaluate the speed and discomfort at the cell into which the person would be moving if they choose that direction 31 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Dynamic Potential Field • Constructing is the dynamic potential is the most complex and time consuming step of the algorithm Implicit eikonal equation – Solution • ♦ ♦ ♦ ♦ ♦ 32 Assign the potential field inside the goal to 0; include these cells in KNOWN cells; all other to UNKNOWN ; UNKNOWN cells adjacent to KNOWN cells are included in the CANDIDATE cells and we approximate at these locations by solving a finite difference approximation to The CANDIDATE cell with the lowest potential is then included in the KNOWN cells and its neighbors are introduced into the CANDIDATE set by re-approximating the potentials at these cells This process is repeated, propagating the KNOWN cells outwards from the goal until all cells are defined. HEAP DATA STRUCTURE : O(N log N) The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Finite difference approximation • First find the less costly adjacent grid cell along the both x- and y-axis • Solve the equation for • Once we have computed , we take its difference with the neighboring grid cells in the upwind direction gives us • Renormalize the gradient, multiply by the speed in the appropriate directions to compute the velocity field at that point 33 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Crowd Advection • Once velocity field is known Each person’s position is displaced by their velocity, which is effectively computing an Euler integration to • Min displacement Enforcement ♦ All pairs within a threshold distance, symmetrically pushed apart so that min distances are preserved 34 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL General Algorithm Overview Grids Density Potential Fields New positions Goal Boundary 35 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Results Video 36 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Contributions • Integrates both global navigation & local collision avoidance into one framework • Velocity dependent term: which induces lane formation • Distance based term: which stabilizes the flow • Complexity depend on the number of grid cells 37 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Limitations • • • • • Complex heterogeneous motion Individual path planning Depends on the number of groups Depends on the resolution Approximations ♦ Dynamic potential field ♦ Minimum distance enforcement to remove visual unpleasant artifacts 38 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL What remains challenging • Individual behavior planning in crowds • Inertia – walking & running ♦ 4D eikonal equation (Position and Velocity) • Potential function across nonuniform grids for speed up ♦ Sparse data points in areas with few people ♦ Finer discretizations in areas of congestion 39 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Summary • Behavior planning approach to automatically generate realistic motions for animated characters • Crowd simulation framework based on a continuum perspective 40 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Questions? 41 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Thank you!! 42 The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL