Advertisement

body prediction with angular velocity

Started by October 10, 2006 07:31 PM
2 comments, last by hplus0603 18 years, 4 months ago
hi i have a physical simulation (with ODE) running on a server. the client receives 'physical body updates' every once in a while (say every 1 sec or so). a 'body packet' contains timestamp, position, orientation, linear and angular velocity. in the client, while waiting for the next packet, i try to predict how the body is moving with this:

correction = (lastPacket.LinearVelocity*dt) + (0.5f * acceleration * (dt*dt))
currentPosition = lastPacket.Position + correction
this works ok only when the body is moving in a straight line. my problem is i fail to predict position on a curved motion. the simplest test i've made is having the body running in circle on a plane. so, assuming is only rotating on the y vector, i've tried something like this:

q = Quaternion.FromAxisAngle(Vector.UnitY, lastPacket.AngularVelocity.y*dt)
currentPosition = lastPacket.Position + (q * correction)
it doesn't seems right. predicted body is very different from the real one. what i'm doing wrong?
Ekt
Prediction will not be perfect.

I find that logging the values that I receive, when I receive them, and the values that I predict, and when I predict them (as well as the input values to the predictor), and then plotting them with markers for time, while going over the actual values by hand (say, in an Excel sheet), helps tremendously.
enum Bool { True, False, FileNotFound };
Advertisement
thanks! right now i'm rendering debug vectors while running the simulation in slow motion. dumping numbers and plotting synched in time seems a good idea and i'll try it.

related to the code snippets i've posted above, do you see anything wrong?
Ekt
Quote:
related to the code snippets i've posted above, do you see anything wrong?


That depends more on the specific semantics of the numbers, than the names you've given them.

Personally, I would not include acceleration in interpolation; it just serves to complicate things, and if you get updates often enough, it won't make the interpolation better enough to be worth it.

Also, verify that your values are right (like, how you calculate "dt" for example).
enum Bool { True, False, FileNotFound };

This topic is closed to new replies.

Advertisement