This wiki is archived and useful information is being migrated to the main bzflag.org website

Difference between revisions of "Dead Reckoning"

From BZFlagWiki
Jump to: navigation, search
m (add category)
(clarity and grammar)
Line 1: Line 1:
 
This page should give information and suggestion on what Dead Reckoning (DR) is, how it is implemented, what it should be.
 
This page should give information and suggestion on what Dead Reckoning (DR) is, how it is implemented, what it should be.
  
DR is a method to find the current position by measuring the course and distance from a past know point.
+
DR is a method to find the current position by measuring the course and distance from a past known point.
  
It is used in Distributed Interactive Simulation to save the bandwidth in the communication between two different network entities, when exchanging positional information of the object. It starts from a kinematic model of the object.
+
It is used in Distributed Interactive Simulation to conserve bandwidth in the communication between two different network entities, when exchanging positional information of a moving object. It starts with a kinematic model of the object.
  
Let explain that with simple cases around the entity that own the object (A), and the entity that should receive the positional update (B). Name this object tank.
+
Let's explain with a simple case including an object which we'll call "Tank" that is owned by entity (A). There is a second entity (B) that should receive position updates for Tank.
  
A is updating is tank position continuosly, taking into account the environment, the player wished, and the physics (virtual) laws that the game impose. Continuosly just means any frame. A is the master (driver) of the tank.
+
A is updating Tank's position continuously, taking into account the environment, the Tank driver's control inputs, and the physics (virtual) laws that the game imposes. "Continuously" means at some periodic rate. A is the master (driver) of the tank. B recreates the position and orientation of A's Tank locally using data provided by A. B's tank is a slave.
B is following with A, using A provided info to update is local copy of the tank. B is a slave.
+
  
Let assume at first a 0 delay network.
+
Let's first assume a 0 delay network.
  
First approach could be for A to communicate the tank position to B any time (frame) it is updating its internal tank representation. B uses these message to change its internal copy of the tank and uses the last arrived data, whenever tank info should be used. This is a bandwidth wasting!
+
One approach could be for A to communicate the tank position and orientation to B any time it updates its own internal tank representation. B uses these messages to update its internal copy of the tank, using the newest data to have arrived. Unfortunately, this wastes bandwidth!
  
To save bandwidth, A and B could share a DR model of the tank.
+
To conserve bandwidth, A and B could share a Dead Reckoning (DR) model of the tank.
  
After having A updated is tank position, without taking into account the DR model, and just before sending, A compare the current tank position with a predicted tank position, taking now into account the DR model. If the two object representation are not so different, below a threshold, it just avoids sending data. B, when no data is arriving, uses the DR model to know the position of the tank. That is not a futured position. It is just the current position with an error maximized by the threshold. Tank position is however updated periodically, to allow for new player entering in the game. For this to work, we should add DR model parameters to the updated data.
+
When A has updated its Tank position, instead of blindly sending a position update, A compares the current tank position to a predicted tank position that is calculated via the DR model. If the "real" and predicted object representations are the same (or nearly the same within a tolerance) it does not send an update message to B. With no update received from A, B uses its DR model to calculate the position of the tank. That is not a future position. It is the actual current tank position with no more error than is allowed by the tolerance. However, the true tank position *is* updated periodically, to allow for new player's entering in the game. To enable all players' DR models to remain synchronized, we must add DR model parameters to the update messages.
  
This way we do not send tank update when the position can be accurately derived by the old data, saving bandwidth.
+
In this way we only send tank updates when the position cannot be accurately derived by the old data, thus saving bandwidth.
  
Let assume now a fixed delay network.
+
Now let's assume a fixed delay network.
  
With the same behaviour described above, A send its data to B. B update is tank representation with just the same rules above. Forgetting the network delay, B has the "correct" representation of the object, and its history, but just delayed by the network. Here Dead reckoning is not going to "predict" any position, B behaves the same as if DR is not used, (i.e. A send tank updates any frames). Data futuring is not in the game.
+
With the same behavior described above, A send its data to B. B updates its tank representation with the same rules outlined above. B has the "correct" representation of the object, and its history, but just delayed by the network. Here Dead reckoning is not going to "predict" any position, B behaves the same as if DR is not used, (i.e. A send tank updates any frames). Data futuring is not in the game.
  
 
What happens with a jittered network?
 
What happens with a jittered network?

Revision as of 16:56, 27 January 2009

This page should give information and suggestion on what Dead Reckoning (DR) is, how it is implemented, what it should be.

DR is a method to find the current position by measuring the course and distance from a past known point.

It is used in Distributed Interactive Simulation to conserve bandwidth in the communication between two different network entities, when exchanging positional information of a moving object. It starts with a kinematic model of the object.

Let's explain with a simple case including an object which we'll call "Tank" that is owned by entity (A). There is a second entity (B) that should receive position updates for Tank.

A is updating Tank's position continuously, taking into account the environment, the Tank driver's control inputs, and the physics (virtual) laws that the game imposes. "Continuously" means at some periodic rate. A is the master (driver) of the tank. B recreates the position and orientation of A's Tank locally using data provided by A. B's tank is a slave.

Let's first assume a 0 delay network.

One approach could be for A to communicate the tank position and orientation to B any time it updates its own internal tank representation. B uses these messages to update its internal copy of the tank, using the newest data to have arrived. Unfortunately, this wastes bandwidth!

To conserve bandwidth, A and B could share a Dead Reckoning (DR) model of the tank.

When A has updated its Tank position, instead of blindly sending a position update, A compares the current tank position to a predicted tank position that is calculated via the DR model. If the "real" and predicted object representations are the same (or nearly the same within a tolerance) it does not send an update message to B. With no update received from A, B uses its DR model to calculate the position of the tank. That is not a future position. It is the actual current tank position with no more error than is allowed by the tolerance. However, the true tank position *is* updated periodically, to allow for new player's entering in the game. To enable all players' DR models to remain synchronized, we must add DR model parameters to the update messages.

In this way we only send tank updates when the position cannot be accurately derived by the old data, thus saving bandwidth.

Now let's assume a fixed delay network.

With the same behavior described above, A send its data to B. B updates its tank representation with the same rules outlined above. B has the "correct" representation of the object, and its history, but just delayed by the network. Here Dead reckoning is not going to "predict" any position, B behaves the same as if DR is not used, (i.e. A send tank updates any frames). Data futuring is not in the game.

What happens with a jittered network?

With jitter, the fastest packets arrive with a delay that is near the minimum path route, while some other packets arrives later, due to some network bottleneck. Now the tank updates from A to B does not arrive just delayed, but sometimes there is an event time compression, sometimes a time expansion, without A knowing anything about it. If B takes into account this message without any time correction the two prediction algorithm, A & B, behave not the same. And DR is going to alter the perception of A tank in B, not just delaying his history, but changing its trajectory.

One of the most effect of this behaviour is when A cannot control its tank so the DR algorithm works saving much. Jumping! Probably, during jumping A send just few updates, let us assume that it will send 4 updates: beginning, half of the raise, top, half of descent, landing. So take an example.

Tank start to jump, so it send an update. The next update suffers from network congestion, so it is seen delayed at B side. In the mean time, B continue to predict the tank position. When tank is seen at B at half descent, the delayed message was received, so B put back is local view of the tank at the half raise point, where the local view of tank continue is raising. After a while a new update is received putting the tank again forward to his top and half descent position.

I see lot of time this while playing.

To correct this, we should compute the network jitter, and use this to correctly position the tank in time & space as view by the DR algorithm, so it can continue to work happily. The "fixed" (unknown) network delay still apply, so our local tank representation is still delayed and, apart the network congestion event, where we blindly predict the future, truely reflect the remote one.