The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Crowd Simulations Sashi Kumar Penta Robotics – Class Presentation
Dec 30, 2015
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Crowd Simulations
Sashi Kumar Penta
Robotics – Class Presentation
2The 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
3The 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
4The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Applications
• 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
Courtesy: Illknur
5The 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]
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Behavior Planning for Character Animation,
Kuffner et.al, SCA 2005
7The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Abstract
• Automatically generate realistic motions for animated characters
• Motion clips - FSM - movements of a virtual character
• Global search of the FSM – a sequence of behaviors for the character
From small amount of data
Scales to large motion DBs
Flexi
ble fr
amew
ork
Sta
tic/D
ynam
ic e
nvir
onm
ents
8The 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 high-level behavior
• Each directed edge represents a possible transition b/w two behaviors
• There can be multiple motion clips with in a state.
9The 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
10The 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
11The 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.
12The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
ALGORITHM 1: BEHAVIOR PLANNER
Function F returns the set of actions A that the character is allowed to take from sbest
Function T takes the input state sin and an action a as parameters and returns the output state sout
Function G determines if we should expand Snext as a child of sbest in the tree.
13The 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.
14The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Advantages
• Scalability• Memory Usage• Intuitive Structure• Generality• Optimality• Anytime
15The 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
18The 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
19The 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]
20The 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
21The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
• Real-time crowd model based on continuum dynamics
• Global navigation with moving obstacles such as other people
• Motion of large crowds without need for explicit collision avoidance
Key points
Dynamic potential field
Interactive rates
Smooth flow
Emergent phenomena
22The 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)
23The 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
24The 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 = 0♦ Every where,
25The 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)
26The 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
27The 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
28The 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
29The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
• “Splat” the crowd particles onto a density grid, to compute speed field which are dependent on density
• Requirements of density function1. 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♦ to ensure each individual is not affected by its own
contribution to the density field
Density Conversion
30The 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
31The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
• 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
Unit cost field
32The 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♦ 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)
33The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
• 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
Finite difference approximation
34The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Crowd Advection
• Once velocity field is knownEach 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
35The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
General Algorithm OverviewGrids
Potential Fields New positionsDensity
Goal
Boundary
37The 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
38The 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
39The 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
40The 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