crowd simulation - university of edinburghhomepages.inf.ed.ac.uk › tkomura › cav ›...

40
Crowd simulation Crowd simulation Taku Komura Taku Komura

Upload: others

Post on 06-Jul-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Crowd simulation - University of Edinburghhomepages.inf.ed.ac.uk › tkomura › cav › presentation9.pdf · 2012-02-14 · Three streams for crowd simulation Agent based Modelling

Crowd simulationCrowd simulation

Taku KomuraTaku Komura

Page 2: Crowd simulation - University of Edinburghhomepages.inf.ed.ac.uk › tkomura › cav › presentation9.pdf · 2012-02-14 · Three streams for crowd simulation Agent based Modelling

Animating Crowds Animating Crowds

�� We have been going through methods to We have been going through methods to simulate individual characters simulate individual characters �� What if we want to simulate the movement What if we want to simulate the movement

of crowds?of crowds?�� Pedestrians in the streetsPedestrians in the streets�� Pedestrians in the streetsPedestrians in the streets�� Flock of birds, school of fishesFlock of birds, school of fishes�� People in panic People in panic

Page 3: Crowd simulation - University of Edinburghhomepages.inf.ed.ac.uk › tkomura › cav › presentation9.pdf · 2012-02-14 · Three streams for crowd simulation Agent based Modelling

Why need a crowd simulation ?Why need a crowd simulation ?

�� Shooting scenes with many peopleShooting scenes with many people�� Expensive to hire many extra actorsExpensive to hire many extra actors

�� We don’t see the details : use simple computerWe don’t see the details : use simple computer--based models based models based models based models

�� Security reasons: Security reasons: �� Need to evaluate the safety of buildingsNeed to evaluate the safety of buildings

Page 4: Crowd simulation - University of Edinburghhomepages.inf.ed.ac.uk › tkomura › cav › presentation9.pdf · 2012-02-14 · Three streams for crowd simulation Agent based Modelling

Three streams for crowd Three streams for crowd simulationsimulation

�� Agent based Agent based �� Modelling each individualModelling each individual�� Simulate the movements of many individuals to make an effect of Simulate the movements of many individuals to make an effect of

crowdscrowds�� PatchPatch--based methods based methods

�� Create scenes by building blocks Create scenes by building blocks �� Using potential / vector fields Using potential / vector fields �� Using potential / vector fields Using potential / vector fields

�� Compute the potential field and determine the movements of Compute the potential field and determine the movements of characters based on dynamicscharacters based on dynamics

�� Most methods are Agent basedMost methods are Agent based

Page 5: Crowd simulation - University of Edinburghhomepages.inf.ed.ac.uk › tkomura › cav › presentation9.pdf · 2012-02-14 · Three streams for crowd simulation Agent based Modelling

Flocking Models Flocking Models –– Most basic Most basic agent model (Reynolds ’87)agent model (Reynolds ’87)�� The agents interact based on simple The agents interact based on simple

dynamicsdynamics�� Good to simulate Good to simulate

�� Flock of birds flying, Flock of birds flying, �� Flock of birds flying, Flock of birds flying, �� school of fishes swimmingschool of fishes swimming

Page 6: Crowd simulation - University of Edinburghhomepages.inf.ed.ac.uk › tkomura › cav › presentation9.pdf · 2012-02-14 · Three streams for crowd simulation Agent based Modelling

Forces applied to individualsForces applied to individuals

�Separation�Alignment�Cohesion �Avoidance�Avoidance

Page 7: Crowd simulation - University of Edinburghhomepages.inf.ed.ac.uk › tkomura › cav › presentation9.pdf · 2012-02-14 · Three streams for crowd simulation Agent based Modelling

SeparationSeparation

• Try to avoid running into local flock-mates– Use a perception volume to limit visible

flock-mates

– S : surrounding entities

ix

Separation:Fly away away from neighbors that are “too close”

∑∈

−−=

Si2

i

is

xx

xxF

x

Page 8: Crowd simulation - University of Edinburghhomepages.inf.ed.ac.uk › tkomura › cav › presentation9.pdf · 2012-02-14 · Three streams for crowd simulation Agent based Modelling

AlignmentAlignment

• Try to fly in same direction as local flock-mates– Gets everyone flying in the same

direction

Alignment: steer toward average velocity

( )∑∈

−=Si

A xxF i &&

ix&

x&

Page 9: Crowd simulation - University of Edinburghhomepages.inf.ed.ac.uk › tkomura › cav › presentation9.pdf · 2012-02-14 · Three streams for crowd simulation Agent based Modelling

CohesionCohesion

• Try to move toward the average position of local flock-mates– Spaces everyone out evenly,– keep boundary members toward the – keep boundary members toward the

group

Cohesion: steer toward average position

xx

F i −=∑∈

N

SiC N

ixx

Page 10: Crowd simulation - University of Edinburghhomepages.inf.ed.ac.uk › tkomura › cav › presentation9.pdf · 2012-02-14 · Three streams for crowd simulation Agent based Modelling

AvoidanceAvoidance

• Try to avoid obstacles– The closer the character is, the stronger the force

NF =

Avoidance: steer away from obstacles

O

x closest to is that

point at the obstacle theof vector normal the:

),(

x

N

xF

ODO =

N

Page 11: Crowd simulation - University of Edinburghhomepages.inf.ed.ac.uk › tkomura › cav › presentation9.pdf · 2012-02-14 · Three streams for crowd simulation Agent based Modelling

Combining CommandsCombining Commands

�� Consider commands as accelerationsConsider commands as accelerations

�� Give a weight to each desireGive a weight to each desire�� Ex. High for avoidance, low for cohesionEx. High for avoidance, low for cohesion

�� Option 1: Apply in order of highest weight, Option 1: Apply in order of highest weight, until a max acceleration is reacheduntil a max acceleration is reached�� Ensures that high priority things happenEnsures that high priority things happen

�� Option 2: Take weighted sum and truncate Option 2: Take weighted sum and truncate accelerationacceleration�� Makes sure some part of everything happensMakes sure some part of everything happens

http://www.youtube.com/watch?v=4kPSDW7gQHA

Page 12: Crowd simulation - University of Edinburghhomepages.inf.ed.ac.uk › tkomura › cav › presentation9.pdf · 2012-02-14 · Three streams for crowd simulation Agent based Modelling

Simulating dynamical features Simulating dynamical features of escape panic : Helbing ‘00of escape panic : Helbing ‘00

�� A particle system model to simulate the A particle system model to simulate the crowd under paniccrowd under panic

�� People rush towards the exitPeople rush towards the exit�� ffijij, the force to stay away from other , the force to stay away from other �� ffijij, the force to stay away from other , the force to stay away from other

entities,entities,�� ffiwiw the force to stay away from walls the force to stay away from walls �� : velocity of entity: velocity of entity ii�� : the desired velocity of entity: the desired velocity of entity iio

ioi ev

iv

http://www.youtube.com/watch?v=mUKYtOXg5Zw

Page 13: Crowd simulation - University of Edinburghhomepages.inf.ed.ac.uk › tkomura › cav › presentation9.pdf · 2012-02-14 · Three streams for crowd simulation Agent based Modelling

Flocking EvaluationFlocking Evaluation

�� Advantages:Advantages:�� Complex behavior from simple rulesComplex behavior from simple rules

�� Many types of behavior can be expressed Many types of behavior can be expressed with different rules and parameterswith different rules and parameters

�� Disadvantages:Disadvantages:�� Disadvantages:Disadvantages:�� Can be difficult to set parameters to achieve Can be difficult to set parameters to achieve

desired resultdesired result

�� Problems regarding strength of forcesProblems regarding strength of forces

Page 14: Crowd simulation - University of Edinburghhomepages.inf.ed.ac.uk › tkomura › cav › presentation9.pdf · 2012-02-14 · Three streams for crowd simulation Agent based Modelling

Making the Agents SmarterMaking the Agents Smarter

�Designing the details of the behaviours�What to do when you see a predator

�What to do when you find somebody you know? know?

�What to do when the traffic lights are red?

�Need to add more and more rules…

Page 15: Crowd simulation - University of Edinburghhomepages.inf.ed.ac.uk › tkomura › cav › presentation9.pdf · 2012-02-14 · Three streams for crowd simulation Agent based Modelling

Artificial FishArtificial Fish--Terzopoulos et al. SIGGRAPH ‘94Terzopoulos et al. SIGGRAPH ‘94

�� Adding further factors such as Adding further factors such as �� HungerHunger

�� Libido Libido

�� Fear Fear �� Fear Fear

for deciding the for deciding the behaviorbehavior of the fishof the fish

�� Adding sensory perception such asAdding sensory perception such as�� visionvision

Page 16: Crowd simulation - University of Edinburghhomepages.inf.ed.ac.uk › tkomura › cav › presentation9.pdf · 2012-02-14 · Three streams for crowd simulation Agent based Modelling

Intention Generator

1.First check the sensory information for collision

2. If any close predator, either

� Schooling

� Escape� Escape

� Otherwise if hungry eat

� If full mate

http://www.youtube.com/watch?v=RHt_8ZYQVZw

Page 17: Crowd simulation - University of Edinburghhomepages.inf.ed.ac.uk › tkomura › cav › presentation9.pdf · 2012-02-14 · Three streams for crowd simulation Agent based Modelling

Intention Generator

�� Decision making for the fishDecision making for the fish

Page 18: Crowd simulation - University of Edinburghhomepages.inf.ed.ac.uk › tkomura › cav › presentation9.pdf · 2012-02-14 · Three streams for crowd simulation Agent based Modelling

What about humans?What about humans?

�� Can do something similarCan do something similar�� But humans are a bit more high levelBut humans are a bit more high level

�� Not only eating or escapingNot only eating or escaping�� Have destinationsHave destinations�� Have destinationsHave destinations�� Contexts Contexts �� SocializingSocializing

��Grouping, Grouping, ��Talking to somebody you knowTalking to somebody you know

Just make a more (ad hoc) complex Just make a more (ad hoc) complex modelmodel

Page 19: Crowd simulation - University of Edinburghhomepages.inf.ed.ac.uk › tkomura › cav › presentation9.pdf · 2012-02-14 · Three streams for crowd simulation Agent based Modelling

Behavior model : Behavior model : Autonomous PedestriansAutonomous Pedestrians

�� More complex than a fishMore complex than a fish

http://www.youtube.com/watch?v=cqG7ADSvQ5ohttp://www.youtube.com/watch?v=cqG7ADSvQ5o

Page 20: Crowd simulation - University of Edinburghhomepages.inf.ed.ac.uk › tkomura › cav › presentation9.pdf · 2012-02-14 · Three streams for crowd simulation Agent based Modelling

More serious problems for More serious problems for humans : context humans : context

�� Interactions with the environmentInteractions with the environment�� Queuing and buying ticketsQueuing and buying tickets

�� Embed the motions into the environmentEmbed the motions into the environment�� patchpatch--based approachesbased approaches

�� Interactions with othersInteractions with others�� Interactions with othersInteractions with others�� Collision avoidance Collision avoidance

�� A bit more complex than fishesA bit more complex than fishes�� Create a more complex controller Create a more complex controller

�� Getting to the destination :Getting to the destination :�� use pathuse path--finding algorithms such as A* search finding algorithms such as A* search

(shortest route to the destination)(shortest route to the destination)

Page 21: Crowd simulation - University of Edinburghhomepages.inf.ed.ac.uk › tkomura › cav › presentation9.pdf · 2012-02-14 · Three streams for crowd simulation Agent based Modelling

Interactions with the Interactions with the EnvironmentEnvironment

� Examples� At bus stops, people stop and queue � At an elevator, people wait for it and ride on it when it comes and

travel to different floors

�� Long streets Long streets -- The characters should walk straight along the The characters should walk straight along the streetstreet

�� desk and a seat : walk and sit on the seat and face the deskdesk and a seat : walk and sit on the seat and face the desk

�� TV in the living room : turn on the TV and sit on the sofa to watch TV in the living room : turn on the TV and sit on the sofa to watch TVTV

� IDEA: associate such motions with the objects� Once the character comes across such objects, they launch the

associated motion

Page 22: Crowd simulation - University of Edinburghhomepages.inf.ed.ac.uk › tkomura › cav › presentation9.pdf · 2012-02-14 · Three streams for crowd simulation Agent based Modelling

Embedding motions into the Embedding motions into the environment : environment : Advantages of the approachAdvantages of the approach

�� Efficient data handlingEfficient data handling�� Each agent holds the data only needed at that Each agent holds the data only needed at that

momentmoment

�� The control is decentralized The control is decentralized �� The system is scalable, and large crowds can The system is scalable, and large crowds can

be simulatedbe simulated

Page 23: Crowd simulation - University of Edinburghhomepages.inf.ed.ac.uk › tkomura › cav › presentation9.pdf · 2012-02-14 · Three streams for crowd simulation Agent based Modelling

Interactions with othersInteractions with others

�� Flocks just walking do not look so realistic Flocks just walking do not look so realistic �� Interactions between the flocks make the animation more Interactions between the flocks make the animation more

lively and realistic lively and realistic �� Associate an input stimuli and an actionAssociate an input stimuli and an action

�� Find these using videos Find these using videos

�� At runtime, compute the probability of performing each At runtime, compute the probability of performing each �� At runtime, compute the probability of performing each At runtime, compute the probability of performing each action according to the stimuliaction according to the stimuli

http://www.youtube.com/watch?v=FA3y3fu5m2k

Page 24: Crowd simulation - University of Edinburghhomepages.inf.ed.ac.uk › tkomura › cav › presentation9.pdf · 2012-02-14 · Three streams for crowd simulation Agent based Modelling

PatchPatch--based approachesbased approaches

�� PrePre--compute the patches (building compute the patches (building blocks) which includes the characters blocks) which includes the characters and the environment and the environment

�� Concatenate them to generate large Concatenate them to generate large scale scenes during runtime scale scenes during runtime Motion PatchesMotion Patches�� Motion PatchesMotion Patches

�� Crowd patches Crowd patches

Page 25: Crowd simulation - University of Edinburghhomepages.inf.ed.ac.uk › tkomura › cav › presentation9.pdf · 2012-02-14 · Three streams for crowd simulation Agent based Modelling

Motion Patches Motion Patches

�� Building Blocks for Virtual EnvironmentsBuilding Blocks for Virtual Environments�� Embed the motions into the environmentEmbed the motions into the environment�� The patches are spatially alignedThe patches are spatially aligned

Page 26: Crowd simulation - University of Edinburghhomepages.inf.ed.ac.uk › tkomura › cav › presentation9.pdf · 2012-02-14 · Three streams for crowd simulation Agent based Modelling

Crowd PatchesCrowd Patches

�� A patchA patch--based approach to generate scenes of crowded based approach to generate scenes of crowded environmentenvironment

�� Crowds avoiding each other in the patches Crowds avoiding each other in the patches �� The timing and location the characters entering the patches The timing and location the characters entering the patches

are fixed so that the people can keep on entering / exiting are fixed so that the people can keep on entering / exiting �� The characters can be switched to make more variations The characters can be switched to make more variations �� The characters can be switched to make more variations The characters can be switched to make more variations

Page 27: Crowd simulation - University of Edinburghhomepages.inf.ed.ac.uk › tkomura › cav › presentation9.pdf · 2012-02-14 · Three streams for crowd simulation Agent based Modelling

Collision avoidanceCollision avoidance�� Humans avoid others in streets in a Humans avoid others in streets in a

complex waycomplex way�� Sometimes wait, sometimes, move aside Sometimes wait, sometimes, move aside

while walkingwhile walking�� Need to either Need to either Need to either Need to either

�� Model them based on a complex collision Model them based on a complex collision avoidance engine avoidance engine

�� Find a good mathematical model Find a good mathematical model

Page 28: Crowd simulation - University of Edinburghhomepages.inf.ed.ac.uk › tkomura › cav › presentation9.pdf · 2012-02-14 · Three streams for crowd simulation Agent based Modelling

Collision Avoidance :Collision Avoidance :Local vs. GlobalLocal vs. Global

�� Combining various adhoc rules do not work Combining various adhoc rules do not work so well (local model)so well (local model)

�� Need a good controller thatNeed a good controller that�� Considers the futureConsiders the futureConsiders the futureConsiders the future�� Finds an optimal path for avoidance Finds an optimal path for avoidance

to simulate this effect well (global model)to simulate this effect well (global model)

Page 29: Crowd simulation - University of Edinburghhomepages.inf.ed.ac.uk › tkomura › cav › presentation9.pdf · 2012-02-14 · Three streams for crowd simulation Agent based Modelling

Continuum CrowdsContinuum Crowds

�� Solving the pathSolving the path--planning and collision planning and collision avoidance at the same time avoidance at the same time

1.1. Compute the potential field at every time Compute the potential field at every time stepstepstepstep

�� Based on the other avatars and obstaclesBased on the other avatars and obstacles�� The goal location The goal location

2.2. The character’s movement determined The character’s movement determined based on the potential fieldbased on the potential field

3.3. Update the potential fieldUpdate the potential field

Page 30: Crowd simulation - University of Edinburghhomepages.inf.ed.ac.uk › tkomura › cav › presentation9.pdf · 2012-02-14 · Three streams for crowd simulation Agent based Modelling

Continuum Crowds : Continuum Crowds : procedure procedure

�� Discretize the space into grids Discretize the space into grids �� Decide the start / goal of the charactersDecide the start / goal of the characters

Page 31: Crowd simulation - University of Edinburghhomepages.inf.ed.ac.uk › tkomura › cav › presentation9.pdf · 2012-02-14 · Three streams for crowd simulation Agent based Modelling

Continuum Crowds : Continuum Crowds : procedure 2procedure 2

�� The path that minimizes the cost function The path that minimizes the cost function is going to be pickedis going to be picked

Page 32: Crowd simulation - University of Edinburghhomepages.inf.ed.ac.uk › tkomura › cav › presentation9.pdf · 2012-02-14 · Three streams for crowd simulation Agent based Modelling

Discomfort FieldDiscomfort Field

�� Produced by other obstacles / charactersProduced by other obstacles / characters

Page 33: Crowd simulation - University of Edinburghhomepages.inf.ed.ac.uk › tkomura › cav › presentation9.pdf · 2012-02-14 · Three streams for crowd simulation Agent based Modelling

Continuum Crowds : Continuum Crowds : procedure 2procedure 2

�� Potential fieldPotential field�� Cost to the goal at all the grid pointsCost to the goal at all the grid points

Page 34: Crowd simulation - University of Edinburghhomepages.inf.ed.ac.uk › tkomura › cav › presentation9.pdf · 2012-02-14 · Three streams for crowd simulation Agent based Modelling

EikonalEikonal function function

It makes sense that for any person, the It makes sense that for any person, the optimal strategy is to move opposite the optimal strategy is to move opposite the gradient of, gradient of, ΦΦ as this will decrease cost as this will decrease cost of the path most rapidly.of the path most rapidly.

Φ

Page 35: Crowd simulation - University of Edinburghhomepages.inf.ed.ac.uk › tkomura › cav › presentation9.pdf · 2012-02-14 · Three streams for crowd simulation Agent based Modelling

Fast Marching MethodFast Marching Method

A method to solve efficiently the A method to solve efficiently the problem of front propagationproblem of front propagation

Such as computing the distanceSuch as computing the distancefields, potential fields, fields, potential fields, isosurfacesisosurfacesfields, potential fields, fields, potential fields, isosurfacesisosurfaces

Similar to Similar to Djikstra’sDjikstra’s algorithmalgorithm

Page 36: Crowd simulation - University of Edinburghhomepages.inf.ed.ac.uk › tkomura › cav › presentation9.pdf · 2012-02-14 · Three streams for crowd simulation Agent based Modelling

Fast Marching MethodFast Marching Method

Initialize Step Initialize Step Alive Points: Let Alive Points: Let AA be the set of all grid points {be the set of all grid points {iiAA,j,jAA} the } the

represents the initial curve; represents the initial curve; Narrow Band: Let Narrow Band: Let NarrowBandNarrowBand be the set of all grid points be the set of all grid points

neighbors of A. neighbors of A. Far Away Points: Let Far Away Points: Let FarAwayFarAway be the set of all others grid be the set of all others grid

points {points {i,ji,j}. Set }. Set TTi,ji,j = ¥ for all points in = ¥ for all points in FarAwayFarAway. . points {points {i,ji,j}. Set }. Set TTi,ji,j = ¥ for all points in = ¥ for all points in FarAwayFarAway. .

Page 37: Crowd simulation - University of Edinburghhomepages.inf.ed.ac.uk › tkomura › cav › presentation9.pdf · 2012-02-14 · Three streams for crowd simulation Agent based Modelling

Marching ForwardsMarching Forwards

1. Begin Loop: Let (1. Begin Loop: Let (iiminmin, , jjminmin) be the point in ) be the point in NarrowBandNarrowBand with the with the smallest value for T. smallest value for T.

2. Add the point (2. Add the point (iiminmin, , jjminmin) to A; remove it from ) to A; remove it from NarrowBandNarrowBand. . 3. Tag as neighbors any points (i3. Tag as neighbors any points (iminmin--1, 1, jjminmin), (i), (iminmin+1, +1, jjminmin), (), (iiminmin, j, jminmin--

1), (1), (iiminmin, j, jminmin+1) that are either in +1) that are either in NarrowBandNarrowBand or or FarAwayFarAway. If . If the neighbor is in the neighbor is in FarAwayFarAway, remove it from that list and add it , remove it from that list and add it to the set to the set NarrowBandNarrowBand. .

4. 4. RecomputeRecompute the values of T at all neighborsthe values of T at all neighbors4. 4. RecomputeRecompute the values of T at all neighborsthe values of T at all neighbors

Return to top of Loop. Return to top of Loop.

Page 38: Crowd simulation - University of Edinburghhomepages.inf.ed.ac.uk › tkomura › cav › presentation9.pdf · 2012-02-14 · Three streams for crowd simulation Agent based Modelling

Potential Field Potential Field

�� If the group of people share the same speed, If the group of people share the same speed, goal, and discomfort, we can use the same goal, and discomfort, we can use the same potential field for all these characters potential field for all these characters �� Very efficient if there are little number of groupsVery efficient if there are little number of groups

Page 39: Crowd simulation - University of Edinburghhomepages.inf.ed.ac.uk › tkomura › cav › presentation9.pdf · 2012-02-14 · Three streams for crowd simulation Agent based Modelling

Can simulate the dynamics of Can simulate the dynamics of crowdscrowds

�� A global approach (optimal towards the goal) A global approach (optimal towards the goal) �� Can simulate phenomena observed in real Can simulate phenomena observed in real

humans humans http://www.youtube.com/watch?v=IqIuVhDFSp8

Page 40: Crowd simulation - University of Edinburghhomepages.inf.ed.ac.uk › tkomura › cav › presentation9.pdf · 2012-02-14 · Three streams for crowd simulation Agent based Modelling

Reference Reference

� REYNOLDS, C. W. 1987. Flocks, herds, and schools: A distributed behavioral model. In Computer Graphics (Proceedings of SIGGRAPH 87)

� TU, X., AND TERZOPOULOS, D. 1994. Artificial fishes: Physics, locomotion, perception, behavior. In Proceedings of SIGGRAPH 94, Computer Graphics Proceedings, Annual Conference Series, 43–50.

� SHAO, W., AND TERZOPOULOS, D. 2005. Autonomous pedestrians. In SCA ’05: Proceedings of the 2005 ACM SIGGRAPH/Eurographics symposium on Computer animation, ACM Press, New York, NY, USA, 19–28.symposium on Computer animation, ACM Press, New York, NY, USA, 19–28.

� Crowd Patches: Populating Large-Scale Virtual Environments for Real-Time Applications.Barbara Yersin, Jonathan Maïm, Julien Pettré and Daniel Thalmann.ACM SIGGRAPH Symposium on Interactive 3D Graphics and Games 2009.

� Kang Hoon Lee, Myung Geol Choi and Jehee Lee, Motion Patches: Building Blocks for Virtual Environments Annotated with Motion Data, accepted to ACM SIGGRAPH 2006.

� Adrien Treuille, Seth Cooper, Zoran Popovic, Continuum Crowds,SIGGRAPH 2005