75
Lecture 3 Dead Reckoning and Local Perception Filter 25 January 2010 1 Saturday, January 23, 2010

CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

Lecture 3Dead Reckoning

andLocal Perception Filter

25 January 2010

1Saturday, January 23, 2010

Page 2: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

or

Collect Events

Render

Wait

GameStates

events

states

Simulate Game

GameStates

2Saturday, January 23, 2010

Page 3: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

Player A

What if a state changes continuously (i.e., is a function of time) ?

Player B

Server

3Saturday, January 23, 2010

Page 4: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

Player A

Consider position updates of players. Players send move command. Server replies with positions periodically.

Player B

Server

4Saturday, January 23, 2010

Page 5: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

Two issues:

1. Message overhead2. Delay jitter

5Saturday, January 23, 2010

Page 6: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

Delay jitter causes player’s movement to appear erratic.

Server

Player A

time

6Saturday, January 23, 2010

Page 7: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

Player A

Recall: Short circuiting is used to predict own states. We can similarly predict opponent’s state.

Player B

Server

7Saturday, January 23, 2010

Page 8: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

Suppose the velocity remains constant, then we can predict every position at all time.

Server

Player A

time

predicted position

8Saturday, January 23, 2010

Page 9: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

x[ti] = x[ti−1] + v × (ti − ti−1)

x[t]v

position of entity at time t

velocity of the entity

9Saturday, January 23, 2010

Page 10: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

We send over the initial position x[t], t, and velocity. (Why do we need to send t?)

Server

Player A

time

predicted position

10Saturday, January 23, 2010

Page 11: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

But velocity may change (e.g. a car accelerating). To counter this, we send position, velocity, and acceleration as update.

time

Server

Player A

11Saturday, January 23, 2010

Page 12: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

x[t]v

position of entity at time t

velocity of the entity

x[ti] = x[ti−1] + v(ti − ti−1) +12a(ti − ti−1)2

a acceleration of the entity

12Saturday, January 23, 2010

Page 13: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

B

time

We will still need substantial number of updates if the direction changes frequently (e.g. in a FPS game).

Server

Player A

13Saturday, January 23, 2010

Page 14: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

idea: trade-off message overhead and accuracy. No need to update if error is small.

14Saturday, January 23, 2010

Page 15: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

time

Server

Player A

error threshold

15Saturday, January 23, 2010

Page 16: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

time

Server

Player A

16Saturday, January 23, 2010

Page 17: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

time

Server

Player A

17Saturday, January 23, 2010

Page 18: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

time

predicted position at A

A’s predicted position at the server

Server

Player A

18Saturday, January 23, 2010

Page 19: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

time

A’s version of the entity’s position is now too far away from the correct position. Server updates A with the new velocity and position.

Server

Player A

19Saturday, January 23, 2010

Page 20: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

time

A converges the entity to the correct position smoothly.

Server

Player A

20Saturday, January 23, 2010

Page 21: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

how to set error threshold?

21Saturday, January 23, 2010

Page 22: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

adapt based on game requirement

(e.g. distance to other players)

22Saturday, January 23, 2010

Page 23: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

time

Space inconsistency: due to error threshold and convergence

Time inconsistency: due to message delay and clock asynchrony

Server

Player A

23Saturday, January 23, 2010

Page 24: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

What is the difference between the actual and predicted position ?

How long does the difference last?

24Saturday, January 23, 2010

Page 25: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

error

time

inconsistency =

25Saturday, January 23, 2010

Page 26: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

time

what are the different components of distance error?

Server

Player A

26Saturday, January 23, 2010

Page 27: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

Any drawbacks?

27Saturday, January 23, 2010

Page 28: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

higher CPU cost(needs to simulate other players)

unfair(higher latency leads to larger error)

28Saturday, January 23, 2010

Page 29: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

Dead Reckoning

29Saturday, January 23, 2010

Page 30: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

Generalized Dead Reckoning : Prediction Contract

30Saturday, January 23, 2010

Page 31: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

“return to base”“drive along this road”

31Saturday, January 23, 2010

Page 32: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

Server and clients must have a common notion of “time”

32Saturday, January 23, 2010

Page 33: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

Two choices:

Wall ClockGame Clock

33Saturday, January 23, 2010

Page 34: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

Wall Clock: clients and server have to synchronize their physical clocks using NTP or SNTP.

34Saturday, January 23, 2010

Page 35: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

now is 10:18:32

now is 10:18:30

now is 10:18:29.5

now is 10:18:33.5

35Saturday, January 23, 2010

Page 36: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

now is 10:18:32

now is 10:18:30

now is 10:18:29.5

now is 10:18:33.5

Time now should be10:18:30.5

RTT = 1sOWD = 0.5s

36Saturday, January 23, 2010

Page 37: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

Player A

Players try to sync the game states with the server at the same wallclock time, and predict ahead with an amount of time equal to one-way delay.

Player B

Server

37Saturday, January 23, 2010

Page 38: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

Player A

or: synchronize states to game clock, which runs behind the server by an amount of time equals to the one-way delay.

Player B

Server

38Saturday, January 23, 2010

Page 39: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

A S B

what A seeswhat B sees

3 4 2 game clock

39Saturday, January 23, 2010

Page 40: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

Example: using game clock

40Saturday, January 23, 2010

Page 41: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

A S B

1 2 0

A decides to move. Send event to S.

41Saturday, January 23, 2010

Page 42: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

A S B

1 2 0

S receives event, moves A, and tells A and B that A is moving at t = 3

A S B

2 3 1

42Saturday, January 23, 2010

Page 43: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

A S B

1 2 0

A moves itself at t = 3.

A S B

2 3 1

A S B

3 4 2

43Saturday, January 23, 2010

Page 44: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

A S B

1 2 0

B moves A at t = 3.

A S B

2 3 1

A S B

3 4 2

A S B

4 5 3

44Saturday, January 23, 2010

Page 45: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

Example: using wallclock

45Saturday, January 23, 2010

Page 46: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

A S B

0 0 0

A decides to move. Send event to S.

46Saturday, January 23, 2010

Page 47: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

A S B

0 0 0

S receives event, moves A, and tells A and B that A is moving at t = 1

A S B

1 1 1

47Saturday, January 23, 2010

Page 48: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

A S B

0 0 0

A moves itself to where it should be at t = 2.

A S B

1 1 1

A S B

2 2 2

48Saturday, January 23, 2010

Page 49: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

A S B

0 0 0

B finds out A moves at t = 1 and moves A to where A should be at t = 3

A S B

1 1 1

A S B

2 2 2

A S B

3 3 3

49Saturday, January 23, 2010

Page 50: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

Tight synchronization allows interaction but can lead to visual disruptions.

50Saturday, January 23, 2010

Page 51: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

Asynchronization allows smooth movement but hinder interaction.

51Saturday, January 23, 2010

Page 52: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

Local Perception Filter

52Saturday, January 23, 2010

Page 53: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

Hybrid Model:Render objects within real-time interaction range in real time, other objects in

delayed time.

53Saturday, January 23, 2010

Page 54: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

Two Kinds of Entities

Active: players (unpredictable)Passive: ball, bullet (predictable)

54Saturday, January 23, 2010

Page 55: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

happening now

happened time t ago

A

B

55Saturday, January 23, 2010

Page 56: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

Question:What if a player A throws a

ball at player B?

56Saturday, January 23, 2010

Page 57: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

happening now

happened time t ago

A

B

57Saturday, January 23, 2010

Page 58: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

Question:What if a player B throws a

ball at player A?

58Saturday, January 23, 2010

Page 59: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

happening now

happened time t ago

A

B

59Saturday, January 23, 2010

Page 60: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

Distance of ball (thrown by A) from A versus time.

distance

time

nowtime t ago

now time t ago

60Saturday, January 23, 2010

Page 61: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

What A sees..

distance

time

nowtime t ago

61Saturday, January 23, 2010

Page 62: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

Distance of ball (thrown by B) from A versus time.

distance

time

nowtime t ago

now

time t ago

62Saturday, January 23, 2010

Page 63: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

Distance of ball (thrown by B) from A versus time.

distance

time

nowtime t ago

63Saturday, January 23, 2010

Page 64: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

happened t ago

happened t - 1 ago

happened t - 2 ago

A

B

64Saturday, January 23, 2010

Page 65: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

Question:What if a player A throws a

ball at player B?

65Saturday, January 23, 2010

Page 66: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

What A sees..

distance

time

66Saturday, January 23, 2010

Page 67: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

What A sees..

distance

time

67Saturday, January 23, 2010

Page 68: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

Question:What if a player B throws a

ball at player A?

68Saturday, January 23, 2010

Page 69: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

Distance of ball (thrown by B) from A versus time.

distance

time

69Saturday, January 23, 2010

Page 70: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

70Saturday, January 23, 2010

Page 71: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

time

71Saturday, January 23, 2010

Page 72: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

time

3 slots ago

now

2 slots ago

1 slots ago

72Saturday, January 23, 2010

Page 73: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

Assignment 1

73Saturday, January 23, 2010

Page 74: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

74Saturday, January 23, 2010

Page 75: CS4344 09/10 Lecture 3: Dead Reckoning and Local Perception Filter

Assignment 1

75Saturday, January 23, 2010